我的代码如下所示:
<h:form>
<h:inputTextarea value="#{spintax.content}" cols="30" rows="10" />
<h:commandButton value="Submit" action="spinned" />
</h:form>
它需要一些内容,更改它并在spinned.xhtml页面上作为outputText给出响应。我也想这样做,但是我需要它保持在同一页面并输出为Textarea(而不是outputText)。输出textarea应该在inputTextarea下。可能吗 ?因此,您在文本区域放置了一些内容,并在其下的相同文本区域获得响应。
答案 0 :(得分:1)
是的,有可能。有几种方法可以实现它。我将展示两个:
<h:inputTextarea>
之外的<h:form>
:
<h:form>
<h:inputTextarea value="#{spintax.content}" cols="30" rows="10" />
<h:commandButton value="Submit" action="spinned" />
</h:form>
<h:inputTextarea value="#{spintax.output}" cols="30" rows="10" />
使用托管bean处理数据和ajax:
Facelets代码:
<h:form>
<h:inputTextarea id="itaContent" value="#{spintax.content}" cols="30" rows="10" />
<h:commandButton value="Submit" action="#{spintax.process}">
<f:ajax render="itaOutput" execute="itaContent" />
</h:commandButton>
<h:inputTextArea id="itaOutput" value="#{spintax.content}" />
</h:form>
托管bean代码:
@ViewScoped
@ManagedBean
public class Spintax {
private String content;
//proper getter/setter
public void process() {
//process the content if needed...
//otherwise, do nothing
}
}