i have a JSF/Seam Page and added a new not HTML Interface. I reused the business logic, so StatusMessages.instance().add is used everywhere.
Is there a default way to access and handle this StatusMessages from Java or do i have to extend the base class and pass the protected messages list?
thx
Edit:
StatusMessages.instance().add(Severity.ERROR, "Please enter a username.");
The FacesMessages is not returning his own messages List (where i saw the entry in the debugger) (FacesMessages.instance() is the same object as StatusMessages.instance() )
FacesMessage开发者_如何学Gos.instance().getCurrentMessages();
It is calling this
FacesContext.getCurrentInstance().getMessages();
and this is returning an empty iterator.
StatusMessages
is abstraction for handing messages in a way that is not dependent on the view technology you are using.
Default implementation of this abstraction is org.jboss.seam.faces.FacesMessages
. This is included in Seam for use with JSF.
If are reusing you business logic with another view technology you could provide your specific StatusMessages
implementation. Actually, that's why this is an abstraction.
@Scope(ScopeType.CONVERSATION)
@Name(StatusMessages.COMPONENT_NAME)
@Install(precedence=APPLICATION)
@BypassInterceptors
public class NonHtmlMessages extends StatusMessages
{
/// implement here you message handling
Because of @Install
precedence this will automatically be used in all StatusMessages.instance()
.
精彩评论