I realize this thread is a week old, but I'd like to add that I've
also noticed the lack of some sort of suggested value.  In our case,
we bind UIInputs directly to business object properties, but sometimes
want to suggest a context sensitive value or partially fill it in.

For example, in a reservation system, you might request that the user
enter a contact email, and, if the user is logged in, suggest the
current user's email address when creating a reservation, while
requiring that the field not be left blank.
You already have a complex Reservation business object, so you bind an
input to the properties, e.g. #{reservation.contactEmail},
#{reservation.date}, etc.

In that case, there isn't an easy way for the back-end logic to
populate the contactEmail property on an unpersisted instance, so
we're stuck making the user type their own address over and over.
This seems most appropriate to handle in the view layer anyways, since
no actual business logic/rules are involved, it is just a suggestion,
not a default or anything like that.

Another example might be having the user enter a URL, so you default
the field to 'http://' so they don't have to type that most of the
time.  They can change it to ftp://something and still have to
complete the URL, but you save the user some typing.

On 3/12/07, Mike Kienenberger <[EMAIL PROTECTED]> wrote:
Most people create one backing bean per page.   So you'd simply set
the default values on that backing bean.

One thing you could do is use t:updateActionListener to initialize the
default values on the UICommand that takes you to the next page.

In JSF, the data is stored in the backing beans, not in the page code,
so trying to set default values in the page code isn't a good fit.

On 3/12/07, David Delbecq <[EMAIL PROTECTED]> wrote:
> Thanks but it does not fit the needs
> 1) the default value should be configurable per page. It's not the only
> hidden field. Some have a searchScope that depend on which page the form
> sit in. It can't be initialized by 'managed property'
>
> Cmon, there should be something as simple as defaut="..." that exist in
> JSF. I can't believe a form couldn't have default values in the JSP...
>
> Steve Torrefranca a écrit :
> > I am also a JSF newbie but I think for default values you can try
> > managed property
> >
> > In you faces-config.xml you do something like
> >
> >  <managed-bean>
> >    <managed-bean-name>theBackingBean</managed-bean-name>
> >    <managed-bean-class>
> >    com.whatever.com.TheBackingBean</managed-bean-class>
> >    <managed-bean-scope>
> >    session</managed-bean-scope>
> >      <managed-property>
> >          <property-name>theProperty</property-name>
> >          <value>theDefaultvalue</value>
> >      </managed-property>
> >  </managed-bean>
> >
> >
> >
> >
> > David Delbecq wrote:
> >> Hello,
> >>
> >> I need to design a form in JSF where there are various default value for
> >> various fields.
> >> However, the default value is separated from the backing bean (it's
> >> something to display in initial form). I am not sure how to do this, i
> >> don't see in h:inputHidden anything that relate to a default value.
> >>
> >> I need to convert this struts form:
> >>
> >>
> >>         <html:hidden property="scope" value="${param.searchScope}"/>
> >>         <html:hidden property="requestedNodeResults" value="15"/>
> >>         <html:text property="query" styleClass="search"/>
> >> to a JSF form, but i don't know where to put the '15' and
> >> 'param.searchScope' in JSf
> >>
> >> setting <h:inputHidden value="#{theForm.requestedNodeResults}"/> does
> >> not set the default value to 15.
> >>
> >> Any suggestion to set default value? Do i have to do
> >> <h:inputHidden
> >> value="#{theForm.requestedNodeResults}">15</h:inputHidden> or something
> >> like that? Can't find documentation on setting default form values...
> >>
> >> Help appreciated.
> >>
> >>
> >>
> >
>
>

Reply via email to