• Post Reply Bookmark Topic Watch Topic
  • New Topic

commandButton inside messages

 
Christian Aarthun
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Is there a way to add a h:commandButton or h:commandLink to h:messages or can one just add normal text/html?
This is what I have tried to do:

StringBuffer sb = new StringBuffer();
sb.append("<");
sb.append("h:commandLink id=");
sb.append("\"");
sb.append("myLink");
sb.append("\"");
sb.append(" ");
sb.append("action=");
sb.append("\"");
sb.append("myPage.xhtml");
sb.append("\"");
sb.append(" ");
sb.append("value=");
sb.append("\"");
sb.append("ClickMe");
sb.append("\"");
sb.append("/");
sb.append(">");
FacesContext.getCurrentInstance().addMessage("form:", new FacesMessage(FacesMessage.SEVERITY_ERROR, sb.toString(), sb.toString()));

When the h:messages gets rendered it does not display any link even though there is som extra space inside the messages that was not there when I did not try to add the commandLink. Firebug also shows that there is a new <li> element with the link inside it, but it says commandlink with a small L.

Any thoughts?
 
Tim Holloway
Bartender
Posts: 18408
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The messages in FacesMessage objects have to be exactly what their name says they are. Messages. Text. No HTML or other markup. Layout of the message display is controlled by the h:messages element (table or list view option). Formatting of the messages is controlled by CSS.

You do bring up an interesting point, although I tend to use tooltips on the affected controls for popup help myself - which has the side benefit that you don't have to make an error first.

Because JSF is an abstract view framework, low-level directives such as raw HTML are only supported for a very small number of cases. And some of them are used more often than they should be.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!