I am confused with JSF life cycle.  some senarios:
 
Senario 1 -- Cancel
<h:form>
...

<h:commandLink id="cancel" action=""

value="#{bundle.Cancel}" immediate="true">

</h:form>

When the Cancel link is clicked, will "Update Model data" phase be skipped so the model data will not be changed?

(note that immediate = true)

The Sun's JSF doc(j2ee1.4 tutorial) says:

If some components on the page have their immediate attributes (see The immediate Attribute, page 701) set to true, then the validation, conversion, and events associated with these components will be processed during this phase.

It does not say the "Update Model date" phase will be skipped. However the model data did not get changed.(MyFaces example: Edit All Countries).

Senario 2 -- ActionEvent of commandLink

<h:form>

<x:dataTable id="data"

var="city"

value="#{backingBean.cityList}"

preserveDataModel="true"

rows="10"

>

...

<h:column>

<h:selectBooleanCheckbox value="#{city.selected}"

</h:column>

// some <h:inputText> here

<h:column>

<h:commandLink actionListener="#{backingBean.change}" value="Change" />

</h:column>

</x:dataTable>

<h:commandButton action="" value="Submit"/>

</h:form>

-------

BackingBean change() method:

  public void change(ActionEvent e) throws NamingException {

    UIComponent comp = e.getComponent();
        HtmlDataTable dataTable = (HtmlDataTable) comp.getParent().getParent();
    City city = (City)dataTable.getRowData();
    
    sessionBean.mergeCity(city);
   
  }

My questions are:

  1. ActionListener is invoked before "update model data" phase. does sessionBean.mergeCity(city) include new changes from pages?  but it works.
  2. Check all checkboxes, and then submit  the form. Inside the submit() method, going through the cityList, the "selected" attribute of all the cities are false. I expect them to true. what is going wrong?

Please help. Thank you. Have a nice day! Dave


Click here to donate to the Hurricane Katrina relief effort.

Reply via email to