Formatted Messages

I am first developer in CAF I want to use the Formatted Messages compoment to display custom message can some tell how to that or send me a custom code to display the message via a command button.

I am using webMethods 7.12

You can create a java method that creates a new FacesMessage (http://download.oracle.com/docs/cd/E17802_01/j2ee/j2ee/javaserverfaces/1.1_01/docs/api/javax/faces/application/FacesMessage.html#FacesMessage(java.lang.String,%20java.lang.String))

and add that message to the faces context (http://download.oracle.com/docs/cd/E17802_01/j2ee/j2ee/javaserverfaces/1.2/docs/api/javax/faces/context/FacesContext.html#addMessage(java.lang.String,%20javax.faces.application.FacesMessage))

like this:

	public void addMessage() {
		getFacesContext().addMessage(null, 
				new FacesMessage("Test message", "Message details"));
		
	}

In the UI editor, you can drag the addMessage function onto the canvas which will create an asyncCommandButton.

Hi Luis,

Not sure what you scenario is but here’s one…

I want to select some rows of products that’s displayed in a view and take some key information over to another view or to another async table in the same view for example…see the getFacesContext in use.

  1. Add an action to your page bean - I called it addNewProducts
  2. Open the page source and update the following logic -

public String addNewProducts() {
String productid = null;
try {
productid = this.getCreateNewProduct().getParameters().getCreateNewProduct().getPRODUCTID();
this.getCreateNewProduct().refresh();
getFacesContext().addMessage(null, new FacesMessage("New Products added with productid: " + productid));
} catch (Exception e) {
getFacesContext().addMessage(null, new FacesMessage(e.getLocalizedMessage()));
}
return OUTCOME_OK;
}

Obviously,

  1. you will have to import javax.faces.application.FacesMessage;
  2. you must have your web service CreateNewProduct with it’s necessary parameters

Hope this helps
Vikash