0

Inside a primefaces overlayPanel I am asking a user for a value, which will be reused directly afterwards. So I don't want to save it in a backing bean.

Here's the code:

<p:overlayPanel id="ovlpanel" for="copy" hideEffect="fade" style="width:300px">
    <h:form>
        <p:panel id="grid" header="#{msg.copy_item}">
            <h:panelGrid columns="2" cellpadding="5"
                styleClass="ui-panelgrid-blank">
                <p:outputLabel value="#{msg.number_of_copies}: " for="number_of_copies" />
                    <p:column>
                        <p:inputText id="number_of_copies"
                        value="tempValNumberOfCopies" />
                    </p:column>
            </h:panelGrid>
            <p:commandButton
            action="#{controller.copyItem(tempValNumberOfCopies)}"
            value="#{msg.copy}" />
        </p:panel>
    </h:form>
</p:overlayPanel>

I want to save the value for tempValNumberOfCopies inside a temporary variable and use it in the action of the button.

Do you maybe have any ideas how to implement that?

John
  • 795
  • 3
  • 15
  • 38

1 Answers1

1

You could use the implicit scopes, e.g.

<p:inputText id="number_of_copies"
             value="requestScope.tempValNumberOfCopies" />
<p:commandButton action="#{controller.copyItem(requestScope.tempValNumberOfCopies)}"
                 value="#{msg.copy}" />

or

<p:inputText id="number_of_copies"
             value="viewScope.tempValNumberOfCopies" />
<p:commandButton action="#{controller.copyItem(viewScope.tempValNumberOfCopies)}"
                 value="#{msg.copy}" />
Smutje
  • 17,733
  • 4
  • 24
  • 41