2

I've added 2 managed beans: ProductController with 2 method:

ist<ProdusDTO> getList()
String update()

and ProductDTO, for entity Product.

index.jsp

<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
<h:dataTable value="#{ProductController.getList()}" var="p">
        <h:column>
            <f:facet name="header">Description</f:facet> #{p.description}
        </h:column>
        <h:column>
            <f:facet name="header">Image</f:facet> #{p.image}
        </h:column>
    </h:dataTable>

    <h2>Adds</h2>
    <h:form>
        <h:panelGrid columns="3">
            Description: <h:inputText value="#{produsDTO.description}" size="100" required="true"></h:inputText>
            Image: <h:inputText value="#{productDTO.image}" size="100" required="true" label="Image"> </h:inputText>
        </h:panelGrid>
        <h:commandButton value="Submit" action="#{ProductController.update()}" />
    </h:form>

When I run the jsp file, I get this error:

PWC6228: #{...} not allowed in a template text body.

In the build path I've included jsf-api.jar and jsf-impl.jar (mojjara 1.2_15)

Why I can't specify for a dataTable component a method for value attribute?

Thanks.

Emanuel
  • 6,622
  • 20
  • 58
  • 78

1 Answers1

3

Unified expression language deferred expressions are only allowed in custom tag attributes that support them (see JSP 2.1 for UEL support).

This is a limitation of using JSPs and JSF. Deferred expressions must be used with a control tag (e.g. an outputText.)

This issue was addressed with the Facelets view technology; consider upgrading if this is possible.

Community
  • 1
  • 1
McDowell
  • 107,573
  • 31
  • 204
  • 267
  • After replacing # with $, I've get another error: According to the TLD, the attribute value is a deferred-value or deferred-method, but the specified value contains a $-expression – Emanuel Dec 12 '11 at 20:25
  • @Emanuel - `${}` and `#{}` expressions are evaluated at different times using different mechanisms. You can only use deferred expressions within a `dataTable`. – McDowell Dec 12 '11 at 20:32
  • 1
    He has already answered it: use for example an `` *(or just get rid of JSP and upgrade to its successor Facelets)* – BalusC Dec 12 '11 at 20:38