importing content into jsf h:inputTextarea

341 views Asked by At

We are currently converting a Spring mvc/jsp app into a jsf app.

Previously we could import the content of a JSP segment file into a text area like this

<textarea id="sectionSixPointOne" name="sectionSixPointOne">
      <jsp:include page="sect_six_point_one.jspf"/>
</textarea> 

Magically the content of the jsp appeared into the content of the text area.

We are trying to do the same with JSF, but I am about ready to shoot myself in the face.

We've tried

<h:inputTextarea id="sectionSixPointOne">
  <ui:include src="section_six_sect_one.xhtml"/>     
</h:inputTextarea>

But it includes the content after the textarea not inside it.

I have tried to include the content of as the value parameter of h:inputTextarea but the compiler gets it's knickers in a knot about the syntax/quotes/anglebrackets etc.

<h:inputTextarea id="sectionSixPointOne" value=<ui:include src="section_six_sect_one.xhtml"/>     
</h:inputTextarea> 

I would much rather include the content directly in the jsf pages rather than mucking about loading it into a backing bean. Anyone got any ideas can what I want to do be done with jsf (apologies for any idiocy I am a total JSF newb?

1

There are 1 answers

1
Zhedar On

Just put the <h:inputTextarea id="sectionSixPointOne"> with it's value to include in the file you want to include.
That way you don't need to insert it in some component, you just extracted the whole thing into its own file.

So you code looks like:

<ui:include src="section_six_sect_one.xhtml"/> 

and in section_six_sect_one.xhtml":

<ui:composition xmlns=... >
    <h:inputTextarea id="sectionSixPointOne" value="yourIncludedText"/>
...