[jboss-user] [JBoss Seam] - convertEntity: mixing session and conversation data

awheeler do-not-reply at jboss.com
Sun Aug 5 22:27:45 EDT 2007


I am using Seam 1.2.1GA and I have problem with s:convertEntity such as:



  | 			<h:selectOneMenu id="clientBranch" value="#{loggedInUser.clientBranch}" styleClass="input-field" required="true" style="width:50%">
  | 				<s:selectItems value="#{editVehicleIncident.userBranchList}" var="b" label="#{b.companyName}" noSelectionLabel="[Select your company branch]" hideNoSelectionLabel="true"/>
  | 				<s:convertEntity/>			
  | 			</h:selectOneMenu>
  | 

The bean loggedInUser is a session bean. When the form submits JSF reports that the field is not valid. I have debugged the EntityConverter class and it returns the selected value correctly from the getAsObject function. This means (I assume) the validation error is occuring within JSF, in my case MyFaces.

The session bean function is:

  | 	public List<Company> getBranchList() {
  | 		return this.flattenedBranches;
  | 	}
  | 


To experiment I sourced the list from a bean in the current conversation. This function gets the list from the session bean and merges it (using entityManager) into a local list.


  | 	@In(value="loggedInUser", required=true)
  | 	private IUser user;
  | 
  | 	private List<Company> userBranchList;
  | 	public List<Company> getUserBranchList() {
  | 		if (this.userBranchList == null) {
  | 			this.userBranchList = new ArrayList<Company>();
  | 			Iterator itr = this.loggedInUser.getBranchList().iterator();
  | 			while (itr.hasNext()) {
  | 				Company branch = (Company)itr.next();
  | 				
  | 				this.userBranchList.add(super.getEntityManager().merge(branch));
  | 			}
  | 		}
  | 		
  | 		return this.userBranchList;
  | 	}
  | 

This works without JSF reporting any validation problems. 

I really don't understand why this does not work for session data as the EntityConverter class uses entityManager.find to look-up the data using the data's primary key. This means that the EntityConverter is returning a "merged" result using the current conversation's entityManager.

Does anyone have any thoughts?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4071015#4071015

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4071015



More information about the jboss-user mailing list