2

I have found a lot of information on how to use ui:include and now would like to use it. I have several controls on multiple pages that do the exact same thing but the models (values, etc.) on each are slightly different. Is there a way to dynamically assign, maybe via a property on the backing bean, the value to a control?

For example:

<h:form id="formQInfo1">
   <h:outputText escape="false" value="#{surveyFormController.selectedQuestionResponse.questionInfo1.response}"/>
</h:form>

Now I want to send the selectedQuestionResponse from the backing bean of the parent xhtml page and assign it to the included xhtml page. Or better yet, can I make the actual value call different backing beans dynamically?

And if I am going in the wrong direction and there is a better way to do this, I would love to hear about it!

Thanks!

Eva Donaldson
  • 385
  • 4
  • 18

1 Answers1

1

The concrete functional requirement is not exactly clear, but the way how you stated the question leans to this answer:

<ui:include src="/WEB-INF/some.xhtml">
    <ui:param name="selected" value="#{surveyFormController.selectedQuestionResponse}" />
</ui:include>

Which can then in /WEB-INF/some.xhtml be accessed as follows:

#{selected.questionInfo1.response}

To get some steps further, you may want to look at tag files and/or composite components. This allows passing (action)listener methods and even converters/validators.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • The ui:param part is what I needed. I actually had read the thread you link to here. It did not address this param issue. Somehow no matter what I typed into Google I was not getting this "ui:param" piece. Thank you! – Eva Donaldson Oct 22 '12 at 11:36