You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Sunil Tiwari <su...@tatainfotech.com> on 2005/02/22 14:21:46 UTC

Query regarding multiple dependent on a page.

Hi All,

I have 6 drop downs on a jsf page which act as filters.
i.e. the second drop down depends on the value selected in the first and so on.
When i go to this page, the drop downs should display the selected values from the database if any or default values.
Now, for displaying the values, i populate the bean and use the value attribute of 
<h:selectOneMenu> and <f:selectItems> to highlight the values from the database.
valueChangeListener() are attached with each dropdown to get the new value and change the values of next drop
dropdown. 
Now , i am able to display the values from the database and i am also able to change the values of dropdowns.
But the problem is whenever i click the submit button to save the changed values, the page simply refreshes and the
drop down values become the same as in the database before.
Ideally, the bean values which display the data from database should also be able to get the new values and save them to database.
The scope of the page data bean is session and of the managed bean is request.

Has any one come across this problem?

Any ideas how to make this work?


Thanx & Regards,
Sunil 


Re: Query regarding multiple dependent on a page.

Posted by Sunil Tiwari <su...@tatainfotech.com>.
Hi Slawek,

my code is like this :
<h:selectOneMenu styleClass="selectOneMenu" id="country"

valueChangeListener="#{pc_OperatorBanner.handleCountryValueChange}"

value="#{pc_OperatorBanner.operatorDataBean.cou}"

onchange="return func_1(this, event);">

<f:selectItems id="countrylist" 

value="#{pc_OperatorBanner.operatorDataBean.countries}" />

</h:selectOneMenu>

If i remove the value attribute of select one menu and 
dont populate the "#{pc_OperatorBanner.operatorDataBean.countries}" (which is array of selectItem)
then everything works fine.
For displaying the data from the database, i have to instantiate the bean with the values.
 After that, once the page loads,  user can select new values from the drop down and valuechangelistener does that.
But when i try to save the new values by clicking submit button, the page refreshes and the bean loses the 
new values and retains the previous values from database.

Hope, it clarifies your doubt.
In this case, the bean is populated with some values for displaying and the same bean should be able save the new values 
back to the database.
the value change listeners call a javascript function which submit the form so as to change the value of the next drop down.
And everytime the bean is instantiated again.

any ideas to solve this problem?

Thanx & Regards,
Sunil

----- Original Message ----- 
From: "Slawek" <ss...@o2.pl>
To: "MyFaces Discussion" <my...@incubator.apache.org>
Sent: Wednesday, February 23, 2005 1:35 AM
Subject: Re: Query regarding multiple dependent <h:selectOneMenu> on a page.


>i cant understnad your problem in 100%, but i think it may have something 
> in common with problem that i posted few day ago...
> 
> if you have:
> 
> <h:selectOneMenu value="#{bean.selected_id}">
> <f:selectItems value="#{bean.options}"/>
> <h:selectOneMenu/>
> 
> i assume that bean.options is array of SelectItem...
> if you construct each SelectItem like that: new 
> SelectItem("string_option_id","string_option_value")
> make sure that type of bean.selected_id is also String
> 
> i have wasted few days because my bean.selected_id type was int and 
> SelectItem class was constructed with two String args:D
> 
> Sławek Sobótka
> 
>> Hi All,
>>
>> I have 6 drop downs on a jsf page which act as filters.
>> i.e. the second drop down depends on the value selected in the first and 
>> so on.
>> When i go to this page, the drop downs should display the selected 
>> values from the database if any or default values.
>> Now, for displaying the values, i populate the bean and use the value 
>> attribute of
>> <h:selectOneMenu> and <f:selectItems> to highlight the values from the 
>> database.
>> valueChangeListener() are attached with each dropdown to get the new 
>> value and change the values of next drop
>> dropdown.
>> Now , i am able to display the values from the database and i am also 
>> able to change the values of dropdowns.
>> But the problem is whenever i click the submit button to save the 
>> changed values, the page simply refreshes and the
>> drop down values become the same as in the database before.
>> Ideally, the bean values which display the data from database should 
>> also be able to get the new values and save them to database.
>> The scope of the page data bean is session and of the managed bean is 
>> request.
>>
>> Has any one come across this problem?
>>
>> Any ideas how to make this work?
>>
>>
>> Thanx & Regards,
>> Sunil
>>
>

Re: Query regarding multiple dependent on a page.

Posted by Slawek <ss...@o2.pl>.
i cant understnad your problem in 100%, but i think it may have something 
in common with problem that i posted few day ago...

if you have:

<h:selectOneMenu value="#{bean.selected_id}">
	<f:selectItems value="#{bean.options}"/>
<h:selectOneMenu/>

i assume that bean.options is array of SelectItem...
if you construct each SelectItem like that: new 
SelectItem("string_option_id","string_option_value")
make sure that type of bean.selected_id is also String

i have wasted few days because my bean.selected_id type was int and 
SelectItem class was constructed with two String args:D

Sławek Sobótka

> Hi All,
>
> I have 6 drop downs on a jsf page which act as filters.
> i.e. the second drop down depends on the value selected in the first and 
> so on.
> When i go to this page, the drop downs should display the selected 
> values from the database if any or default values.
> Now, for displaying the values, i populate the bean and use the value 
> attribute of
> <h:selectOneMenu> and <f:selectItems> to highlight the values from the 
> database.
> valueChangeListener() are attached with each dropdown to get the new 
> value and change the values of next drop
> dropdown.
> Now , i am able to display the values from the database and i am also 
> able to change the values of dropdowns.
> But the problem is whenever i click the submit button to save the 
> changed values, the page simply refreshes and the
> drop down values become the same as in the database before.
> Ideally, the bean values which display the data from database should 
> also be able to get the new values and save them to database.
> The scope of the page data bean is session and of the managed bean is 
> request.
>
> Has any one come across this problem?
>
> Any ideas how to make this work?
>
>
> Thanx & Regards,
> Sunil
>