Hello again.

I did a whole lot of testing. I tried to change Tiles 2 for Facelets, but I 
still had the same problem!

So I made four examples, using different implementation. I always used the 
latest JSF 1.2 releases (MyFaces 1.2.7, Mojarra 1.2.12, Facelets 1.1.14).
MyFaces alone, works as intended.
Mojarra (Sun's implementation) alone, works as intended.
MyFaces and Facelets fails like my application does.
Mojarra and Facelets fails too !

The four project are a single form with an integer field, that maps to a 
application scope bean. There are an "ok" and a "cancel" command link. The 
cancel has its immediate attribute set to true.
So clicking ok should update the field value, while clicking cancel should not.
This is what happens without Facelets. If I use it, both links update the 
field, as if there was no immediate="true".

So I probably made a mistake using facelets.

Here is the code for Mojarra and Facelets. I can send the four projects to 
anyone willing to help.

web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns="http://java.sun.com/xml/ns/javaee"; 
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; id="WebApp_ID" version="2.5">
  <display-name>TestMojarraFacelets</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
  </context-param>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
</web-app>

faces-config.xml
<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE faces-config PUBLIC
  "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
  "http://java.sun.com/dtd/web-facesconfig_1_1.dtd";>

<faces-config>
<application>
    <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
 </application>
<managed-bean>
        <managed-bean-name>pageBean</managed-bean-name>
        <managed-bean-class>test4.PageBean</managed-bean-class>
        <managed-bean-scope>application</managed-bean-scope>
    </managed-bean>

<navigation-rule>
<from-view-id>/hello.jsp</from-view-id>
<navigation-case>
<from-outcome>self</from-outcome>
<to-view-id>/hello.jsp</to-view-id>
</navigation-case>
</navigation-rule>

</faces-config>

hello.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";
    xmlns:f="http://java.sun.com/jsf/core";
    xmlns:h="http://java.sun.com/jsf/html";>
   <body>
      <f:view>
          <h:form id="aform">
         <h:inputText value="#{pageBean.intField}"/>
         <br />
         <h:commandLink action="#{pageBean.ok}" value="ok" />
         <br />
         <h:commandLink action="#{pageBean.cancel}" value="cancel" 
immediate="true" />
         </h:form>
      </f:view>
   </body>
</html>

index.jsp
<jsp:forward page="hello.jsf"/>

PageBean.java
package test4;

public class PageBean {

    private Integer intField = 13;

    public Integer getIntField() {
        return intField;
    }

    public void setIntField(Integer intField) {
        this.intField = intField;
    }
    
    public String ok() {
        return "self";
    }
    
    public String cancel() {
        return "self";
    }
}

Thanks in advance,

BugFactory


From: [email protected]
To: [email protected]
Subject: MyFaces ignores immediate="true" when using Tiles 2.
Date: Mon, 14 Sep 2009 11:19:38 +0200








Good morning.

As a first time poster on this list, I'd like to say hello to everybody.

I have run into a problem when attempting to upgrade an application to use 
MyFaces 1.2 and Tiles 2. (It previously used MyFaces 1.1 and Struts Tiles.) My 
command links ignores their immediate="true" attribute. There is an exception 
happening in my getters when they should not have been called in the first 
place.

I suspect a bug in JspTilesTwoViewHandlerImpl, though I may be the one to 
blame. Does anyone have any idea on how to fix or work around this problem ?

Thanks in advance,

BugFactory

Gratuit : Hotmail plus rapide avec Internet Explorer 8 !  Cliquez ici !
_________________________________________________________________
A la recherche de bons plans pour une rentrée pas chère ? Bing ! Trouvez !
http://www.bing.com/search?q=bons+plans+rentr%C3%A9e&form=MVDE6

Reply via email to