You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Aneesha Govil <po...@gmail.com> on 2006/11/13 11:24:40 UTC

Query about SelectOneMenus in t:datalist

Hi,

I have two drop-downs in a datalist, i.e., there are several rows, each
having two dropdowns and a textbox. On change of the first dropdown, I need
to change the select items in the second dropdown and manipulate the textbox
(change it to a calendar or dropdown). Now the problem is, since the
components are being built dynamically, I have no way of knowing the ID of
the first dropdown. Therefore I cannot use something like this in the
sandbox:

<h:selectOneMenu value="#{ajaxChildComboBoxBean.selectedCountry}"
id="parentCombo">
    <f:selectItems value="#{ajaxChildComboBoxBean.countries}"/>
</h:selectOneMenu>
	
<f:verbatim>
    <br/><br/>
 </f:verbatim>

<s:ajaxChildComboBox value="#{ajaxChildComboBoxBean.selectedCity}"
parentComboBox="parentCombo"

ajaxSelectItemsMethod="#{ajaxChildComboBoxBean.getCitiesOfSelectedCountry}">
    <f:selectItems value="#{ajaxChildComboBoxBean.cities}"/>	
</s:ajaxChildComboBox>

I was trying to do this manually, change the components in the
valuechangelistener but for this I need more information than just the new
value. Any way I could pass more than one values in a value change listener?
Or use updateactionlistener with selectonemenu to update several backing
bean attributes?

Please ask if any more information is required to be able to help.
Please help, this is a show stopper in my application. :(

Thanks in advance,
Regards,
Aneesha

Re: Query about SelectOneMenus in t:datalist

Posted by Aneesha Govil <po...@gmail.com>.
Got this to work. I forgot to add "onchange=submit()" to the selectone menu.

Regards,
Aneesha



On 11/13/06, Aneesha Govil <po...@gmail.com> wrote:
>
> Hi all,
>
> I am trying to solve this problem by using datatable instead of datalist
> and retrieving the current row using getRow. However, the
> valuechangelistener of the selectonemenu is not being called inside the
> datatable. I am using the following code:
>
> HtmlSimpleColumn column = new HtmlSimpleColumn();
>
> HtmlSelectOneMenu columnsDropdown = new HtmlSelectOneMenu();
> vb = FacesContext.getCurrentInstance().getApplication().createValueBinding("#{
> record.columnDropDown.selectedValue}");
> columnsDropdown.setValueBinding ("value", vb);
> MethodBinding mb = FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{
> filter.columnChangeListener}", new Class[]{ValueChangeEvent.class});
> columnsDropdown.setValueChangeListener(mb);
>
> UISelectItems columnSelectItems = new UISelectItems();
> vb = FacesContext.getCurrentInstance
> ().getApplication().createValueBinding("#{
> record.columnDropDown.selectItems}");
> columnSelectItems.setValueBinding("value", vb);
> columnsDropdown.getChildren().add(columnSelectItems);
>
> column.getChildren().add(columnsDropdown);
> datatableChild.getChildren().add(column);
>
> The signature of the valuechangelistener is as follows:
>
> public void columnChangeListener(ValueChangeEvent event) {
> // code here
> }
>
> Anyone got any idea why this is not working? What am I doing wrong?
>
> Please help.
> Thanks,
> Aneesha
>
>
>
> On 11/13/06, Aneesha Govil < popcorn09@gmail.com> wrote:
> >
> > Hi,
> >
> > I have two drop-downs in a datalist, i.e., there are several rows, each
> > having two dropdowns and a textbox. On change of the first dropdown, I need
> > to change the select items in the second dropdown and manipulate the textbox
> > (change it to a calendar or dropdown). Now the problem is, since the
> > components are being built dynamically, I have no way of knowing the ID of
> > the first dropdown. Therefore I cannot use something like this in the
> > sandbox:
> >
> > <h:selectOneMenu value="#{ajaxChildComboBoxBean.selectedCountry}" id="parentCombo">
> >     <f:selectItems value="#{ajaxChildComboBoxBean.countries}"/>
> > </h:selectOneMenu>
> >
> >
> >
> > 	
> > <f:verbatim>
> >     <br/><br/>
> >  </f:verbatim>
> >
> > <s:ajaxChildComboBox value="#{ajaxChildComboBoxBean.selectedCity}" parentComboBox="parentCombo"
> >
> >
> >
> >                              ajaxSelectItemsMethod="#{ajaxChildComboBoxBean.getCitiesOfSelectedCountry}">
> >     <f:selectItems value="#{ajaxChildComboBoxBean.cities}"/>	
> > </s:ajaxChildComboBox>
> >
> >
> >
> >
> > I was trying to do this manually, change the components in the
> > valuechangelistener but for this I need more information than just the new
> > value. Any way I could pass more than one values in a value change listener?
> > Or use updateactionlistener with selectonemenu to update several backing
> > bean attributes?
> >
> > Please ask if any more information is required to be able to help.
> > Please help, this is a show stopper in my application. :(
> >
> > Thanks in advance,
> > Regards,
> > Aneesha
> >
> >
> >
> >
>

Re: Query about SelectOneMenus in t:datalist

Posted by Aneesha Govil <po...@gmail.com>.
Hi all,

I am trying to solve this problem by using datatable instead of datalist and
retrieving the current row using getRow. However, the valuechangelistener of
the selectonemenu is not being called inside the datatable. I am using the
following code:

HtmlSimpleColumn column = new HtmlSimpleColumn();

HtmlSelectOneMenu columnsDropdown = new HtmlSelectOneMenu();
vb = FacesContext.getCurrentInstance
().getApplication().createValueBinding("#{
record.columnDropDown.selectedValue}");
columnsDropdown.setValueBinding("value", vb);
MethodBinding mb = FacesContext.getCurrentInstance
().getApplication().createMethodBinding("#{filter.columnChangeListener}",
new Class[]{ValueChangeEvent.class});
columnsDropdown.setValueChangeListener(mb);

UISelectItems columnSelectItems = new UISelectItems();
vb = FacesContext.getCurrentInstance
().getApplication().createValueBinding("#{record.columnDropDown.selectItems
}");
columnSelectItems.setValueBinding("value", vb);
columnsDropdown.getChildren().add(columnSelectItems);

column.getChildren().add(columnsDropdown);
datatableChild.getChildren().add(column);

The signature of the valuechangelistener is as follows:

public void columnChangeListener(ValueChangeEvent event) {
// code here
}

Anyone got any idea why this is not working? What am I doing wrong?

Please help.
Thanks,
Aneesha



On 11/13/06, Aneesha Govil <po...@gmail.com> wrote:
>
> Hi,
>
> I have two drop-downs in a datalist, i.e., there are several rows, each
> having two dropdowns and a textbox. On change of the first dropdown, I need
> to change the select items in the second dropdown and manipulate the textbox
> (change it to a calendar or dropdown). Now the problem is, since the
> components are being built dynamically, I have no way of knowing the ID of
> the first dropdown. Therefore I cannot use something like this in the
> sandbox:
>
> <h:selectOneMenu value="#{ajaxChildComboBoxBean.selectedCountry}" id="parentCombo">
>     <f:selectItems value="#{ajaxChildComboBoxBean.countries}"/>
> </h:selectOneMenu>
>
> 	
> <f:verbatim>
>     <br/><br/>
>  </f:verbatim>
>
> <s:ajaxChildComboBox value="#{ajaxChildComboBoxBean.selectedCity}" parentComboBox="parentCombo"
>
>                              ajaxSelectItemsMethod="#{ajaxChildComboBoxBean.getCitiesOfSelectedCountry}">
>     <f:selectItems value="#{ajaxChildComboBoxBean.cities}"/>	
> </s:ajaxChildComboBox>
>
>
> I was trying to do this manually, change the components in the
> valuechangelistener but for this I need more information than just the new
> value. Any way I could pass more than one values in a value change listener?
> Or use updateactionlistener with selectonemenu to update several backing
> bean attributes?
>
> Please ask if any more information is required to be able to help.
> Please help, this is a show stopper in my application. :(
>
> Thanks in advance,
> Regards,
> Aneesha
>
>
>
>