tags:

views:

25

answers:

1

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.

+1  A: 

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().

BalusC
Thanks, what I needed.
Yuri Ushakov