开发者

h:inputHidden within ui:repeat

I'm creating an h:form within a cycle, and I'd like each form to have a hidden input with the value taken from the cycle's variable. Like so:

<ui:repeat value="#{controller.elements}" var="element开发者_开发百科">
    <h:form>
        <h:inputHidden value="#{element.value}"/> <!-- Taken from element.value, but submitted to controller.myvalue -->
        <h:commandLink action="#{controller.myaction}"/>
    </h:form>
</ui:repeat>

Question is, how do I supply the input's value from one source, for example, from #{element.value}, but when submitted, I'd like it be set to #{controller.myvalue}?

Apparently the value attribute specifies both the source and the destination. I tried to do something like this:

        <ui:param name="#{controller.myvalue}" value="#{element.value}"/>
        <h:inputHidden value="#{controller.myvalue}"/>

Which didn't work. It must be a known issue, but I couldn't find a solution.

Thanks for help, Yuri.


Use f:setPropertyActionListener.

<ui:repeat value="#{controller.elements}" var="element">
    <h:form>
        <h:commandLink action="#{controller.myaction}">
            <f:setPropertyActionListener target="#{controller.value}" value="#{element.value}" />
        </h:commandLink>
    </h:form>
</ui:repeat>

This will do controller.setValue(element.getValue()) before controller.myaction().

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜