myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wolf Benz" <euroj...@gmail.com>
Subject t:selectItems behavior (MF 121 - Facelets1.1.13 - Tomahawk Sandbox 2.0)
Date Mon, 29 Oct 2007 10:23:20 GMT
Has someone else had trouble with t:selectItems behavior?
I have the below code in my page. The setup is: a user account name is
picked from a selctOne menu, which has as effect the user is digged up
from the DB, a variable "person" is set in the UserBean (JSF bean) and
this person's fields are then shown under the Menu to update.

<t:selectOneMenu id="personMenu" value="#{userMgmtBean.person.account}"
	     valueChangeListener="#{userMgmtBean.chooseUserTrigger}"
             onchange="submit()" immediate="true">
    <f:selectItem itemLabel="Choose One" itemValue="choose_one" />
    <t:selectItems value="#{utilBean.persons}" var="person"
         itemLabel="#{person.firstName}&#160;#{person.lastName}"
         itemValue="#{person.account}" >
     </t:selectItems>
</t:selectOneMenu>


The referenced listener method, "chooseUserTrigger" of UserBean, digs
up the User from the DB.

public void chooseUserTrigger(ValueChangeEvent event){
		FacesContext ctx = FacesContext.getCurrentInstance();
		String gekozenGebruiker = event.getNewValue().toString();	// = the
User's NT Account
		logger.info("The Chosen Person, is "+ gekozenGebruiker);
		if(gekozenGebruiker.equalsIgnoreCase("choose_one"))		// --> no valid
Action has been chosen but "Choose One"
		{	
			// Do nothing & Exit this loop.
			return;
		}
		// A real user was chosen -> dig up all his data:
		try {
			// First check: Selected user in DB?
			setPerson(getFacade().getUserMgmtBD().getPerson(gekozenGebruiker));
			// If Person is still null, show error:
			if(getPerson() == null){	// tell the user no such person was found
				ctx.addMessage("userMgmtForm", new
FacesMessage(Util.getSpecificMeToMaBundleValue("usr_noneFound"),Util.getSpecificMeToMaBundleValue("usr_noneFound")));
				}
			if(getPerson() != null)logger.info("The Person we found, has these
data: "+ person.toString());
		} catch (PersistenceException e) {
			ctx.addMessage("userMgmtForm", new
FacesMessage(Util.getSpecificMeToMaBundleValue("usr_err"),Util.getSpecificMeToMaBundleValue("usr_err")));
			e.printStackTrace();
		}
		
	}

The problem:
Although the logging("The Person we found, has these data...") shows
the correct user with the correct info was digged up, in a blik of an
eye, the menu filled with users, refills itself, by itself, with
null-items. In the loggings, I also see the person's method setWWID()
is called with a null value. (shouldn't be happening, and certainly
not with a null value; it's WWID - world Wide ID. Certainly my code is
NOT calling it)

Anyone experienced the same probs/has an idea on how to remedy?

-Wolf

Mime
View raw message