Justin Kredible
Justin Kredible

Reputation: 8414

JSF 2.0: outputText does not print date

I have the following code:

<h:outputText value="#{java.util.Calendar.getInstance().getTime()}">
    <f:convertDateTime pattern="MM/dd/yyyy" type="date" />
</h:outputText>

which prints nothing.

When I use the following code:

<h:outputText value="#{group.effectiveDate}">
    <f:convertDateTime pattern="MM/dd/yyyy" type="date" />
</h:outputText>

it works. Does anyone know why invoking java.util.Calendar.getInstance().getTime() does not work? I'm using Mojarra.

Upvotes: 1

Views: 1026

Answers (1)

Zack Marrapese
Zack Marrapese

Reputation: 12080

java.util.Calendar.getInstance().getTime() isn't a valid EL expression. Remember that you can only access beans through EL.

This would either be ones you explicitly create, or ones that are exposed by the container.

when the EL parser sees #{java.util}, it looks for a managed bean named java which has a getUtil() method.

Otherwise, it will probably say something along the lines of "Unable to find managed bean: 'java'".

Upvotes: 2

Related Questions