0

I'm in a situation, where I need to pass a variable to some dialog(in custom tag component), the field with the value should be editable, but the dialog shouldn't be able to modify the original value in the managed bean.

This is how I call the component:

<my:aerodromeSelection value="#{fpl.adepIcaoId}" id2="adep"/>

This is fragment of the composite component(only relevant parts included):

<composite:interface>
<composite:attribute name="id2" required="true"/>
<composite:attribute name="value" required="true"/>
</composite:interface>


<composite:implementation>
<p:panelGrid>
     <p:commandButton icon="ui-icon-search" update="#{cc.attrs.id2}_dialog" oncomplete="#{cc.attrs.id2}_dialogAerodrome.show()"/>
</p:panelGrid>


<p:dialog widgetVar="#{cc.attrs.id2}_dialogAerodrome" dynamic="true">
    <p:panelGrid>
        <p:inputText value="#{cc.attrs.value.icaoCode}"/>
    </p:panelGrid>
</p:dialog>
</composite:implementation>

After clicking the button, the dialog is shown and I can edit the value. The problem is, that I don't want the value to be set to the original variable. I tried setting the value to the managed bean of the custom component and use those values instead, but if I do it like this, then having multiple dialogs in one page, I always get the value of the last one:

<c:set value="#{cc.attrs.value.icaoCode}" target="#{adSearchBB}" property="icaoCode"/>

So I need to solve one of two problems:

  • Why is the value in the adSearchBB(RequestScoped, but I've also tried ViewScoped) shared among all dialogs
  • How to "unbind" the variable passed to custom component

Also, what should be the scope of the managed bean? I'd ideally want one bean per component.

I'm using

  • Primefaces 3.5
  • Apache MyFaces 2.1.10
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
NeplatnyUdaj
  • 6,052
  • 6
  • 43
  • 76
  • 1
    *"I'd ideally want one bean per component."* You need a backing component. – BalusC Sep 23 '13 at 11:51
  • You should copy the edited bean before running edit dialog, and if the save is allowed, copy the new values back to the original bean. – Danubian Sailor Sep 23 '13 at 11:58
  • Lukasz-lech: But how do I do that? I ideally don't want to force users of my component to do some additional work. I'm trying to do that via c:set to another managed bean, but that doesn't work as expected. – NeplatnyUdaj Sep 23 '13 at 12:02

0 Answers0