junior developper
junior developper

Reputation: 448

display an input's value in dialog

I would like to display in a dialog the number inserted in the inputText.

<p:inputText id="nbr"
             type="number" 
             value="#{MB.number}" 
             required="true" 
             label="nbr" />
<p:confirmDialog id="confirmPurchase" 
                 message="Your Database was successfully created. And contains "
                 appendToBody="true" 
                 header="Buy Emails List" 
                 severity="info" 
                 widgetVar="purchase">  
    <a class="boldtext">  
       #{MB.number} 
       <h5> datas</h5> 
    </a>
    <p:commandButton id="confirm" value="Buy"  actionListener="#{MB.buy())}" />  
    <p:commandButton id="decline" 
                     value="Decline" 
                     onclick="purchase.hide();" 
                     type="button" />  
</p:confirmDialog> 

The code below returns always 0 as a number in the confirm dialog.

Update1

the dialog is showing once the action in the commandButton is completed

  <p:commandButton value="Extract" update="table nbr" id="ajax" ajax="true" widgetVar="extractButton action="#{MB.search()}" oncomplete="purchase.show();"/>  

Upvotes: 0

Views: 1000

Answers (1)

VulfCompressor
VulfCompressor

Reputation: 1410

First of all, you need a <h:form/> around your <p:inputText> and your <p:commandButton>.

Your <p:commandButton> should have the attribute update=":outputUserText".

Inside your Dialog, you need a <p:outputLabel id="outputUserText" value="#{MB.number}"

Upvotes: 1

Related Questions