0

There is one dropdown and one button. After selecting any item and clicking on button I have to display the selected item in the confirmation dialog, how to achieve this. I am using jsf and prime faces. Below is my sample code:

For dropdown:

<p:selectOneMenu
value="#{decRm.fi_templType}" styleClass="combobox"
id="temptypID" style="Width:30%" filter="true" onchange="selectedinput()">
<f:selectItem itemLabel="--#{lang.select}--" disabled="# 
{decRm.disableTemplate}"
itemValue="--Select--" />
<f:selectItems value="#{decRm.templtList}"></f:selectItems>
</p:selectOneMenu>

For dialog box:

<p:commandButton  value="#{lang.gen_temp}"> 
<p:confirm header="Confirmation!" message="#{temptypID}" ></p:confirm>
</p:commandButton>

<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
<p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" onclick="generateTemplate('FI')" />
<p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
</p:confirmDialog>

Below is the front end screenshot. Suppose I selected T1 from list, I want to display T1 in the confirmation box.

enter image description here

enter image description here

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Md Kamran Azam
  • 129
  • 2
  • 17

1 Answers1

0

Supposing that your decRm managed bean is @ViewScoped, it should be enough just to ajaxify your p:selectOneMenu to set the value in the bean each time the selection is changed:

<p:selectOneMenu
  value="#{decRm.fi_templType}" styleClass="combobox"
  id="temptypID" style="Width:30%" filter="true" onchange="selectedinput()">
    <f:selectItem itemLabel="--#{lang.select}--" disabled="#{decRm.disableTemplate}"
      itemValue="--Select--" />
    <f:selectItems value="#{decRm.templtList}"></f:selectItems>
    <p:ajax update="my Dialog" />
</p:selectOneMenu>

Then you only need to refer #{decRm.fi_templType} in your confirm dialog.

See also:

Aritz
  • 30,971
  • 16
  • 136
  • 217
  • But you might need to update the confirmDialog from the `p:ajax`? I'm thinking of trying to add something to the `p:confirm` dialog that makes it lazy so it 'updates' its content right before opening... – Kukeltje Sep 14 '18 at 12:14
  • @Kukeltje sure, this way involves having to update the dialog when ajax gets executed. It also could be done the way you state. – Aritz Sep 14 '18 at 13:53