webtier@glassfish.java.net

JSF recalls datatable on POST

From: <webtier_at_javadesktop.org>
Date: Wed, 26 Aug 2009 06:05:43 PDT

Hi,

Here is the test codes:

This is my simple managed bean:

----------------------------------
public class Sample {

  public String getText() {
    System.out.println("this is text");
    return "this is text";
  }

  public String[] getData() {
    System.out.println("this is data");
    return new String[] {
      "deneme1",
      "deneme2"
    };
  }

  public String SampleAction() {
    return "sample";
  }
}
----------------------------------

This is web page:

----------------------------------
<%_at_page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>JSP Page</title>
  </head>
  <body>
    <h:dataTable var="d" border="1" value="#{sample.data}">
      <h:column>
        <h:outputText value="#{d}" />
      </h:column>
    </h:dataTable>
    <h:form>
      <h:outputText value="#{sample.text}" />
      <h:commandButton action="#{sample.SampleAction}" value="click" />
    </h:form>
  </body>
</html>
----------------------------------

and this is faces config:

----------------------------------
  <navigation-rule>
    <navigation-case>
      <from-outcome>sample</from-outcome>
      <to-view-id>sample.jsf</to-view-id>
    </navigation-case>
  </navigation-rule>

  <managed-bean>
    <managed-bean-name>sample</managed-bean-name>
    <managed-bean-class>Sample</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
  </managed-bean>
----------------------------------

When we call http://localhost:8080/index.jsf. The server output is:
this is text
this is data

Another word JSF calls datatable #{sample.data} and #{sample.text}.this normal.

But when we click the button. The Server output is:
this is data

is this a possible bug? How may i avoid of reloading datatable content.
[Message sent by forum member 'firatkucuk' (firatkucuk_at_gmail.com)]

http://forums.java.net/jive/thread.jspa?messageID=361978