This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes h:outputText: Default Value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "h:outputText: Default Value" Watch "h:outputText: Default Value" New topic

h:outputText: Default Value

Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
Hi All, I have a text field that is used to present a date like:
<h utputText value="#{}"/>. What I want to do is, if the bean date is null, I want a default text to show up for example "month/day/year" in the field. What is the easiest way to accomplish this. My backing Bean is something like:

class Bean {
Date date;
public Date getDate() {
return date;

public void setDate(Date date) { = date;

Thanks in advance.

Never be satisfied with anything less than the best and you will surely pass the test...
Rick Beaver
Ranch Hand

Joined: Dec 14, 2004
Posts: 464
I would do:


[ October 12, 2005: Message edited by: Rick Beaver ]

ph34r my 133t j4v4 h4><0r1ng sk177z
Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
Thanks for the solution.
It is sorta covered in the JavaRanch Style Guide.
subject: h:outputText: Default Value
Similar Threads
inputText + inputHelperDatePicker default value problem
How to set default value in input text box - jsf
onClick() to clear text field
Nesting ognl expressions?
Filling a Form based on previous JSP data