0

Consider this xhtml piece.

            <p:dialog id="consumerDialog"
                      widgetVar="dealerDialog" modal="true">
                <h:panelGroup binding="#{cdContent}">

                </h:panelGroup>
            </p:dialog>

            <p:dialog id="dealerDialog"
                      widgetVar="dealerDialog" modal="true">
                <h:form>
                    <p:commandButton value="Close"
                         onclick="PF('dealerDialog').hide()" 
                         update=":#{cdContent.clientId}"/>
                </h:form>

            </p:dialog>

In the dealerDialog component is a p:commandButton which updates the h:panelGroup component inside the consumerDialog where the id of the updated component is obtained through binding. I sometimes do this to save pains figuring out the actual id of the target component (especially for complex views).

Are there any downsides or risks if I do it this way?

FuryFart
  • 2,304
  • 4
  • 27
  • 43

1 Answers1

0

Are there any downsides or risks if I do it this way?

Only if the EL variable represented in binding, which is in your case #{cdContent}, is shared by multiple components in the same view. E.g. when the given code snippet is included multiple times in the same template via <ui:include>, tagfile or composite. Or even when there's a managed bean on that name. It doesn't apply in your case, but it would for sure fail if the binding attribtue references a session scoped bean property.

There are no risks if you make absolutely sure that #{cdContent} is exclusively used by only one component in the entire view.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I have a rather late question. Do you know what scope this variable will have? Like RequestScoped or ViewScoped. Not sure if it makes a difference though. – FuryFart Apr 21 '16 at 06:41
  • Technically Facelet scoped, but you can interpret it as request scoped. – BalusC Apr 21 '16 at 07:02