Ah - I got the idea. I worked out the following, and I think it would be
instructive to include it in myfaces example.
public String getColumnDataType() {
String columnDataType = null;
return getColumnValue().getClass().getName();
}
public boolean isBooleanValue() {
return getColumnDataType() == "java.lang.Boolean" ;
}
public boolean isStringValue() {
return getColumnDataType() == "java.lang.String" ;
}
Many thanks.
Regards,
Yee
-----Original Message-----
From: Mathias Brökelmann [mailto:[EMAIL PROTECTED]
Sent: Sunday, 6 November 2005 4:00 PM
To: MyFaces Discussion
Subject: Re: How to handle Boolean/Checkboxes in <t:columns>?
you can switch it by using the rendered attribute. Provide some is
methods for the datatype and check it through the rendered attribute.
Put them inside the t:columns component. You can nest them into
h:panelGroup if you have more than one component to render for a
specific datatype.
<h:selectBooleanCheckbox rendered="#{userRolesBean.booleanValue}"
value="#{userRolesBean.columnValue}"/>
<h:inputText rendered="#{userRolesBean.stringValue}"
value="#{userRolesBean.columnValue}"/>
2005/11/6, Yee CN <[EMAIL PROTECTED]>:
> Does that mean that all columns must be Boolean/Boolean? So there is no
way
> of mixing datatype in different columns?
>
> Regards
> Yee
>
> -----Original Message-----
> From: Mathias Brökelmann [mailto:[EMAIL PROTECTED]
> Sent: Sunday, 6 November 2005 1:05 AM
> To: MyFaces Discussion
> Subject: Re: How to handle Boolean/Checkboxes in <t:columns>?
>
> your userRolesBean.columnValue must return a boolean value. Either
> primitive, instance of java.lang.Boolean or null.
>
> 2005/11/5, Yee CN <[EMAIL PROTECTED]>:
> >
> >
> >
> > Hi,
> >
> >
> >
> > How should I handle boolean and checkboxes using <t:columns>?
> >
> >
> >
> > I am trying to do something like:
> >
> >
> >
> > <t:columns id="columns" value="#{userRolesBean.columnHeaders}"
> > var="columnHeader">
> >
> > <f:facet name="header">
> >
> >
> >
> > </f:facet>
> >
> > <h:selectBooleanCheckbox id="selboolean"
> > value="#{userRolesBean.columnValue}"/>
> >
> > </t:columns>
> >
> >
> >
> > But then I get the following exception:
> >
> > java.lang.IllegalArgumentException: Expected submitted
> > value of type Boolean for Component : {Component-Path : [Class:
> > javax.faces.component.UIViewRoot,ViewId:
> >
> >
> >
> >
> >
> > Thanks,
> >
> >
> >
> > Regards,
> >
> > Yee
>
>
> --
> Mathias
>
>
--
Mathias