You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by song <so...@hotmail.com> on 2007/08/01 16:29:45 UTC

Re: Tomahawk and SaveState

I also encounter a problem like this :i request the page,shou correct,when i
submit the page,rase an error.

jsf page:

<h:selectManyListbox id="teams" value="#{UserForm.userTeamIds}" >
<f:selectItems value="#{UserForm.userTeamMap}"/>
</h:selectManyListbox>


backing bean :

public class UserForm {
	private UserService userService;

	private User user;
	

.......

	public List<String> getUserTeamIds(){
		log.debug("getUserTeamIds go here..");
		List<String> li=new java.util.ArrayList<String>();
		if(user!=null){
			Set<Team> teams=user.getTeams();
			for (Iterator<Team> itr=teams.iterator();itr.hasNext();){
				Team r=itr.next();
				li.add(r.getTeamId().toString());
			}
		}
		return li;
	}


	/**
	 * for select many
	 * @return
	 */
	public Map<String,String> getUserTeamMap(){
		log.debug("getUserTeamMap here :");
		java.util.Map<String,String> m=new java.util.LinkedHashMap<String,
String>();
		if(user!=null){
			Set<Team> teams=user.getTeams();
			for (Iterator<Team> itr=teams.iterator();itr.hasNext();){
				Team t=itr.next();
				m.put(t.getTeamName(),t.getTeamId().toString());
			}
		}
		return m;
	}

............
}


run in en error :
-------------------------------------------------
javax.servlet.ServletException
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)

org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)

org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)

org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)

root cause 

java.util.NoSuchElementException

javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:117)

javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:164)
	javax.faces.component.SelectItemsIterator.next(SelectItemsIterator.java:49)
	javax.faces.component.UISelectMany.matchValue(UISelectMany.java:485)
	javax.faces.component.UISelectMany.validateValue(UISelectMany.java:454)
	javax.faces.component.UIInput.validate(UIInput.java:867)
	javax.faces.component.UIInput.executeValidate(UIInput.java:1065)
	javax.faces.component.UIInput.processValidators(UIInput.java:666)

javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1030)

javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1030)

javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1030)

javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1030)

javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1030)
	javax.faces.component.UIForm.processValidators(UIForm.java:229)

javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1030)
	javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:662)

com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:100)
	com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
	com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)

org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)

org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)

org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)

-------------------------------------------------

i debug in it  ,when i post the page,the page invoke the
UserForm.getUserTeamMap() method,but return
a empety map,then the server validate the selectmany's available value and
selectedItems,then mismath.and throw a exception......is this reson????  who
can tell me .







Damien GUERIN wrote:
> 
> Hi everyone,
> 
> i've a problem with the UISaveState component... I've a JSF page which
> contains a form with many inputs.
> 
> <h:form id="myForm">
> 	<t:saveState id="save" value="#{mainBean}" />
> 	<h:selectOneMenu id="sessionLabel"
> 		value="#{mainBean.param1}"
> 		immediate="true" onchange="submit()"
> 		valueChangeListener="#{mainBean.param1SelectionChangedHandler}">
> 		<f:selectItems value="#{mainBean.param1List}" />
> 	</h:selectOneMenu>
> 	<h:inputText id="param1" value="#{mainBean.param2}" />
>         <h:commandButton action="#{mainBean.doValidate}"
> 		value="OK" />
> </h:form>
> 
> mainBean is a bean which contains :
> - param1 attribute ;
> - param2 attribute ;
> - secondBean : bean to fill param2 in function of param1 selection.
> 
> So, my problem :
> when the param1 value changes, the param2 don't change even if the param2
> value seems to be calculated and assigned correctly in the mainBean (the
> display don't work, saveState, restoreState problem??).
> If the secondBean is declared transient, when the param1 value changes,
> the param2 value changes too and it's ok but in this case, there is a
> problem in the form submission. The value of param2 is always the
> calculated value in param1SelectionChangedHandler even if user change the
> value directly in the form (the setter of param2 doen't seem to be
> used)...
> 
> Thanks a lot.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tomahawk-and-SaveState-tf4193716.html#a11946698
Sent from the MyFaces - Users mailing list archive at Nabble.com.