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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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

Reply via email to