سؤال

What I would like is something like following:


<f:verbatim>
<%
out.println("<span id='test'>Data</span>");
%>
</f:verbatim>

I would like the out.println code to be rerun by ajax. However, when I set that form to dirty, the out.println is not rerun.

Is there a way around this, short of using a custom tag?

What I need is a tag, like


<f:writeAsHTML value="#{bean.HTMLproducer}"/>

Is there already a tag like that in myfaces or basic JSF?

هل كانت مفيدة؟

المحلول

Just put it in f:verbatim without that scriptlet

<f:verbatim>
    <span id="test">Data</span>
</f:verbatim>

Or just print it plain (only possible on JSF 1.2 or newer)

<span id="test">Data</span>

Or use h:outputText since it renders a <span> anyway

<h:outputText id="test" value="Data" />

Or use h:outputText escape="false" if the HTML comes from a bean property

<h:outputText value="#{bean.html}" escape="false" />

As per your functional requirement which reads like

I would like the out.println code to be rerun by ajax

The problem needs to be solved elsewhere. Are you using JSF 1.x or 2.x? Regardless, you should utilize JSF-provided Ajax components like RichFaces' Ajax4jsf components or JSF 2.0's <f:ajax> components which offers a render attribute to trigger re-rendering of JSF components.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top