Help

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

This is a simple example to illustrate how to populate a JSF main form from a rich:modalPanel action. The key is the reRendering of the main form and/or the form in the modalPanel, as required, and not reRendering too many UI components to improve performance. This is just a basic example so limiting regions using s:div, etc. will not be demonstrated. Remember that you can embed just about any RF/A4J component in a form in a modalPanel. I have embedded rich:dataTables in rich:modalPanels many times and those are the more common and more complicated scenarios, especially when you consider SMPC management.

For more info and examples, refer to Practical RichFaces by Max Katz as well as the RichFaces reference documentation.

.xhtml:

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:s="http://jboss.com/products/seam/taglib"
	template="/templates/normal.xhtml">
	
	<ui:define name="body">
	 
		<h:form id="form1">
			<h:outputText value="The value is null." 
						  rendered="#{testPopup.myString eq null}"/>
			<h:outputText value="The value is #{testPopup.myString}"			 			  
			              rendered="#{testPopup.myString ne null}"/>	
			<br/><br/>
			<h:outputLink value="#" id="link">
	        	Show modalPanel
		        <rich:componentControl for="modal1" attachTo="link" operation="show" event="onclick"/>
		    </h:outputLink>
		</h:form>
		
		<rich:modalPanel id="modal1" width="600" height="200">
	        <f:facet name="header">
	            <h:panelGroup>
	                <h:outputText value="Test Modal Panel"/>
	            </h:panelGroup>
	        </f:facet>
        	<h:form id="form2">
        		<h:commandButton value="set String value" action="#{testPopup.setMyString('foo')}" reRender="form1"/>
        	</h:form>	        
		</rich:modalPanel>
	
	</ui:define>
	
</ui:composition>

TestPopup JavaBean component:

@Name("testPopup")
@Scope(ScopeType.PAGE)
public class TestPopup implements Serializable {
	
	private String myString;
		
	public String getMyString() {
		return myString;
	}

	public void setMyString(String myString) {
		this.myString = myString;
	}

}