How to reuse the old views in JSF

202 views Asked by At

I have concurrent view limit exceeded problem in icefaces. It supports not more than 50 views per one session. In the process of finding issue with the code, I have doubt regarding view reusability.

Consider the below cases.

Case 1:

Returning empty string would recreate a view though the user stays on the current page, as shown below.

 public String submit(){
          //...
          return "";
        }

Case 2:

But, below code would reuse the old view.

public String submit(){
      //...
      return null;
    }

Case 3:

I think, below code snippet would also do the same. Correct me here, if I am wrong.

public String submit() {
    // ...
    return "viewId?faces-redirect=true";
}

What is the difference between case 2 and case 3?

UPDATE:

I have tested an application with JSF 1.2, it allows all the 3 cases, as mentioned above.

enter image description here

In my bean I am using the following code

public String saveData() {
    //String returnString = "";//Case 1 : works - user stays on the same page
    //String returnString = null;//Case 2: works - user stays on the same page
    // Case 3:
    String viewId = FacesContext.getCurrentInstance().getViewRoot().getViewId();
    System.out.println("view id = "+ viewId);
    String returnString = viewId+"?faces-redirect=true";
    System.out.println("return string = "+ returnString);
    return returnString;
}

I have deployed the above application in jetty.In the above example, every time the method saveData() is called, the user stays on the same page with his filled in data in input fields, I infer from this that, its reusing the old page or view(I am not clear with a view in JSF). This is happening in all the 3 cases, so not sure of the exact difference, How to experience this difference? What is a view from JSF perspective?

0

There are 0 answers