Hi Andrew, so this does the same as c:choose (sorry for my ignorance, but I don't know the JSTL too well)?
Can you give us an example where this is useful in the wild? regards, Martin On 6/15/07, Andrew Robinson <[EMAIL PROTECTED]> wrote:
I am working on the code for a very simple component, but wanted to see if there is feedback before finishing it up. The component is inspired by the JSTL choose but is geared for JSF and is more robust. I thought this would be helpful when a lot of facelets developers complain about the facelets implementation of choose due to render vs. compile time evaluation. <s:choose type="string" value="object" /> type := index|count (default: count) value := (type == index): list of numbers that correspond to children indexes (negatives allowed). Default: render all (type == count): integer representing max number of components to render. Default: render first Examples: <s:choose> <h:outputText rendered="false" value="a" /> <h:outputText value="b" /> <h:outputText value="c" /> </s:choose> Renders: b <s:choose value="2"> <h:outputText rendered="false" value="a" /> <h:outputText value="b" /> <h:outputText value="c" /> <h:outputText value="d" /> </s:choose> Renders: b c <s:choose value="5"> <h:outputText rendered="false" value="a" /> <h:outputText value="b" /> <h:outputText value="c" /> <h:outputText value="d" /> </s:choose> Renders: b c d <s:choose type="index" value="0,-1"> <h:outputText value="a" /> <h:outputText value="b" /> <h:outputText value="c" /> <h:outputText value="d" /> </s:choose> Renders: a d <s:choose type="index" value="0,-1"> <h:outputText value="a" /> <h:outputText value="b" /> <h:outputText value="c" /> <h:outputText value="d" /> </s:choose> Renders: a d <s:choose type="index" value="5"> <h:outputText value="a" /> <h:outputText value="b" /> <h:outputText value="c" /> <h:outputText value="d" /> </s:choose> Throws index out of bounds exception If index, value can be tied to one of: Collection of Number or Object int[] Object[] of Number or Object String or Object (comma-separated toString()) If Object and not a Number, Integer.parseInt(obj.toString()) is used. The default setting is really the most useful (type=count, value=1), which is simply render only the first child component that isRendered() returns true. Any feedback? -Andrew
-- http://www.irian.at Your JSF powerhouse - JSF Consulting, Development and Courses in English and German Professional Support for Apache MyFaces
