You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Bruno Aranda <br...@gmail.com> on 2006/06/13 22:18:19 UTC
Re: Conditionally rendered fields not retaing values
Could you try if that works if your bean is in session scope?
Bruno
On 6/13/06, Meghana <sy...@yahoo.com> wrote:
> Hi,
> I have a form in which the displayed input fields change based on a radio
> button field. When ever the field value is changed a corresponding
> valuechangelistener method is called and then the new set of input fields
> are displayed. But the values entered for those conditionally rendered
> fields are not retaining values in the backing bean. They are all null. I've
> been banging my head over this for quite a while.
> Any ideas please!
>
> Thanks a lot,
> -M
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
Re: Conditionally rendered fields not retaing values
Posted by Murray Brandon <mu...@hotmagna.com>.
For some reason I got a "Symantec Mail Security detected prohibited
content in a message sent from your address" so I have dumbed down the
email a bit, removing quotes etc and resent. Sorry if you got it twice.
Murray Brandon wrote:
> If rendered=false, APPLY_REQUEST_VALUES doesn't get applied to the
> component, so the backing bean is untouched, isn't it?
> Correct me if I'm wrong, 'cos lots of my assumptions are based on that
> fact. (smiley removed here)
>
> In the past, when a component hasn't been persisiting I've found it to
> be:
>
> 1) Programmer error, badly written bean from 5am. or
> 2) The component is outside the form being submitted. or
> 3) The button or link to submit the form has immediate=true on it.
> Immediate means don't submit the form, just execute the action.
>
4) Ah yes, and because I didn't have an h:messages tag and there was a
conversion error.
Re: Conditionally rendered fields not retaing values
Posted by Murray Brandon <mu...@hotmagna.com>.
If rendered="false", APPLY_REQUEST_VALUES doesn't get applied to the
component, so the backing bean is untouched, isn't it?
Correct me if I'm wrong, 'cos lots of my assumptions are based on that
fact. ;-)
In the past, when a component hasn't been persisiting I've found it to be:
1) Programmer error, badly written bean from 5am. or
2) The component is outside the form being submitted. or
2) The button or link to submit the form has immediate="true" on it.
Immediate means don't submit the form, just execute the action.
Re: Conditionally rendered fields not retaing values
Posted by Meghana <sy...@yahoo.com>.
Bruno,
I tried the hack. It seems to produce the old behavior. Its not retaining the values of the conditionally rendered fields.
<h:outputText value="#{Message.hardware_type}" />
<h:selectOneRadio value="#{ServiceBean.hardwareType}" valueChangeListener="#{ServiceBean.hardwareTypeChanged}"
onclick="document.getElementById('newHWRForm:hiddenButton').click()"
immediate="true">
<f:selectItems value="#{ServiceBean.HWTypes}"/>
</h:selectOneRadio>
<t:commandButton id="hiddenButton" style="visibility:hidden" immediate="true" action="nothing"/>
I am also checking out the subForm. Will post once I am done with that.
Thanks,
Hemanth
Bruno Aranda <br...@gmail.com> wrote: I have two choices in my mind now. One is more elegant than the other,
which is a hack actually. The more elegant is to use the sandbox
s:subForm component [1]. I haven't used it myself so I cannot be or
more help. The hack is to click with javascript an invisible button
with the immediate that sends the form, something like this:
onclick="document.getElementById('hiddenButton').click()"
immediate="true"
valueChangeListener="#{ServiceBean.hardwareTypeChanged}">
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
RE: Conditionally rendered fields not retaing values
Posted by Julian Ray <ju...@yahoo.com>.
I faced a similar problem when using conditionally rendered panes. The best
solution I found was to render them all with JSP but use javascript to hide
the unused panes. Works like a charm and is actually better as I can switch
the rendered pane without requiring a round-trip to the server.
-----Original Message-----
From: Bruno Aranda [mailto:brunoaranda@gmail.com]
Sent: Tuesday, June 13, 2006 5:52 PM
To: MyFaces Discussion
Subject: Re: Conditionally rendered fields not retaing values
I have two choices in my mind now. One is more elegant than the other, which
is a hack actually. The more elegant is to use the sandbox s:subForm
component [1]. I haven't used it myself so I cannot be or more help. The
hack is to click with javascript an invisible button with the immediate that
sends the form, something like this:
<h:selectOneRadio ...
onclick="document.getElementById('hiddenButton').click()"
immediate="true"
valueChangeListener="#{ServiceBean.hardwareTypeChanged}">
...
</h:selectOneRadio>
<t:commandButton style="visibility:hidden" immediate="true"
action="nothing"/>
Note that both the selectOne and the button are immediate="true". It is an
ugly hack, so the subform option is a better approach...
Bruno
[1] http://myfaces.apache.org/sandbox/subForm.html
On 6/13/06, Meghana <sy...@yahoo.com> wrote:
> Bruno,
> Thanks a lot! That was it. One side effect though. It seems to
> validate and show the error messages for the required fields and
> others. Any idea how to circumvent that?
> -M
>
>
>
> Bruno Aranda <br...@gmail.com> wrote:
>
> Does it work if you remove the immediate="true" attribute from the
> selectOneRadio (see this docs to see if you really need it [1]), and
> remove the facesContext.renderResponse() line (not needed).
>
> Let's see!
>
> Bruno
>
> [1]
> http://wiki.apache.org/myfaces/How_The_Immediate_Attribute_Works
>
> On 6/13/06, Meghana wrote:
> > I am sorry I should have included my code snippet before itself.
> > Here we go!
> >
> >
> >
> > onclick="submit()" immediate="true"
> > valueChangeListener="#{ServiceBean.hardwareTypeChanged}">
> >
> >
> >
> > public void hardwareTypeChanged(ValueChangeEvent event) throws
> > SQLException, Exception{ FacesContext context =
> > FacesContext.getCurrentInstance();
> > String prevCategorySelected = (String)event.getOldValue(); String
> > newCategorySelected = (String)event.getNewValue();
> >
> >
> if(!newCategorySelected.equalsIgnoreCase(prevCategorySelected)){
> > // Value changed. Change the drop down values.
> > if(newCategorySelected.equals("Desktop")){
> > desktopSelected = true;
> > debug("Setting desktopSelected field to:
> > "+isDesktopSelected());
> > }
> > else if(newCategorySelected.equals("Laptop")){
> > laptopSelected = true;
> > debug("Setting laptopSelected field to:
> > "+isLaptopSelected()+" Laptop Type: "+laptopType); }
> > context.renderResponse(); } } }
> >
> > Based on what hardware type is selected Desktop items/laptop items
> > are displayed.
> > The code for that is
> >
> > rendered="#{ServiceBean.desktopSelected}"/>
> >
> >
> > id="desktop_type">
> >
> > itemLabel="Standard User Desktop" />
> >
> > itemLabel="Non User Desktop" />
> >
> >
> >
> >
> > rendered="#{ServiceBean.laptopSelected}"/>
> >
> >
> > id="laptop_type">
> >
> > itemLabel="Standard User Laptop" />
> >
> > itemLabel="Power User Laptop" />
> >
> >
> >
> >
> > rendered="#{ServiceBean.laptopSelected}"/>
> >
> >
> > id="docking_station">
> >
> >
> >
> >
> >
> >
> > rendered="#{ServiceBean.laptopSelected}"/>
> >
> >
> > id="wireless_access">
>
> >
> >
> >
> >
> >
> >
> >
> >
> > Bruno Aranda wrote:
> >
> > And what about the "immediate" attributes? Are you using them? Can
> > you show an snippet of your code?
> >
> > Bruno
> >
> > On 6/13/06, Meghana wrote:
> > > Its already in session scope :-(
> > >
> > >
> > > Bruno Aranda wrote:
> > >
> > > Could you try if that works if your bean is in session scope?
> > >
> > > Bruno
> > >
> > > On 6/13/06, Meghana wrote:
> > > > Hi,
> > > > I have a form in which the displayed input fields change based
> > > > on a
> > radio
> > > > button field. When ever the field value is changed a
> > > > corresponding valuechangelistener method is called and then the
> > > > new set of input
> > fields
> > > > are displayed. But the values entered for those conditionally
> > > > rendered fields are not retaining values in the backing bean.
> > > > They are all
> null.
> > > I've
> > > > been banging my head over this for quite a while.
> > > > Any ideas please!
> > > >
> > > > Thanks a lot,
> > > > -M
> > > >
> > > >
> > > > __________________________________________________
> > > > Do You Yahoo!?
> > > > Tired of spam? Yahoo! Mail has the best spam protection around
> > > > http://mail.yahoo.com
> > >
> > >
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam? Yahoo! Mail has the best spam protection around
> > > http://mail.yahoo.com
> >
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
Re: Conditionally rendered fields not retaing values
Posted by Bruno Aranda <br...@gmail.com>.
I have two choices in my mind now. One is more elegant than the other,
which is a hack actually. The more elegant is to use the sandbox
s:subForm component [1]. I haven't used it myself so I cannot be or
more help. The hack is to click with javascript an invisible button
with the immediate that sends the form, something like this:
<h:selectOneRadio ...
onclick="document.getElementById('hiddenButton').click()"
immediate="true"
valueChangeListener="#{ServiceBean.hardwareTypeChanged}">
...
</h:selectOneRadio>
<t:commandButton style="visibility:hidden" immediate="true" action="nothing"/>
Note that both the selectOne and the button are immediate="true". It
is an ugly hack, so the subform option is a better approach...
Bruno
[1] http://myfaces.apache.org/sandbox/subForm.html
On 6/13/06, Meghana <sy...@yahoo.com> wrote:
> Bruno,
> Thanks a lot! That was it. One side effect though. It seems to validate and
> show the error messages for the required fields and others. Any idea how to
> circumvent that?
> -M
>
>
>
> Bruno Aranda <br...@gmail.com> wrote:
>
> Does it work if you remove the immediate="true" attribute from the
> selectOneRadio (see this docs to see if you really need it [1]), and
> remove the facesContext.renderResponse() line (not needed).
>
> Let's see!
>
> Bruno
>
> [1]
> http://wiki.apache.org/myfaces/How_The_Immediate_Attribute_Works
>
> On 6/13/06, Meghana wrote:
> > I am sorry I should have included my code snippet before itself.
> > Here we go!
> >
> >
> >
> > onclick="submit()" immediate="true"
> > valueChangeListener="#{ServiceBean.hardwareTypeChanged}">
> >
> >
> >
> > public void hardwareTypeChanged(ValueChangeEvent event)
> > throws SQLException, Exception{
> > FacesContext context = FacesContext.getCurrentInstance();
> > String prevCategorySelected = (String)event.getOldValue();
> > String newCategorySelected = (String)event.getNewValue();
> >
> >
> if(!newCategorySelected.equalsIgnoreCase(prevCategorySelected)){
> > // Value changed. Change the drop down values.
> > if(newCategorySelected.equals("Desktop")){
> > desktopSelected = true;
> > debug("Setting desktopSelected field to:
> > "+isDesktopSelected());
> > }
> > else if(newCategorySelected.equals("Laptop")){
> > laptopSelected = true;
> > debug("Setting laptopSelected field to:
> > "+isLaptopSelected()+" Laptop Type: "+laptopType);
> > }
> > context.renderResponse();
> > }
> > }
> > }
> >
> > Based on what hardware type is selected Desktop items/laptop items are
> > displayed.
> > The code for that is
> >
> > rendered="#{ServiceBean.desktopSelected}"/>
> >
> >
> > id="desktop_type">
> >
> > itemLabel="Standard User Desktop" />
> >
> > itemLabel="Non User Desktop" />
> >
> >
> >
> >
> > rendered="#{ServiceBean.laptopSelected}"/>
> >
> >
> > id="laptop_type">
> >
> > itemLabel="Standard User Laptop" />
> >
> > itemLabel="Power User Laptop" />
> >
> >
> >
> >
> > rendered="#{ServiceBean.laptopSelected}"/>
> >
> >
> > id="docking_station">
> >
> >
> >
> >
> >
> >
> > rendered="#{ServiceBean.laptopSelected}"/>
> >
> >
> > id="wireless_access">
>
> >
> >
> >
> >
> >
> >
> >
> >
> > Bruno Aranda wrote:
> >
> > And what about the "immediate" attributes? Are you using them? Can you
> > show an snippet of your code?
> >
> > Bruno
> >
> > On 6/13/06, Meghana wrote:
> > > Its already in session scope :-(
> > >
> > >
> > > Bruno Aranda wrote:
> > >
> > > Could you try if that works if your bean is in session scope?
> > >
> > > Bruno
> > >
> > > On 6/13/06, Meghana wrote:
> > > > Hi,
> > > > I have a form in which the displayed input fields change based on a
> > radio
> > > > button field. When ever the field value is changed a corresponding
> > > > valuechangelistener method is called and then the new set of input
> > fields
> > > > are displayed. But the values entered for those conditionally rendered
> > > > fields are not retaining values in the backing bean. They are all
> null.
> > > I've
> > > > been banging my head over this for quite a while.
> > > > Any ideas please!
> > > >
> > > > Thanks a lot,
> > > > -M
> > > >
> > > >
> > > > __________________________________________________
> > > > Do You Yahoo!?
> > > > Tired of spam? Yahoo! Mail has the best spam protection around
> > > > http://mail.yahoo.com
> > >
> > >
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam? Yahoo! Mail has the best spam protection around
> > > http://mail.yahoo.com
> >
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
RE: Conditionally rendered fields not retaing values
Posted by James Richards <ja...@northps.com>.
Note that the below renderResponse() invocation will cause the LifecycleImpl to stop processing after the ValueChangeHandler is invoked because FacesContext.getRenderResponse() returns true, basically halting further processing [aka, no model update]. It sounds like this is not what you want to happen.
-----Original Message-----
From: Bruno Aranda [mailto:brunoaranda@gmail.com]
Sent: Tue 6/13/2006 4:37 PM
To: MyFaces Discussion
Subject: Re: Conditionally rendered fields not retaing values
Does it work if you remove the immediate="true" attribute from the
selectOneRadio (see this docs to see if you really need it [1]), and
remove the facesContext.renderResponse() line (not needed).
Let's see!
Bruno
[1] http://wiki.apache.org/myfaces/How_The_Immediate_Attribute_Works
On 6/13/06, Meghana <sy...@yahoo.com> wrote:
> I am sorry I should have included my code snippet before itself.
> Here we go!
>
> <h:outputText value="#{Message.hardware_type}" />
> <h:selectOneRadio value="#{ServiceBean.hardwareType}"
> onclick="submit()" immediate="true"
> valueChangeListener="#{ServiceBean.hardwareTypeChanged}">
> <f:selectItems value="#{ServiceBean.HWTypes}"/>
> </h:selectOneRadio>
>
> public void hardwareTypeChanged(ValueChangeEvent event)
> throws SQLException, Exception{
> FacesContext context = FacesContext.getCurrentInstance();
> String prevCategorySelected = (String)event.getOldValue();
> String newCategorySelected = (String)event.getNewValue();
>
> if(!newCategorySelected.equalsIgnoreCase(prevCategorySelected)){
> // Value changed. Change the drop down values.
> if(newCategorySelected.equals("Desktop")){
> desktopSelected = true;
> debug("Setting desktopSelected field to:
> "+isDesktopSelected());
> }
> else if(newCategorySelected.equals("Laptop")){
> laptopSelected = true;
> debug("Setting laptopSelected field to:
> "+isLaptopSelected()+" Laptop Type: "+laptopType);
> }
> context.renderResponse();
> }
> }
> }
>
> Based on what hardware type is selected Desktop items/laptop items are
> displayed.
> The code for that is
> <h:outputText value="#{Message.desktop_type}"
> rendered="#{ServiceBean.desktopSelected}"/>
> <h:panelGroup rendered="#{ServiceBean.desktopSelected}">
> <h:selectOneRadio value="#{ServiceBean.desktopType}"
> id="desktop_type">
> <f:selectItem itemValue="Standard User Desktop"
> itemLabel="Standard User Desktop" />
> <f:selectItem itemValue="Non User Desktop"
> itemLabel="Non User Desktop" />
> </h:selectOneRadio>
> <h:message styleClass="error" for="desktop_type"/>
> </h:panelGroup>
> <h:outputText value="#{Message.laptop_type}"
> rendered="#{ServiceBean.laptopSelected}"/>
> <h:panelGroup rendered="#{ServiceBean.laptopSelected}">
> <h:selectOneRadio value="#{ServiceBean.laptopType}"
> id="laptop_type">
> <f:selectItem itemValue="Standard User Laptop"
> itemLabel="Standard User Laptop" />
> <f:selectItem itemValue="Power User Laptop"
> itemLabel="Power User Laptop" />
> </h:selectOneRadio>
> <h:message styleClass="error" for="laptop_type"/>
> </h:panelGroup>
> <h:outputText value="#{Message.docking_station}"
> rendered="#{ServiceBean.laptopSelected}"/>
> <h:panelGroup rendered="#{ServiceBean.laptopSelected}">
> <h:selectOneRadio value="#{ServiceBean.dockingStation}"
> id="docking_station">
> <f:selectItem itemValue="Yes" itemLabel="Yes" />
> <f:selectItem itemValue="No" itemLabel="No" />
> </h:selectOneRadio>
> <h:message styleClass="error" for="docking_station"/>
> </h:panelGroup>
> <h:outputText value="#{Message.wireless_access}"
> rendered="#{ServiceBean.laptopSelected}"/>
> <h:panelGroup rendered="#{ServiceBean.laptopSelected}">
> <h:selectOneRadio value="#{ServiceBean.wirelessAccess}"
> id="wireless_access">
> <f:selectItem itemValue="Yes" itemLabel="Yes" />
> <f:selectItem itemValue="No" itemLabel="No" />
> </h:selectOneRadio>
> <h:message styleClass="error" for="wireless_access"/>
> </h:panelGroup>
>
>
>
> Bruno Aranda <br...@gmail.com> wrote:
>
> And what about the "immediate" attributes? Are you using them? Can you
> show an snippet of your code?
>
> Bruno
>
> On 6/13/06, Meghana wrote:
> > Its already in session scope :-(
> >
> >
> > Bruno Aranda wrote:
> >
> > Could you try if that works if your bean is in session scope?
> >
> > Bruno
> >
> > On 6/13/06, Meghana wrote:
> > > Hi,
> > > I have a form in which the displayed input fields change based on a
> radio
> > > button field. When ever the field value is changed a corresponding
> > > valuechangelistener method is called and then the new set of input
> fields
> > > are displayed. But the values entered for those conditionally rendered
> > > fields are not retaining values in the backing bean. They are all null.
> > I've
> > > been banging my head over this for quite a while.
> > > Any ideas please!
> > >
> > > Thanks a lot,
> > > -M
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam? Yahoo! Mail has the best spam protection around
> > > http://mail.yahoo.com
> >
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
Re: Conditionally rendered fields not retaing values
Posted by Meghana <sy...@yahoo.com>.
Bruno,
Thanks a lot! That was it. One side effect though. It seems to validate and show the error messages for the required fields and others. Any idea how to circumvent that?
-M
Bruno Aranda <br...@gmail.com> wrote: Does it work if you remove the immediate="true" attribute from the
selectOneRadio (see this docs to see if you really need it [1]), and
remove the facesContext.renderResponse() line (not needed).
Let's see!
Bruno
[1] http://wiki.apache.org/myfaces/How_The_Immediate_Attribute_Works
On 6/13/06, Meghana wrote:
> I am sorry I should have included my code snippet before itself.
> Here we go!
>
>
>
> onclick="submit()" immediate="true"
> valueChangeListener="#{ServiceBean.hardwareTypeChanged}">
>
>
>
> public void hardwareTypeChanged(ValueChangeEvent event)
> throws SQLException, Exception{
> FacesContext context = FacesContext.getCurrentInstance();
> String prevCategorySelected = (String)event.getOldValue();
> String newCategorySelected = (String)event.getNewValue();
>
> if(!newCategorySelected.equalsIgnoreCase(prevCategorySelected)){
> // Value changed. Change the drop down values.
> if(newCategorySelected.equals("Desktop")){
> desktopSelected = true;
> debug("Setting desktopSelected field to:
> "+isDesktopSelected());
> }
> else if(newCategorySelected.equals("Laptop")){
> laptopSelected = true;
> debug("Setting laptopSelected field to:
> "+isLaptopSelected()+" Laptop Type: "+laptopType);
> }
> context.renderResponse();
> }
> }
> }
>
> Based on what hardware type is selected Desktop items/laptop items are
> displayed.
> The code for that is
>
> rendered="#{ServiceBean.desktopSelected}"/>
>
>
> id="desktop_type">
>
> itemLabel="Standard User Desktop" />
>
> itemLabel="Non User Desktop" />
>
>
>
>
> rendered="#{ServiceBean.laptopSelected}"/>
>
>
> id="laptop_type">
>
> itemLabel="Standard User Laptop" />
>
> itemLabel="Power User Laptop" />
>
>
>
>
> rendered="#{ServiceBean.laptopSelected}"/>
>
>
> id="docking_station">
>
>
>
>
>
>
> rendered="#{ServiceBean.laptopSelected}"/>
>
>
> id="wireless_access">
>
>
>
>
>
>
>
>
> Bruno Aranda
wrote:
>
> And what about the "immediate" attributes? Are you using them? Can you
> show an snippet of your code?
>
> Bruno
>
> On 6/13/06, Meghana wrote:
> > Its already in session scope :-(
> >
> >
> > Bruno Aranda wrote:
> >
> > Could you try if that works if your bean is in session scope?
> >
> > Bruno
> >
> > On 6/13/06, Meghana wrote:
> > > Hi,
> > > I have a form in which the displayed input fields change based on a
> radio
> > > button field. When ever the field value is changed a corresponding
> > > valuechangelistener method is called and then the new set of input
> fields
> > > are displayed. But the values entered for those conditionally rendered
> > > fields are not retaining values in the backing bean. They are all null.
> > I've
> > > been banging my head over this for quite a while.
> > > Any ideas please!
> > >
> > > Thanks a lot,
> > > -M
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam? Yahoo! Mail has the best spam protection around
> > > http://mail.yahoo.com
> >
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: Conditionally rendered fields not retaing values
Posted by Bruno Aranda <br...@gmail.com>.
Does it work if you remove the immediate="true" attribute from the
selectOneRadio (see this docs to see if you really need it [1]), and
remove the facesContext.renderResponse() line (not needed).
Let's see!
Bruno
[1] http://wiki.apache.org/myfaces/How_The_Immediate_Attribute_Works
On 6/13/06, Meghana <sy...@yahoo.com> wrote:
> I am sorry I should have included my code snippet before itself.
> Here we go!
>
> <h:outputText value="#{Message.hardware_type}" />
> <h:selectOneRadio value="#{ServiceBean.hardwareType}"
> onclick="submit()" immediate="true"
> valueChangeListener="#{ServiceBean.hardwareTypeChanged}">
> <f:selectItems value="#{ServiceBean.HWTypes}"/>
> </h:selectOneRadio>
>
> public void hardwareTypeChanged(ValueChangeEvent event)
> throws SQLException, Exception{
> FacesContext context = FacesContext.getCurrentInstance();
> String prevCategorySelected = (String)event.getOldValue();
> String newCategorySelected = (String)event.getNewValue();
>
> if(!newCategorySelected.equalsIgnoreCase(prevCategorySelected)){
> // Value changed. Change the drop down values.
> if(newCategorySelected.equals("Desktop")){
> desktopSelected = true;
> debug("Setting desktopSelected field to:
> "+isDesktopSelected());
> }
> else if(newCategorySelected.equals("Laptop")){
> laptopSelected = true;
> debug("Setting laptopSelected field to:
> "+isLaptopSelected()+" Laptop Type: "+laptopType);
> }
> context.renderResponse();
> }
> }
> }
>
> Based on what hardware type is selected Desktop items/laptop items are
> displayed.
> The code for that is
> <h:outputText value="#{Message.desktop_type}"
> rendered="#{ServiceBean.desktopSelected}"/>
> <h:panelGroup rendered="#{ServiceBean.desktopSelected}">
> <h:selectOneRadio value="#{ServiceBean.desktopType}"
> id="desktop_type">
> <f:selectItem itemValue="Standard User Desktop"
> itemLabel="Standard User Desktop" />
> <f:selectItem itemValue="Non User Desktop"
> itemLabel="Non User Desktop" />
> </h:selectOneRadio>
> <h:message styleClass="error" for="desktop_type"/>
> </h:panelGroup>
> <h:outputText value="#{Message.laptop_type}"
> rendered="#{ServiceBean.laptopSelected}"/>
> <h:panelGroup rendered="#{ServiceBean.laptopSelected}">
> <h:selectOneRadio value="#{ServiceBean.laptopType}"
> id="laptop_type">
> <f:selectItem itemValue="Standard User Laptop"
> itemLabel="Standard User Laptop" />
> <f:selectItem itemValue="Power User Laptop"
> itemLabel="Power User Laptop" />
> </h:selectOneRadio>
> <h:message styleClass="error" for="laptop_type"/>
> </h:panelGroup>
> <h:outputText value="#{Message.docking_station}"
> rendered="#{ServiceBean.laptopSelected}"/>
> <h:panelGroup rendered="#{ServiceBean.laptopSelected}">
> <h:selectOneRadio value="#{ServiceBean.dockingStation}"
> id="docking_station">
> <f:selectItem itemValue="Yes" itemLabel="Yes" />
> <f:selectItem itemValue="No" itemLabel="No" />
> </h:selectOneRadio>
> <h:message styleClass="error" for="docking_station"/>
> </h:panelGroup>
> <h:outputText value="#{Message.wireless_access}"
> rendered="#{ServiceBean.laptopSelected}"/>
> <h:panelGroup rendered="#{ServiceBean.laptopSelected}">
> <h:selectOneRadio value="#{ServiceBean.wirelessAccess}"
> id="wireless_access">
> <f:selectItem itemValue="Yes" itemLabel="Yes" />
> <f:selectItem itemValue="No" itemLabel="No" />
> </h:selectOneRadio>
> <h:message styleClass="error" for="wireless_access"/>
> </h:panelGroup>
>
>
>
> Bruno Aranda <br...@gmail.com> wrote:
>
> And what about the "immediate" attributes? Are you using them? Can you
> show an snippet of your code?
>
> Bruno
>
> On 6/13/06, Meghana wrote:
> > Its already in session scope :-(
> >
> >
> > Bruno Aranda wrote:
> >
> > Could you try if that works if your bean is in session scope?
> >
> > Bruno
> >
> > On 6/13/06, Meghana wrote:
> > > Hi,
> > > I have a form in which the displayed input fields change based on a
> radio
> > > button field. When ever the field value is changed a corresponding
> > > valuechangelistener method is called and then the new set of input
> fields
> > > are displayed. But the values entered for those conditionally rendered
> > > fields are not retaining values in the backing bean. They are all null.
> > I've
> > > been banging my head over this for quite a while.
> > > Any ideas please!
> > >
> > > Thanks a lot,
> > > -M
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam? Yahoo! Mail has the best spam protection around
> > > http://mail.yahoo.com
> >
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
Re: Conditionally rendered fields not retaing values
Posted by Richard Capraro <ri...@gmail.com>.
According to me, this is normal.
Because in the JSF lifecycle, after the valuechangelistener, the phase
is 'update model values', so the values you 'get' in the
valuechangelistener (your bean properties) haven't yet been updated.
Besides, if you read these values in a binded UIcomponent, a
component.getnewvalue() instruction will work, because the phase 'apply
request values' has been completed.
Regards,
Richard
Meghana a écrit :
> I am sorry I should have included my code snippet before itself.
> Here we go!
>
> <h:outputText value="#{Message.hardware_type}" />
> <h:selectOneRadio value="#{ServiceBean.hardwareType}"
> onclick="submit()" immediate="true"
> valueChangeListener="#{ServiceBean.hardwareTypeChanged}">
> <f:selectItems value="#{ServiceBean.HWTypes}"/>
> </h:selectOneRadio>
>
> public void hardwareTypeChanged(ValueChangeEvent event) throws
> SQLException, Exception{
> FacesContext context = FacesContext.getCurrentInstance();
> String prevCategorySelected = (String)event.getOldValue();
> String newCategorySelected = (String)event.getNewValue();
> if(!newCategorySelected.equalsIgnoreCase(prevCategorySelected)){
> // Value changed. Change the drop down values.
> if(newCategorySelected.equals("Desktop")){
> desktopSelected = true;
> debug("Setting desktopSelected field to:
> "+isDesktopSelected());
> }
> else if(newCategorySelected.equals("Laptop")){
> laptopSelected = true;
> debug("Setting laptopSelected field to:
> "+isLaptopSelected()+" Laptop Type: "+laptopType);
> }
> context.renderResponse();
> }
> }
> }
>
> Based on what hardware type is selected Desktop items/laptop items
> are displayed.
> The code for that is
> <h:outputText value="#{Message.desktop_type}"
> rendered="#{ServiceBean.desktopSelected}"/>
> <h:panelGroup rendered="#{ServiceBean.desktopSelected}">
> <h:selectOneRadio value="#{ServiceBean.desktopType}"
> id="desktop_type">
> <f:selectItem itemValue="Standard User Desktop"
> itemLabel="Standard User Desktop" />
> <f:selectItem itemValue="Non User Desktop"
> itemLabel="Non User Desktop" />
> </h:selectOneRadio>
> <h:message styleClass="error" for="desktop_type"/>
> </h:panelGroup>
> <h:outputText value="#{Message.laptop_type}"
> rendered="#{ServiceBean.laptopSelected}"/>
> <h:panelGroup rendered="#{ServiceBean.laptopSelected}">
> <h:selectOneRadio value="#{ServiceBean.laptopType}"
> id="laptop_type">
> <f:selectItem itemValue="Standard User Laptop"
> itemLabel="Standard User Laptop" />
> <f:selectItem itemValue="Power User Laptop"
> itemLabel="Power User Laptop" />
> </h:selectOneRadio>
> <h:message styleClass="error" for="laptop_type"/>
> </h:panelGroup>
> <h:outputText value="#{Message.docking_station}"
> rendered="#{ServiceBean.laptopSelected}"/>
> <h:panelGroup rendered="#{ServiceBean.laptopSelected}">
> <h:selectOneRadio
> value="#{ServiceBean.dockingStation}" id="docking_station">
> <f:selectItem itemValue="Yes" itemLabel="Yes" />
> <f:selectItem itemValue="No" itemLabel="No" />
> </h:selectOneRadio>
> <h:message styleClass="error" for="docking_station"/>
> </h:panelGroup>
> <h:outputText value="#{Message.wireless_access}"
> rendered="#{ServiceBean.laptopSelected}"/>
> <h:panelGroup rendered="#{ServiceBean.laptopSelected}">
> <h:selectOneRadio
> value="#{ServiceBean.wirelessAccess}" id="wireless_access">
> <f:selectItem itemValue="Yes" itemLabel="Yes" />
> <f:selectItem itemValue="No" itemLabel="No" />
> </h:selectOneRadio>
> <h:message styleClass="error" for="wireless_access"/>
> </h:panelGroup>
>
>
> */Bruno Aranda <br...@gmail.com>/* wrote:
>
> And what about the "immediate" attributes? Are you using them? Can you
> show an snippet of your code?
>
> Bruno
>
> On 6/13/06, Meghana wrote:
> > Its already in session scope :-(
> >
> >
> > Bruno Aranda wrote:
> >
> > Could you try if that works if your bean is in session scope?
> >
> > Bruno
> >
> > On 6/13/06, Meghana wrote:
> > > Hi,
> > > I have a form in which the displayed input fields change based
> on a radio
> > > button field. When ever the field value is changed a corresponding
> > > valuechangelistener method is called and then the new set of
> input fields
> > > are displayed. But the values entered for those conditionally
> rendered
> > > fields are not retaining values in the backing bean. They are
> all null.
> > I've
> > > been banging my head over this for quite a while.
> > > Any ideas please!
> > >
> > > Thanks a lot,
> > > -M
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam? Yahoo! Mail has the best spam protection around
> > > http://mail.yahoo.com
> >
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
Re: Conditionally rendered fields not retaing values
Posted by Meghana <sy...@yahoo.com>.
I am sorry I should have included my code snippet before itself.
Here we go!
<h:outputText value="#{Message.hardware_type}" />
<h:selectOneRadio value="#{ServiceBean.hardwareType}" onclick="submit()" immediate="true" valueChangeListener="#{ServiceBean.hardwareTypeChanged}">
<f:selectItems value="#{ServiceBean.HWTypes}"/>
</h:selectOneRadio>
public void hardwareTypeChanged(ValueChangeEvent event) throws SQLException, Exception{
FacesContext context = FacesContext.getCurrentInstance();
String prevCategorySelected = (String)event.getOldValue();
String newCategorySelected = (String)event.getNewValue();
if(!newCategorySelected.equalsIgnoreCase(prevCategorySelected)){
// Value changed. Change the drop down values.
if(newCategorySelected.equals("Desktop")){
desktopSelected = true;
debug("Setting desktopSelected field to: "+isDesktopSelected());
}
else if(newCategorySelected.equals("Laptop")){
laptopSelected = true;
debug("Setting laptopSelected field to: "+isLaptopSelected()+" Laptop Type: "+laptopType);
}
context.renderResponse();
}
}
}
Based on what hardware type is selected Desktop items/laptop items are displayed.
The code for that is
<h:outputText value="#{Message.desktop_type}" rendered="#{ServiceBean.desktopSelected}"/>
<h:panelGroup rendered="#{ServiceBean.desktopSelected}">
<h:selectOneRadio value="#{ServiceBean.desktopType}" id="desktop_type">
<f:selectItem itemValue="Standard User Desktop" itemLabel="Standard User Desktop" />
<f:selectItem itemValue="Non User Desktop" itemLabel="Non User Desktop" />
</h:selectOneRadio>
<h:message styleClass="error" for="desktop_type"/>
</h:panelGroup>
<h:outputText value="#{Message.laptop_type}" rendered="#{ServiceBean.laptopSelected}"/>
<h:panelGroup rendered="#{ServiceBean.laptopSelected}">
<h:selectOneRadio value="#{ServiceBean.laptopType}" id="laptop_type">
<f:selectItem itemValue="Standard User Laptop" itemLabel="Standard User Laptop" />
<f:selectItem itemValue="Power User Laptop" itemLabel="Power User Laptop" />
</h:selectOneRadio>
<h:message styleClass="error" for="laptop_type"/>
</h:panelGroup>
<h:outputText value="#{Message.docking_station}" rendered="#{ServiceBean.laptopSelected}"/>
<h:panelGroup rendered="#{ServiceBean.laptopSelected}">
<h:selectOneRadio value="#{ServiceBean.dockingStation}" id="docking_station">
<f:selectItem itemValue="Yes" itemLabel="Yes" />
<f:selectItem itemValue="No" itemLabel="No" />
</h:selectOneRadio>
<h:message styleClass="error" for="docking_station"/>
</h:panelGroup>
<h:outputText value="#{Message.wireless_access}" rendered="#{ServiceBean.laptopSelected}"/>
<h:panelGroup rendered="#{ServiceBean.laptopSelected}">
<h:selectOneRadio value="#{ServiceBean.wirelessAccess}" id="wireless_access">
<f:selectItem itemValue="Yes" itemLabel="Yes" />
<f:selectItem itemValue="No" itemLabel="No" />
</h:selectOneRadio>
<h:message styleClass="error" for="wireless_access"/>
</h:panelGroup>
Bruno Aranda <br...@gmail.com> wrote: And what about the "immediate" attributes? Are you using them? Can you
show an snippet of your code?
Bruno
On 6/13/06, Meghana wrote:
> Its already in session scope :-(
>
>
> Bruno Aranda
wrote:
>
> Could you try if that works if your bean is in session scope?
>
> Bruno
>
> On 6/13/06, Meghana wrote:
> > Hi,
> > I have a form in which the displayed input fields change based on a radio
> > button field. When ever the field value is changed a corresponding
> > valuechangelistener method is called and then the new set of input fields
> > are displayed. But the values entered for those conditionally rendered
> > fields are not retaining values in the backing bean. They are all null.
> I've
> > been banging my head over this for quite a while.
> > Any ideas please!
> >
> > Thanks a lot,
> > -M
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: Conditionally rendered fields not retaing values
Posted by Bruno Aranda <br...@gmail.com>.
And what about the "immediate" attributes? Are you using them? Can you
show an snippet of your code?
Bruno
On 6/13/06, Meghana <sy...@yahoo.com> wrote:
> Its already in session scope :-(
>
>
> Bruno Aranda <br...@gmail.com> wrote:
>
> Could you try if that works if your bean is in session scope?
>
> Bruno
>
> On 6/13/06, Meghana wrote:
> > Hi,
> > I have a form in which the displayed input fields change based on a radio
> > button field. When ever the field value is changed a corresponding
> > valuechangelistener method is called and then the new set of input fields
> > are displayed. But the values entered for those conditionally rendered
> > fields are not retaining values in the backing bean. They are all null.
> I've
> > been banging my head over this for quite a while.
> > Any ideas please!
> >
> > Thanks a lot,
> > -M
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
Re: Conditionally rendered fields not retaing values
Posted by Meghana <sy...@yahoo.com>.
Its already in session scope :-(
Bruno Aranda <br...@gmail.com> wrote: Could you try if that works if your bean is in session scope?
Bruno
On 6/13/06, Meghana wrote:
> Hi,
> I have a form in which the displayed input fields change based on a radio
> button field. When ever the field value is changed a corresponding
> valuechangelistener method is called and then the new set of input fields
> are displayed. But the values entered for those conditionally rendered
> fields are not retaining values in the backing bean. They are all null. I've
> been banging my head over this for quite a while.
> Any ideas please!
>
> Thanks a lot,
> -M
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com