Hi Volker,

thanks for the tip, I am a little suprised that new GUI objects are generated 
on each request/response
cycle, but 
 UIComponent comp = (UIComponent)  valueChangeEvent.getSource();
 rootPanel = (UIPanel) 
FacesContext.getCurrentInstance().getViewRoot().findComponent( "page:"+<myid>);
 
 does the trick.
 
 Next problem is that I'd like to set the value in the combo box which the user 
has just selected:
 
 UISelectOne combo;
 UISelectItem[] items = new UISelectItem [ mymodel.getItemCount()];
 
 List comboChildren = combo.getChildren();
 
 for( int i=0; i < mymodel.getItemCount(); i++){
    items[i] = myModel.convertToUISelectItem( someparam);
    comboChildren.add( items[i]);                    
    if( mymodel.isSelectedValue(items[i]))
        combo.setValue( items[i].getValue());  //getValue() returns a 
SelectItem 

But the value is never set ! It always displays the first available value in 
the box !

Any ideas ?

Kind regards,

Peter
         
> Hi Peter,
> 
> to find a component which is a descendant of the binding component you
> need to climb the tree up starting at the binding component.
> 
> In restore view phase the component tree is restored and the restored
> component with binding is set into the valuebinding. This is a new
> created object, and so none of your stored references into descendant
> components are valid.
> 
> in your case i think you can do something like this:
> 
> // combo is your old now invalid UISelectOne
> 
> // if the element was rendered before this should work, (afaik)
> String comboId = combo.getClientId();
> 
> combo =
>     FacesContext.getCurrentIstance().getViewRoot().findComponent(":" + 
> comboId);
> 
> Regards,
>    Volker
> 
> 2006/10/10, Peter Rabing <[EMAIL PROTECTED]>:
> > Hi,
> >
> > Why is the getter called only once ?
> > How do I change the list of selectItems - is my code posted below ok for 
> > this ?
> >
> > The submit is correctly rendered in the HTML code, I do get a 
> > ValueChangeEvent in which I
> > then proceed to update the gui components as described below.
> >
> > I'd quite like to use Ajax, but I think I get the basics to work first, 
> > right now I am happy with a submit.
> >
> > kind regards,
> >
> > Peter
> >
> >
> >
> >
> > > If you use component-binding, you need to keep in mind that the
> > > "getter" of your component is only called once, whereas the setter is
> > > called on every request.
> > >
> > > If you need to dynamically change the list of selectItems - you need
> > > to do that in the setter.
> > >
> > > regards,
> > >
> > > Martin
> > >
> > > On 10/10/06, Gerald Müllan <[EMAIL PROTECTED]> wrote:
> > > > Hi,
> > > >
> > > > can you post your jsp-code here?
> > > >
> > > > Have you added the attribute onchange="this.form.submit();" to the
> > > > select menu in jsp code? You have to do a submit after changing the
> > > > selection, otherwise you will only stay on
> > > > the client.
> > > >
> > > > For this kind of usecase you can also use the ajax enabled combobox
> > > > from sandbox, as it is shown on our examples page:
> > > >
> > > > http://example.irian.at/example-sandbox-20061010/ajaxChildComboBox.jsf
> > > >
> > > > Would be a more fluid flow for the user.
> > > >
> > > > cheers,
> > > >
> > > > Gerald
> > > >
> > > > On 10/10/06, Peter Rabing <[EMAIL PROTECTED]> wrote:
> > > > > Hi,
> > > > >
> > > > > I've created a component with a binding expression in which I created 
> > > > > a component tree.
> > > > > The Tree contains 2 combo boxes with some items. Upon Selection of 
> > > > > one item in the combo box
> > > > > (ValueChangeEvent) I change the entries in the 2nd combo box. But 
> > > > > whichever way I do this, the change is
> > > > > never reflected on the page, it always shows the same 2 comboxes with 
> > > > > the same entries again.
> > > > >
> > > > > To modify the box I use e.g.
> > > > > UISelectOne combo; //tried creating new instances as well as re-using 
> > > > > them
> > > > >                    //via a hasmap
> > > > > combo.getChildren().clear();
> > > > > UISelectItem[] items = new UISelectItem [ 4];
> > > > > .. add and fill array ..
> > > > > combo.getChildren().addAll( items);
> > > > >
> > > > > How do I tell it to render the complete page again? Is their some 
> > > > > kind of cache for HTML code?
> > > > >
> > > > > I also tried adding value binding expressions for the entries, but 
> > > > > the getter is never called ...
> > > > >
> > > > > Thanks for your help,
> > > > >
> > > > > Peter
> > > > > --
> >
> > --
> > Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
> > Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
> >
> 
-- 
GMX DSL-Flatrate 0,- Euro* - Überall, wo DSL verfügbar ist!
NEU: Jetzt bis zu 16.000 kBit/s! http://www.gmx.net/de/go/dsl

Reply via email to