• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to render html content that is produced by a backing bean ?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have a problem rendering html output produced by a backing bean.

Displaying it the simple way by

<f:verbatim>#{cms.html}</f:verbatim>

works, but if the content returned by getHtml() changes due to a click on a h:commandButton in a different part of the page, the output is still the same although the returned string is definitely different. It looks like the part between the f:verbatim-tags is somewhere cached and the backing bean is no more contacted to retrieve the correct content.

Br,
Markus
 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try orThen you can use whatever hooks your chosen framework gives you to re-render "myStuff" as needed.

I think that'll work - but I've not tried it myself.

J.
 
Markus Bauer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jason,

the first one would render the included tags escaped and make them look like &lt;b&gt; instead of <b>while the second one does not bring any change.

Currently i have it surrounded by a rich:panel - tag. I also already tried surrounding it with a f:subview, but that also did not bring any change.

Br,
Markus
 
Jason Irwin
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
D'oh! Of course.

Well, as you are using RichFaces, why not just have an AJAX event reRender the richPanel? You could use an <a4j: support ... /> element under the h:commandButton, or swap to using an a4j:commandButton with has in-built AJAX support.

Unless you are refreshing the entire form when the button is clicked, your panel will not re-render.

J.
 
Markus Bauer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jason,

i also tried without the surrounding rich:panel.

As I am using a "normal" h:commandButton, the complete page should refresh, shouldn't it ?
I also tried implicitly refreshing the panel by putting its ID into the reRender-Attribute of the commandButton, but the content between the f:verbatim still stays the same meaning:

the backingBeans get-Method is not even called...

 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Markus Bauer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:



Bingo! That's the solution.

Anyway - what if i don't just want to include "simple" HTML-Tags, but also jsf-tags or even richfaces-component tags ?

Is this at all possible or will i have to dynamically create a file and then include this file to be processed ?
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any non-HTML tags - custom JSP, JSTL, JSF, Facelets, whatever would not be processed, just passed on verbatimh as part of the HTML and the browser would typically ignore them, since that's the standard for tags that a browser doesn't understand.

To process custom tags, you'd need to set up the proper processing environment for the type of tag you wanted to process. The easiest way to do that would be to construct a separate internal page request, then present the HTML that came back from that request.

For the most part, that's too much trouble and delay. In the case of custom JSF/facelet stuff, it's easier and simpler just to construct the underlying objects and insert them into the JSF document tree.
 
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic