Thx Andreas.

When you make a change in the first select box, does the change automatically 
propogate to second
selectbox without submitting the form (or does the change just affect the 
component tree)?

Mike

--- [EMAIL PROTECTED] wrote:

> HI Mike!
> 
> I have done it with a ValueChangeListener, it works fine.
> I get my Values for the BOX from the Database, because I have to update them 
> very quickly. So
> I'm not sure, if you will do that yourself.
> 
> Here is my code, perhaps it helps you:
> 
> 
> <!--FIRST SELECTBOX-->
> <h:selectOneMenu  id="mandanten" styleClass="show"
>       value="#{searchDto.mandant}" 
> valueChangeListener="#{linker.listnewStandortsForSearch}"
>       onchange="submit()"  rendered="#{searchDto.showAlleAnzeigenMandant}" >
>       <f:selectItem itemValue="#{searchDto.nullwert}" itemLabel="#{msg.alle}" 
>  />
>       <f:selectItems value="#{queryHelper.mandanten}"/>
> </h:selectOneMenu>
> 
> <!--SECOND SELECTBOX: DEPENDS ON FIRST SELECTBOX-->
> <h:selectOneMenu id="standorte" styleClass="show"
>       value="#{searchDto.standort}" 
> rendered="#{searchDto.showAlleAnzeigenStandort}">
>       <f:selectItem itemValue="#{searchDto.nullwert}" itemLabel="#{msg.alle}" 
> />
>       <f:selectItems value="#{queryHelper.standorte}"/>
> </h:selectOneMenu>
> 
> //HERE IS THE VALUECHANGEMETHOD:
> 
> public void listnewStandortsForSearch(ValueChangeEvent event) {
> 
>               qh = (QueryHelper) FacesUtil.getManagedBean("queryHelper");
>               searchDto = (SearchDto) FacesUtil.getManagedBean("searchDto");
>               Long newvalue = null;
> 
>               // Überprüfung ob Wert der Mandanten Combobox einen anderen 
> Wert als 0
>               // (=Alle Anzeigen) liefert
>               if (((Long) event.getNewValue()).compareTo(new Long(0)) != 0) {
>                       newvalue = (Long) event.getNewValue();
>                       searchDto.setMandant(newvalue);
> 
>               }
>               else {
>                       searchDto.setMandant(new Long(0));
>               }
> 
>               //CALL METHOD WHICH TAKES THE VALUES FOR THE 2nd BOX OUT OF THE 
> DATABASE, DEPENDING ON THE
> SELECTION OF THE FIRST BOX.
>               try {
>                       qh.liststandorts(newvalue);
>               }
>               catch (Exception e) {
>                       // TODO Auto-generated catch block
>                       e.printStackTrace();
>               }
> 
> 
> //NOT SO INTERESSTING FOR YOU:
>               if (event.getComponent().getId()
>                               .equalsIgnoreCase("newpartnerMandanten")) {
>                       String viewId = "/newpartner.jsp";
>                       FacesContext context = 
> FacesContext.getCurrentInstance();
>                       UIViewRoot view = 
> context.getApplication().getViewHandler()
>                                       .createView(context, viewId);
>                       view.setViewId(viewId);
>                       context.setViewRoot(view);
>                       context.renderResponse();
>               }
>               else {
>                       String viewId = "/search.jsp";
>                       FacesContext context = 
> FacesContext.getCurrentInstance();
>                       UIViewRoot view = 
> context.getApplication().getViewHandler()
>                                       .createView(context, viewId);
>                       view.setViewId(viewId);
>                       context.setViewRoot(view);
>                       context.renderResponse();
>               }
> 
>       }
> 
> -----Ursprüngliche Nachricht-----
> Von: Mike Duffy [mailto:[EMAIL PROTECTED]
> Gesendet: Mittwoch, 14. Dezember 2005 09:37
> An: [email protected]
> Betreff: Dynamic Drop Down Lists
> 
> 
> Is there any way to create dynamic drop down lists in JSF without using AJAX?
> 
> Without JSF there are JavaScript techniques that can be used to dynamically 
> change a drop down
> list (e.g., based on the selection of drop down list A, the values ion drop 
> down list B are
> populated by an onclick function),
> 
> However, with JSF, the changes made in JavaScript do not correspond to the 
> values in the
> component
> tree on the server, so an error is thrown.  I've tried to update the 
> component through a
> "valueChangeListener", but this also generates an error.
> 
> Has anyone found a way to do this in JSF?  Can you send a link with an 
> example?  I Googled with
> no
> success.
> 
> Thx.
> 
> Mike
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> 
> ______________________________________________________________________
> 
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom they
> are addressed. If you have received this email in error please notify
> your system manager.
> 
> This footnote also confirms that this email message has been swept
> for the presence of computer viruses.
> ______________________________________________________________________
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to