Andrew, I'm not an expert on c:choose, but from the one time I tried to use it, the syntax and functionality seemed quite different.
If there's going to be a sandbox:choose component, I would hope that it would be the render-time equivalent of the c:choose build-time tag. Since I don't think that's the case, I'd recommend using a different name for this component. Otherwise, it's going to cause a great deal of unnecessary confusion. How about "chooseRendered"? On 6/14/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
