Hi,

I have been having troubles using aliasBean from myfaces with the jsf-ri. I have tried the following code with both implementations:

faces-config.xml
         <managed-bean>
             <managed-bean-name>person</managed-bean-name>
             <managed-bean-class>custom.Person</managed-bean-class>
             <managed-bean-scope>request</managed-bean-scope>
         </managed-bean>
 
// Person.java
public class Person {
  
  private String firstname;
  private String lastname;
  
  public String refresh() {
    System.out.println("person: "+firstname+" "+lastname);
    return null;
  }
 
  public String getFirstname() {
    return firstname;
  }
  public void setFirstname(String firstname) {
    this.firstname = firstname;
  }
  public String getLastname() {
    return lastname;
  }
  public void setLastname(String lastname) {
    this.lastname = lastname;
  }
 
<!-- alias.jsp -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page language="java" %>
<html>
  <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
  <%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
  <body>
    <f:view>
      <h:form>
                 <x:aliasBean sourceBean="#{person}" alias="#{holder}">
                          <f:subview id="form2">
                                   <h:inputText value="#{holder.firstname}"/>
                                   <h:inputText value="#{holder.lastname}"/><p/>
                          </f:subview>
                 </x:aliasBean>
                 
                 <h:commandButton value="Refresh" action=""
color=red>"#{person.refresh}"/>
      </h:form>
      <h:messages layout="table" style="color: red"/>
    </f:view>
  </body>
</html>
 



bringing the page works in both implementations, but pressing the refresh button works in my-faces (1.0.8) and result in an exception in jsf-ri (1.1_01) :

java.lang.ClassCastException: java.lang.Boolean
         at com.sun.faces.el.ValueBindingImpl.getType(ValueBindingImpl.java:93)
         at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:111)
         at javax.faces.component.UIInput.getConvertedValue(UIInput.java:713)
         at javax.faces.component.UIInput.validate(UIInput.java:638)
         at javax.faces.component.UIInput.executeValidate(UIInput.java:849)
         at javax.faces.component.UIInput.processValidators(UIInput.java:412)
         at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:912)
         at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:912)
         at org.apache.myfaces.custom.aliasbean.AliasBean.processValidators(AliasBean.java:179)
         at javax.faces.component.UIForm.processValidators(UIForm.java:170)



furthermore, the exception occurs on the 2nd inputText, although the value binding expressions are very similar!

it is unfortunate that this component does not work with the RI because it appears to be a very effective way of reusing component trees, specially when you need several of them in the same page, binding to differents objects. Any fix or workaround?

thanks
v.

 

Reply via email to