MyFaces Features

Saving the full tree and model state information in the client response

Traditional JSP Applications save their state information within HttpSession objects. This is an easy to use but poor approach: MyFaces has a different approach. It makes it possible to write sophisticated applications without any use of the HttpSession. All state information of the jsf tree and (optionally the model beans) can be encoded to the client response in the form of query parameters and hidden inputs in forms.

Support for saving model state

MyFaces introduces a new Component "UISaveState" with the corresponding Tag "<myfaces_ext:save_state>".
Example (see "sample1.jsp"):
    ...
    <jsp:useBean id="calcForm"
                 class="net.sourceforge.myfaces.examples.example1.CalcForm"
                 scope="request" />
    ...
    <f:use_faces>
        ...
        <x:save_state id="save1" modelReference="calcForm.number1" />
        <x:save_state id="save2" modelReference="calcForm.number2" />
        <x:save_state id="save3" modelReference="calcForm.result" />
        ...
The current values of the three properties number1, number2 and result get automatically saved within the client response and restored from the following client request.

You can also save the whole bean.
Example:


    ...
    <jsp:useBean id="calcForm"
                 class="net.sourceforge.myfaces.examples.example1.CalcForm"
                 scope="request" />
    ...
    <f:use_faces>
        ...
        <x:save_state id="save1" modelReference="calcForm" />
        ...
The whole bean automatically is saved (serialized) and restored by MyFaces.

Keep in mind that to be able to save and restore the value of a bean property or the bean itself, it must either be serializable or have a type that is supported by a Converter (see package myfaces/converter/map).

State Saving

MyFaces offers 4 different state saving features:
  1. "server_session"
    Tree state is saved in a HTTPSession comparable to Sun's default saving with saveStateInClient = false. This mode is for all people that can live with HTTPSessions. We are tolerant and do not want to discriminate anybody. ;-)
  2. "client_serialized"
    Tree is serialized, zipped and saved as url parameter or hidden input (comparable to Sun's saving with saveStateInClient = true but additionally zips the parameter and has also support for url parameters) This mode is mainly meant as a proof of concept.
  3. "client_minimized"
    Only those (dynamical) tree and component infos are saved, that could not otherwise be restored by parsing the JSP. MyFaces' main feature as we know it. Parameters are saved in "plaintext", so convenient for debugging purposes.
  4. "client_minimized_zipped"
    Like "client_minimal", but additionally state info is zipped (GZIP), encoded to allowed characters (Base64) and written as one query parameter or hidden form input. Meant for production environments, where high HTTP traffic "costs" more than zipping und unzipping. i.e. When running a fast server together with thin clients connected over Internet (and not LAN).

ServletMapping

MyFaces supports two methods of mapping requests to the FacesServlet:

UINavigation / NavigationRenderer (navigation and navigation_item tags)

A simple navigation component to build a vertical menu structure.
(see web\example\inc\navigation.jsp for an example)

UISortHeader / SortColumnRenderer (sortheader and sortcolumn tags)

Convenient support for writing lists, that can be (re)sorted by a click on a column header. (see web\example\simpleSortList.jsp for an example)

LayoutRenderer (page_layout, page_header, page_body and page_footer tags)

Support for switchable page layout. Try the example and change the layout under "Options" to see the magic!

ListRenderer supports nested HTML and JSP

MyFaces ListRenderer does not render it's children, but rather lets child components and embedded HTML or JSP code the chance to render. This is achieved by our magic CallbackRenderer support. (see list examples)

UIFileUpload

Convenient component for uploading files to web applications.