开发者

noSelectionLabel in jsf?

There are m开发者_StackOverflow社区any situations when we want to tell the user to select an option from a selectOneMenu component. In Seam this is easily solved using noSelectionLabel.

<h:selectOneMenu value="#{seasonHome.id}">
        <s:selectItems value="#{seasonListQuery.resultList}"
                       var="season"
                       label="xxxSeason #{season.startYear}"
                       noSelectionLabel="Select Season"
                       hideNoSelectionLabel="true" />
        <s:convertEntity /> 
</h:selectOneMenu>

Can you please tell me if there is something similar in JSF 1.2?

I'm using icefaces with a list for selectItems like:

<ice:selectOneMenu
            id="#{id}"
            required="#{required}"
            styleClass="#{styleClass} #{not required ? 'graNotRequired':''}"
            style="width: #{width};font-size: #{fontSize};"
            partialSubmit="#{partialSubmit}"
            disabled="#{disabled}"
            value="#{fieldOneDataHolder[fieldTwo]}">
            <f:selectItems value="#{selectableItems}" />
            <f:validator validatorId="#{validatorId}" />
        </ice:selectOneMenu>

(please ignore parameters, this is a custom component I made).

I can introduce a new <f:selectItem itemLabel="Please select" itemValue=""/> above f:selectItems but this is difficult (I have to find a way to hide it in some cases etc)...

Do you know other work-around?

Thanks.


<f:selectItem itemLabel="Please select" itemValue="" itemDisabled="true" rendered="#{isShown}" />

The itemDisabled will make it shown but not selectable.

The boolean in rendered will decide whether the item is shown or not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜