You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Damar Thapa <th...@gmail.com> on 2006/11/18 00:52:55 UTC

how to create a SelectOneMenu with dynamic list

Hi,

Somebody on the list may have implemented this. I have two
SelectOneMenu, A and B, with the same list.  But, when Menu A is
selected, the list of B has to be recreated with (full list minus the
item selected in Menu A).

My valueChangeEvent is something like the following:

public void firstChoiceSelected(ValueChangeEvent vce){
String firstChoice=(String)vce.getNewValue();
java.util.ArrayList<SelectItem> listB=new java.util.ArrayList();
listB=this.getListA(); //ListA=listB initially

//remove the item selected in Menu A
SelectItem item=new SelectItem(firstChoice,firstChoice);
list.remove(item);
this.setListB(listA);

In my case, valueChangeEvent is called, but the list remains the same.
What do I have to do? Any pointers would be highly appreciated.


With regards,

Damar Thapa

Re: how to create a SelectOneMenu with dynamic list

Posted by Damar Thapa <th...@gmail.com>.
Thank you, Jeff. Truly appreciated.

Damar

On 11/30/06, Jeff Bischoff <jb...@klkurz.com> wrote:
> Damar,
>
> Please see link [1] to view the irian examples website. You click
> "MyFaces Sandbox Examples latest build" to get the day's examples. I can
> give you a direct link [2] for what you wanted, and it works today but
> will break tomorrow. See the date in the URL? So best is to use link [1]
> and find the component from there.
>
> [1] http://www.irian.at/myfaces.jsf
> [2] http://example.irian.at/example-sandbox-20061129/ajaxChildComboBox.jsf
>
> Regards,
>
> Jeff Bischoff
> Kenneth L Kurz & Associates, Inc.
>
>
> Damar Thapa wrote:
> > Hi,
> > This link found to be dead now, any idea?
> >
> > http://example.irian.at/example-sandbox-20061118/ajaxChildComboBox.jsf
> >
> > Damar
> >
>
>
>


-- 
With regards,

Damar Thapa

Re: how to create a SelectOneMenu with dynamic list

Posted by Jeff Bischoff <jb...@klkurz.com>.
Damar,

Please see link [1] to view the irian examples website. You click 
"MyFaces Sandbox Examples latest build" to get the day's examples. I can 
give you a direct link [2] for what you wanted, and it works today but 
will break tomorrow. See the date in the URL? So best is to use link [1] 
and find the component from there.

[1] http://www.irian.at/myfaces.jsf
[2] http://example.irian.at/example-sandbox-20061129/ajaxChildComboBox.jsf

Regards,

Jeff Bischoff
Kenneth L Kurz & Associates, Inc.


Damar Thapa wrote:
> Hi,
> This link found to be dead now, any idea?
> 
> http://example.irian.at/example-sandbox-20061118/ajaxChildComboBox.jsf
> 
> Damar
> 



Re: how to create a SelectOneMenu with dynamic list

Posted by Damar Thapa <th...@gmail.com>.
Hi,
This link found to be dead now, any idea?

http://example.irian.at/example-sandbox-20061118/ajaxChildComboBox.jsf

Damar

On 11/18/06, Gerald Müllan <bi...@gmail.com> wrote:
> Hi,
>
> the list is reduced in the ValueChangeEvent method? Apart from this, i
> can`t see any mistakes in the code snippet.
>
> Any errors shown in the page? (don`t forget t:messages)
>
> Alternatively you can also use the sandbox ajax comboBox [1] which
> should exactly fit your needs and seems to be more user friendly.
>
> cheers,
>
> Gerald
>
> [1] http://example.irian.at/example-sandbox-20061118/ajaxChildComboBox.jsf
>
> On 11/18/06, Damar Thapa <th...@gmail.com> wrote:
> > Hi,
> >
> > Somebody on the list may have implemented this. I have two
> > SelectOneMenu, A and B, with the same list.  But, when Menu A is
> > selected, the list of B has to be recreated with (full list minus the
> > item selected in Menu A).
> >
> > My valueChangeEvent is something like the following:
> >
> > public void firstChoiceSelected(ValueChangeEvent vce){
> > String firstChoice=(String)vce.getNewValue();
> > java.util.ArrayList<SelectItem> listB=new java.util.ArrayList();
> > listB=this.getListA(); //ListA=listB initially
> >
> > //remove the item selected in Menu A
> > SelectItem item=new SelectItem(firstChoice,firstChoice);
> > list.remove(item);
> > this.setListB(listA);
> >
> > In my case, valueChangeEvent is called, but the list remains the same.
> > What do I have to do? Any pointers would be highly appreciated.
> >
> >
> > With regards,
> >
> > Damar Thapa
> >
>
>
> --
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>


-- 
With regards,

Damar Thapa

Re: how to create a SelectOneMenu with dynamic list

Posted by Gerald Müllan <bi...@gmail.com>.
Hi,

the list is reduced in the ValueChangeEvent method? Apart from this, i
can`t see any mistakes in the code snippet.

Any errors shown in the page? (don`t forget t:messages)

Alternatively you can also use the sandbox ajax comboBox [1] which
should exactly fit your needs and seems to be more user friendly.

cheers,

Gerald

[1] http://example.irian.at/example-sandbox-20061118/ajaxChildComboBox.jsf

On 11/18/06, Damar Thapa <th...@gmail.com> wrote:
> Hi,
>
> Somebody on the list may have implemented this. I have two
> SelectOneMenu, A and B, with the same list.  But, when Menu A is
> selected, the list of B has to be recreated with (full list minus the
> item selected in Menu A).
>
> My valueChangeEvent is something like the following:
>
> public void firstChoiceSelected(ValueChangeEvent vce){
> String firstChoice=(String)vce.getNewValue();
> java.util.ArrayList<SelectItem> listB=new java.util.ArrayList();
> listB=this.getListA(); //ListA=listB initially
>
> //remove the item selected in Menu A
> SelectItem item=new SelectItem(firstChoice,firstChoice);
> list.remove(item);
> this.setListB(listA);
>
> In my case, valueChangeEvent is called, but the list remains the same.
> What do I have to do? Any pointers would be highly appreciated.
>
>
> With regards,
>
> Damar Thapa
>


-- 
http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces