You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Johannes Hiemer <jh...@web.de> on 2005/08/09 10:21:05 UTC

Reloading values in forms after ValueChangeEvent in bean

Good morning together,
after I tried for nearly an hour to get this problem solved, I would like to ask you all if anyone could help me. I got the following constellation: I have form having a selectOneMenu:

	<x:selectOneMenu id="selectSystem" immediate="true" onchange="this.form.submit( );"
       valueChangeListener="#{requestSpringBean.filter}">
				<f:selectItems value="#{requestSpringBean.systemBean}" />
		</x:selectOneMenu>

If the value changes the event gets fired and it should change the following textboxes:

		<x:outputLabel value="#{bundle.requestBuidling}" for="building" />
		<x:inputText value="#{requestSpringBean.system.sbuilding}" id="building" />
		<x:outputLabel value="#{bundle.requestFloor}" for="floor" />
		<x:inputText value="#{requestSpringBean.system.sfloor}" id="floor" />
		<x:outputLabel value="#{bundle.requestRoom}" for="room" /> 
		<x:inputText value="#{requestSpringBean.system.sroom}" id="room" />
		<x:outputLabel value="#{bundle.requestTable}" for="table" /> 
		<x:inputText value="#{requestSpringBean.system.stable}" id="table" />	

So, because they are referencing system in my requestSpringBean I thought, if I just null system and put new values into, that it should update the values in the frontend automatically.

               
	HtmlSelectOneMenu systemMenu = (HtmlSelectOneMenu) event.getComponent().findComponent("selectSystem");
		setSystem(null);
		setSystem(getSystemManager().getSystem(systemMenu.getValue().toString()));

But trying it that way it didn't work, so I tried to reference the inputFields directly and update them "by hand" like this:

HtmlInputText building = (HtmlInputText) event.getComponent().findComponent("building");
		HtmlInputText floor = (HtmlInputText) event.getComponent().findComponent("floor");
		HtmlInputText room = (HtmlInputText) event.getComponent().findComponent("room");
		HtmlInputText table = (HtmlInputText) event.getComponent().findComponent("table");

system = getSystemManager().getSystem(systemMenu.getValue().toString());
		building.setValue(system.getSbuilding());
		floor.setValue(system.getSfloor());
		room.setValue(system.getSroom());
		table.setValue(system.getStable());

But that didn't work either. So what I want to ask is, am I doing something wrong in my concept? Or do I miss a tag or something like that?

I hope I provided enough information, to help you understand my problem.

Regards Johannes

PS: Thanks a lot for all comment, tipps, tricks and hints :-)
______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193


Antwort: Reloading values in forms after ValueChangeEvent in bean

Posted by ma...@daimlerchrysler.com.
I don't know if I understand you right, two possible solutions:

1. reset the input compoments in the listerner:

HtmlInputText building = (HtmlInputText) 
event.getComponent().findComponent("building");
building.setSubmittedValue(null);


2. do a page navigation to the same page with a command component 
(immediate="true") with an action outcome that maps in the navigation 
rules to the same page you are displaying.
This would involve a additional command control, that you have to invoke 
by java script on the client.
 

jhiemer@web.de schrieb am 09.08.2005 10:21:05:

> 
> Good morning together,
> after I tried for nearly an hour to get this problem solved, I would
> like to ask you all if anyone could help me. I got the following 
> constellation: I have form having a selectOneMenu:
> 
>    <x:selectOneMenu id="selectSystem" immediate="true" 
> onchange="this.form.submit( );"
>        valueChangeListener="#{requestSpringBean.filter}">
>             <f:selectItems value="#{requestSpringBean.systemBean}" />
>       </x:selectOneMenu>
> 
> If the value changes the event gets fired and it should change the 
> following textboxes:
> 
>       <x:outputLabel value="#{bundle.requestBuidling}" for="building" />
>       <x:inputText value="#{requestSpringBean.system.sbuilding}" 
> id="building" />
>       <x:outputLabel value="#{bundle.requestFloor}" for="floor" />
>       <x:inputText value="#{requestSpringBean.system.sfloor}" id="floor" 
/>
>       <x:outputLabel value="#{bundle.requestRoom}" for="room" /> 
>       <x:inputText value="#{requestSpringBean.system.sroom}" id="room" 
/>
>       <x:outputLabel value="#{bundle.requestTable}" for="table" /> 
>       <x:inputText value="#{requestSpringBean.system.stable}" id="table" 
/> 
> 
> So, because they are referencing system in my requestSpringBean I 
> thought, if I just null system and put new values into, that it 
> should update the values in the frontend automatically.
> 
> 
>    HtmlSelectOneMenu systemMenu = (HtmlSelectOneMenu) event.
> getComponent().findComponent("selectSystem");
>       setSystem(null);
>       setSystem(getSystemManager().getSystem(systemMenu.getValue().
> toString()));
> 
> But trying it that way it didn't work, so I tried to reference the 
> inputFields directly and update them "by hand" like this:
> 
> HtmlInputText building = (HtmlInputText) event.getComponent().
> findComponent("building");
>       HtmlInputText floor = (HtmlInputText) event.getComponent().
> findComponent("floor");
>       HtmlInputText room = (HtmlInputText) event.getComponent().
> findComponent("room");
>       HtmlInputText table = (HtmlInputText) event.getComponent().
> findComponent("table");
> 
> system = getSystemManager().getSystem(systemMenu.getValue().toString());
>       building.setValue(system.getSbuilding());
>       floor.setValue(system.getSfloor());
>       room.setValue(system.getSroom());
>       table.setValue(system.getStable());
> 
> But that didn't work either. So what I want to ask is, am I doing 
> something wrong in my concept? Or do I miss a tag or something like 
that?
> 
> I hope I provided enough information, to help you understand my problem.
> 
> Regards Johannes
> 
> PS: Thanks a lot for all comment, tipps, tricks and hints :-)
> ______________________________________________________________
> Verschicken Sie romantische, coole und witzige Bilder per SMS!
> Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193
>