This week's book giveaway is in the Python forum.
We're giving away four copies of Python Continuous Integration and Delivery and have Moritz Lenz on-line!
See this thread for details.
Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Create dynamic text in jsf  RSS feed

Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I know how to create dynamic text with facescontext.addMessage();
But i have to do that without facescontext. Can anyone show me the tricks ?
So in page B when i press a button, the text show up.
and when i go to page A( jsf page ) via commanlink  and go back to page B i should not see the text show up anymore. I need to press the button again to show up the text

Saloon Keeper
Posts: 20502
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not understand what you want.

The messages component of FacesContext is primarily for the benefit of JSF's built-in validation mechanism and other JSF internal uses. Each message can, in fact, attach itself to a particular form control, which means that you design pages either to present messages in a block or have each message proximate to the form control whose value was reported invalid. It's not a general-purpose text display system.

The FacesContext doesn't even exist except when the FacesServlet is in control for a request/response cycle. Pass to a JSP or non-JSF servlet, and FacesContext isn't available. Likewise the messages are associated with the current request and no other, since it's assumed that the user will be repairing whatever problem was reported and that the next response may well have an entirely new set of messages. Or none at all.

If you simply want a message, make it a property of a backing bean and use h:outputText to display it. You can also just code a raw EL expression if you don't want the message to be a JSF structured component (with styles, styleClasses, element ID, and the right to be considered as an independent element in a JSF tabular control.

And to ensure that your message doesn't promptly evaporate, make sure that the backing bean in question is not in request scope. Request scope is virtually useless in JSF, anyhow.
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!