Help with application scope bean
lle Dec 13, 2006 8:05 PMHi,
I am a newbie with Seam and am trying to convert my JSF application to use Seam without ejb3.
I have an application scoped action object, which initialized a map of javabeans from the database, as below:
@Name("appManager") @Scope(ScopeType.APPLICATION) @Startup public class GAHostAppManagedAction { @In private Session session; @Logger private Log log; private Map<String, List<Items>> hostAppsByHostName; public List<SelectItem> getHostList() { ... this instantiate and initialized a list SelectItem, containing String of host } @Create public void init() { ... get a list of Items and populate it to the map } }
Here is my home.xhtml code snippet:
<h:form> <h3>Please enter your name and password:</h3> <h:panelGrid columns="2"> Name: <h:inputText value="#{user.userName}"/> Password: <h:inputSecret value="#{user.userPassword}"/> Host: <h:selectOneMenu value="#{hostapp.host}"> <a4j:support action="#{hostapp.hostChanged}" event="onchange" reRender="applist" limitToList="true" ajaxSingle="true" requestDelay="20"/> <f:selectItems value="#{appManager.hostList}"/> </h:selectOneMenu> Application <h:selectOneMenu id="applist" value="#{hostapp.id}"> <f:selectItems value="#{appManager.appList}"/> </h:selectOneMenu> </h:panelGrid> <br/> <h:commandButton action="#{login.login}" value="Login"/> </h:form>
It doesn't seem to work. I got the following exception when hitting the page home.jsf:
java.lang.IllegalArgumentException: Value binding '#{appManager.hostList}'of UISelectItems with component-path {Component-Path : [Class: org.ajax4jsf.framework.ajax.AjaxViewRoot,ViewId: /home.xhtml][Class: javax.faces.component.html.HtmlForm,Id: _id2][Class: javax.faces.component.html.HtmlPanelGrid,Id: _id4][Class: javax.faces.component.html.HtmlSelectOneMenu,Id: _id10][Class: javax.faces.component.UISelectItems,Id: _id12]} does not reference an Object of type SelectItem, SelectItem[], Collection or Map but of type : null at org.apache.myfaces.shared_impl.util.SelectItemsIterator.hasNext(SelectItemsIterator.java:144) at org.apache.myfaces.shared_impl.renderkit.RendererUtils.internalGetSelectItemList(RendererUtils.java:414) at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getSelectItemList(RendererUtils.java:392)
Can any of you let me know what I did wrong?
Sorry, I am still trying to get familiar with Seam concepts and might have missed something.
Thanks a lot.