myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johannes Ruthenberg ...@software-friends.de>
Subject Re: t:selectItems with a map
Date Sat, 14 Mar 2009 19:10:23 GMT
Hello!

Thanks for your reply!

Simon Kitching wrote on 14.03.2009 15:39:
>  Have you tried this? <t:selectItems value="#{myBean.allRoles}"/>

I have, but I get a NullPointerException if I do.

Caused by: java.lang.NullPointerException
    at org.apache.catalina.connector.Request.getAttribute(Request.java:877)
    at 
org.apache.catalina.connector.RequestFacade.getAttribute(RequestFacade.java:263)
    at 
javax.servlet.ServletRequestWrapper.getAttribute(ServletRequestWrapper.java:82)
    at 
org.apache.myfaces.context.servlet.RequestMap.getAttribute(RequestMap.java:47)
    at 
org.apache.myfaces.util.AbstractAttributeMap.put(AbstractAttributeMap.java:104)
    at 
org.apache.myfaces.util.AbstractAttributeMap.put(AbstractAttributeMap.java:38)
    at 
org.apache.myfaces.custom.selectitems.AbstractUISelectItems.putIteratorToRequestParam(AbstractUISelectItems.java:131)
    at 
org.apache.myfaces.custom.selectitems.AbstractUISelectItems.createSelectItems(AbstractUISelectItems.java:107)
    at 
org.apache.myfaces.custom.selectitems.AbstractUISelectItems.getValue(AbstractUISelectItems.java:75)
    at 
org.apache.myfaces.shared_impl.util.SelectItemsIterator.hasNext(SelectItemsIterator.java:128)
    at 
org.apache.myfaces.shared_impl.renderkit.RendererUtils.internalGetSelectItemList(RendererUtils.java:557)
    at 
org.apache.myfaces.shared_impl.renderkit.RendererUtils.getSelectItemList(RendererUtils.java:542)
    at 
org.apache.myfaces.shared_impl.renderkit.html.HtmlCheckboxRendererBase.renderCheckboxList(HtmlCheckboxRendererBase.java:117)
    at 
org.apache.myfaces.shared_impl.renderkit.html.HtmlCheckboxRendererBase.encodeEnd(HtmlCheckboxRendererBase.java:65)
    at 
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:624)
    ... 76 more

Looking at the actual implementation of the t:selectItems tag, I think 
this is consistent (it sets the current map value to the request under 
the provided variable name and then calls a method which retrieves this 
and tries to get the label and value for the select item -- this fails 
if no variable name is given). It just doesn't fit what the tag is 
supposed to do as per the documentation, at least as I understand it.

I could simply built the list of SelectItem instances myself and set 
this in my bean. But I actually wouldn't want to handle more of the 
internal UI elements than necessary, so if the tag could do this, I 
think that would be the better approach. I also wonder if the 
documentation is wrong here or the tag class (a matter of perspective, I 
guess). ;-)

Regards,
Johannes Ruthenberg

Mime
View raw message