jsf 2 - faces component content which contains jsf components is not evaluated -


created taghandler , added facelet. facelet content still not evaluated. html code contains ui:fragment text.

    @override     public void encodebegin(facescontext context) throws ioexception{     responsewriter writer = context.getresponsewriter();               content = benefits.getcontent(type);       writer.write(content);   }    <content type="short">     <data><![cdata[              <ui:fragment rendered="#{true}">         <a id="" href="a.xhtml>     </ui:fragment>     <ui:fragment rendered="{false}">         <a id="" href="b.xhtml">     </ui:fragment>     <img src="a.png"  alt="" />   </a>  ]]></data>    public class cardholderbenefitstaghandler extends taghandler {   private final tagattribute src;  public cardholderbenefitstaghandler(tagconfig config) {     super(config);     tagattribute attr = null;     attr = this.getattribute("src");                 this.src = attr;  }  public void apply(faceletcontext ctx, uicomponent parent)         throws ioexception {     string path = this.src.getvalue(ctx);      variablemapper orig = ctx.getvariablemapper();     ctx.setvariablemapper(new variablemapperwrapper(orig));     try {         this.nexthandler.apply(ctx, null);         ctx.includefacelet(parent, path);     } catch (ioexception e) {                    throw new tagattributeexception(this.tag, this.src,                 "invalid path : " + path);     } {         ctx.setvariablemapper(orig);     }  }  } 

you're making conceptual mistake. http response writer intented write html code, not write jsf code. webbrowser namely understands html, not jsf. regular jsf components , renderers write html code response writer. open normal jsf page in webbrowser , rightclick , view source. if jsf did job right, you'll see it's 1 , html, free of jsf code.

essentially, need create facelets taghandler instead of jsf ui component in order manipulate jsf component tree new jsf components based on xml source.

the answer following question contains hello world tag handler. must started: custom facelet component in jsf.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -