myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joost Schouten" <jo...@jsportal.com>
Subject RE: Problem using Map to populate selectItems
Date Sun, 29 Apr 2007 03:24:07 GMT
Dear Mike,

Changing the return type of my backing variable to:

public Set getLoggedDropDownActionsEntrySet(){
	this.getLoggedDropDownActions().entrySet();
}

Solved the problem.

Thanks a lot,
Joost Schouten

-----Original Message-----
From: Mike Kienenberger [mailto:mkienenb@gmail.com] 
Sent: Sunday, April 29, 2007 2:50 AM
To: MyFaces Discussion
Subject: Re: Problem using Map to populate selectItems

Sorry,  I didn't notice you were using t:selectItems in the first part
of the message.

Here's the issue:

myBean.loggedDropDownActions.entrySet

would be resolved as

myBean.getLoggedDropDownActions().getEntrySet()
and not as
myBean.getLoggedDropDownActions().entrySet()

So your value list would be null/empty.

Not sure about clay, but facelets would allow you to define a static
function where you could get the entry set value....


#{myFunctions:entrySet(myBean.loggedDropDownActions)}

I suppose you could just define

public Map.Entry getLoggedDropDownActionsEntrySet()



On 4/28/07, Joost Schouten <joost@jsportal.com> wrote:
> Mike,
>
> Thanks. I guess I'll go for the t:selectItems then. But that doesn't
explain
> why t:selectItems produces an empty t:selectOneMenu. Do you have any idea
> why?
>
> Thanks,
> Joost Schouten
> -----Original Message-----
> From: Mike Kienenberger [mailto:mkienenb@gmail.com]
> Sent: Saturday, April 28, 2007 1:53 PM
> To: MyFaces Discussion
> Subject: Re: Problem using Map to populate selectItems
>
> You need to use t:selectItems.
>
> f: does not support var or value (at least, it's not supposed to).
>
> On 4/27/07, Joost Schouten <joost@jsportal.com> wrote:
> > Hi,
> >
> > I try to populate a selectItems with a Map from my backing bean (as
> > described at [1]) but have no success. When I use t:selectItems
> >
> > <t:selectOneMenu value="#{myBean.loggedAction}">
> >         <t:selectItems value="#{ myBean.loggedDropDownActions.entrySet}"
> > var="mapEntry" itemValue="#{mapEntry.key}" itemLabel="#{mapEntry.value}"
> />
> > </t:selectOneMenu>
> >
> > I end up with the dropdown on my page but not populated with any values.
A
> > check on the backend [2] does show there are keys and values set btw.
> >
> > When I use f:selectItems
> >
> > <t:selectOneMenu value="#{myBean.loggedAction}">
> >         <f:selectItems value="#{ myBean.loggedDropDownActions.entrySet}"
> > var="mapEntry" itemValue="#{mapEntry.key}" itemLabel="#{mapEntry.value}"
> />
> > </t:selectOneMenu>
> >
> > I get the following exception as shown below [3].
> >
> > Does anyone have any clues?
> > Thank you,
> > Joost
> >
> >
> > [1]: http://www.nabble.com/Using-t:selectItems-with-Map-t3480577.html
> > [2]:
> > public Map getLoggedDropDownActions()throws Exception{
> >         TreeMap mp = new TreeMap();
> >         ....loading of the values ...
> >         for(Iterator itr =
> >
>
this.getSessionVars().getLoggedDropDownActions().entrySet().iterator();itr.h
> > asNext();){
> >                 Map.Entry temp = (Map.Entry)itr.next();
> >                 log.debug("key: " + temp.getKey() + " | value: " +
> > temp.getValue());
> >         }
> >         return mp;
> > }
> >
> >
> > [3]:
> >
> > java.lang.IllegalArgumentException: Value binding
> > '#{user_dashboard.loggedDropDownActions.entrySet}'of UISelectItems with
> > component-path {Component-Path : [Class:
> > org.apache.shale.view.faces.ShaleViewRoot,ViewId:
> > /user_dashboard.jsf][Class: org.apache.shale.clay.component.Clay,Id:
> > clayView][Class: org.apache.shale.clay.component.Clay,Id:
> > loggedColumnPageLayout][Class:
> javax.faces.component.html.HtmlOutputText,Id:
> > _id0][Class: org.apache.shale.clay.component.Clay,Id: _id16][Class:
> > javax.faces.component.html.HtmlOutputText,Id: _id18][Class:
> > org.apache.shale.clay.component.Clay,Id: _id20][Class:
> > javax.faces.component.html.HtmlOutputText,Id: _id30][Class:
> > org.apache.myfaces.custom.form.HtmlForm,Id: _id32][Class:
> > org.apache.myfaces.custom.div.Div,Id: _id34][Class:
> > org.apache.myfaces.component.html.ext.HtmlSelectOneMenu,Id:
_id36][Class:
> > javax.faces.component.UISelectItems,Id: _id37]} does not reference an
> Object
> > of type SelectItem, SelectItem[], Collection or Map but of type : null
> >         at
> >
>
org.apache.myfaces.shared_tomahawk.util.SelectItemsIterator.hasNext(SelectIt
> > emsIterator.java:144)
> >         at
> >
>
org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.internalGetSelect
> > ItemList(RendererUtils.java:473)
> >         at
> >
>
org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.getSelectItemList
> > (RendererUtils.java:451)
> >         at
> >
>
org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils.internal
> > RenderSelect(HtmlRendererUtils.java:303)
> >         at
> >
>
org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils.renderMe
> > nu(HtmlRendererUtils.java:276)
> >         at
> >
>
org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlMenuRendererBase.encod
> > eEnd(HtmlMenuRendererBase.java:59)
> >         at
> >
>
org.apache.myfaces.renderkit.html.ext.HtmlMenuRenderer.encodeEnd(HtmlMenuRen
> > derer.java:60)
> >
> >
>
>
>



Mime
View raw message