简体   繁体   English

将内容导入jsf h:inputTextarea

[英]importing content into jsf h:inputTextarea

We are currently converting a Spring mvc/jsp app into a jsf app. 我们目前正在将Spring mvc / jsp应用程序转换为jsf应用程序。

Previously we could import the content of a JSP segment file into a text area like this 以前,我们可以将JSP段文件的内容导入这样的文本区域

<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. 神奇的是,jsp的内容出现在了文本区域的内容中。

We are trying to do the same with JSF, but I am about ready to shoot myself in the face. 我们正在尝试对JSF进行同样的操作,但是我准备面对自己开枪。

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的value参数包含在内,但是编译器将其语法,引号/尖括号等弄得一团糟。

<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. 我宁愿直接将内容包括在jsf页面中,也不愿将其加载到支持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? 任何人都有任何想法可以用jsf来完成(对于任何愚蠢的人,我都是JSF newb表示歉意?

Just put the <h:inputTextarea id="sectionSixPointOne"> with it's value to include in the file you want to include. 只需将<h:inputTextarea id="sectionSixPointOne">放入要包含在文件中的值即可。
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": 并在section_six_sect_one.xhtml中:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM