This content has been marked as final.
Show 4 replies
-
1. Re: Is it a bug?
sergeysmirnov Mar 18, 2008 5:23 PM (in response to mailcl)rich:dataTable as well as any other dataTable in JSF does not support Set directly as soon as Set does not guaranty the order of the elements.
You need to write you own dataModel -
-
3. Re: Is it a bug?
fabmars Mar 19, 2008 6:46 AM (in response to mailcl)Common issue in the JSF world. Here is some resolver I made (it's based on some JSF 1.1 code I found using Google, but here uses EL / JSF 1.2 compliant code)
package what.you.want; import java.beans.FeatureDescriptor; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import javax.el.ELContext; import javax.el.ELResolver; import javax.el.PropertyNotWritableException; public class ToListResolver extends ELResolver { private static String resolverWord = "toList"; @Override public Class<?> getCommonPropertyType(ELContext context, Object base) { if (base != null && base instanceof Collection) { return Collection.class; } return null; } @Override public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) { return null; } @Override public Class<?> getType(ELContext context, Object base, Object property) { if (base != null && base instanceof Collection) { if(resolverWord.equals(property)) { context.setPropertyResolved(true); return List.class; } } return null; } @Override public Object getValue(ELContext context, Object base, Object property) { if (base != null && base instanceof Collection) { if(resolverWord.equals(property)) { context.setPropertyResolved(true); return new ArrayList<Object>((Collection<?>)base); } } return null; } @Override public boolean isReadOnly(ELContext context, Object base, Object property) { if (base != null && base instanceof Collection) { if(resolverWord.equals(property)) { context.setPropertyResolved(true); return true; } } return true; } @Override public void setValue(ELContext context, Object base, Object property, Object value) { if (base != null && base instanceof Collection) { if(resolverWord.equals(property)) { context.setPropertyResolved(true); throw new PropertyNotWritableException(); } } } }
Register it in your faces-config with:<application> <el-resolver>what.you.want.ToListResolver</el-resolver> </application>
-
4. Re: Is it a bug?
fabmars Mar 19, 2008 6:47 AM (in response to mailcl)...and you can write in your jsf pages:
<rich:dataTable var="ro" value="#{selectedGroup.roles.toList}">