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
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.
An IDE is no substitute for an Intelligent Developer.