Skip to main content

h:dataTable with java.util.Set

3 replies [Last post]
alexander_bell
Offline
Joined: 2009-12-24

Hi,

I wanna use the h:dataTable with a java.util.Set as list value like this:

Bean:

@ManagedBean
@RequestScoped
public class MyBean {
private Set myDomains;
public MyBean() {
myDomains = new LinkedHashSet();
myDomains.add(new MyDomain("1", "eins"));
myDomains.add(new MyDomain("2", "zwei"));
myDomains.add(new MyDomain("3", "drei"));
myDomains.add(new MyDomain("4", "vier"));
}
public Set getMyDomains() {
return myDomains;
}
public void setMyDomains(Set myDomains) {
this.myDomains = myDomains;
}
}

h:dataTable

I get the following exception:
javax.el.PropertyNotFoundException: /index.xhtml @11,37 value="#{i.key}": Property 'key' not found on type java.util.LinkedHashSet
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:104)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178)
at javax.faces.component.UIOutput.getValue(UIOutput.java:168)

BTW with java.util.List everything works fine!

Any ideas?
Is that a bug (IMO it must be ;-))

Alex

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Ryan Lubke

I would recommend reviewing the javadocs for UIData.getValue().

You will need to provide a custom DataModel implementation for Sets.

On 12/25/2009 2:10 AM, webtier@javadesktop.org wrote:
> Hi,
>
> I wanna use the h:dataTable with a java.util.Set as list value like this:
>
> Bean:
>
> @ManagedBean
> @RequestScoped
> public class MyBean {
> private Set myDomains;
> public MyBean() {
> myDomains = new LinkedHashSet();
> myDomains.add(new MyDomain("1", "eins"));
> myDomains.add(new MyDomain("2", "zwei"));
> myDomains.add(new MyDomain("3", "drei"));
> myDomains.add(new MyDomain("4", "vier"));
> }
> public Set getMyDomains() {
> return myDomains;
> }
> public void setMyDomains(Set myDomains) {
> this.myDomains = myDomains;
> }
> }
>
> h:dataTable
>
>
>
>
>

>
>
>

>

>
>
> I get the following exception:
> javax.el.PropertyNotFoundException: /index.xhtml @11,37 value="#{i.key}": Property 'key' not found on type java.util.LinkedHashSet
> at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:104)
> at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190)
> at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178)
> at javax.faces.component.UIOutput.getValue(UIOutput.java:168)
>
> BTW with java.util.List everything works fine!
>
> Any ideas?
> Is that a bug (IMO it must be ;-))
>
> Alex
> [Message sent by forum member 'alexander_bell' (Alexander.Bell@j4fry.org)]
>
> http://forums.java.net/jive/thread.jspa?messageID=377473
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

alexander_bell
Offline
Joined: 2009-12-24

thanks ryan, I'm gonna write my own custom dataModel

alex

Lincoln Baxter, III

Not a bug. It doesn't work with sets. Ui:repeat should, though.

The problem lies in datatable requiring a position, or index, so it can
determine the selected row.... file it as an enhancement on the spec issue
tracker (www.javaserverfaces.org ) . I think it's a poor limitation.

Lincoln

Lincoln Baxter III
http://ocpsoft.com
http://scrumshark.com
Keep it simple.

On Dec 25, 2009 5:10 AM, wrote:

Hi,

I wanna use the h:dataTable with a java.util.Set as list value like this:

Bean:

@ManagedBean
@RequestScoped
public class MyBean {
private Set myDomains;
public MyBean() {
myDomains = new LinkedHashSet();
myDomains.add(new MyDomain("1", "eins"));
myDomains.add(new MyDomain("2", "zwei"));
myDomains.add(new MyDomain("3", "drei"));
myDomains.add(new MyDomain("4", "vier"));
}
public Set getMyDomains() {
return myDomains;
}
public void setMyDomains(Set myDomains) {
this.myDomains = myDomains;
}
}

h:dataTable








I get the following exception:
javax.el.PropertyNotFoundException: /index.xhtml @11,37 value="#{i.key}":
Property 'key' not found on type java.util.LinkedHashSet
at
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:104)
at
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190)
at
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178)
at javax.faces.component.UIOutput.getValue(UIOutput.java:168)

BTW with java.util.List everything works fine!

Any ideas?
Is that a bug (IMO it must be ;-))

Alex
[Message sent by forum member 'alexander_bell' (Alexander.Bell@j4fry.org)]

http://forums.java.net/jive/thread.jspa?messageID=377473

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net
[att1.html]