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) is 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.example.model.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.example.model.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 Methods

MyFaces supports two ways of saving client state information: MyFaces supports two methods of encoding the state information:

UINavigation

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

UIMessageList

A very simple component that prints all messages in a <ul> list.
(see web\example\sample1.jsp for an example)