I pass a string reference to my composite component with the value =
ORIGINAL VALUE, then my composite component have a button, this button
change the original value to = HERE IM SETTING A NEW VALUE, then when
i press my button in my "normal page: page.xhtml for review it",the
value still without any change (ORIGINAL VALUE), why this happend, if
my string is pass as a reference because is an object, what im doing
wrong?

Resume:

1. I pass a String (as attribute to my composite component) with the
value: ORIGINAL VALUE
2. Then in the composite component i get this attribute and change it
to =HERE IM SETTING A NEW VALUE
3. When i review the value in page.xhtml i see again ORIGINAL VALUE
(not expected)
4. If i review my value in my composite component i have:HERE IM
SETTING A NEW VALUE

I try to set my Bean to RequestScoped, ViewAccessScoped and
SessionScoped and the problem is the same.

Here is an example:

My composite component: myComponent.xhtml

 <ui:component  xmlns="http://www.w3.org/1999/xhtml";
          xmlns:p="http://primefaces.org/ui";
          xmlns:cc="http://java.sun.com/jsf/composite";
          xmlns:ui="http://java.sun.com/jsf/facelets";
          xmlns:h="http://java.sun.com/jsf/html";>

        <cc:interface componentType="myComponent">
            <cc:attribute name="myString" type="java.lang.String"/>
        </cc:interface>

        <cc:implementation>
            <p:commandButton value="Change Value"
                             actionListener="#{cc.changeStringValue}"/>
        </cc:implementation>

    </ui:component>
My FacesComponent Class:

@FacesComponent(value="myComponent")
 public class MyComponent extends UINamingContainer  {
   public void changeStringValue(ActionEvent e){
     String originalValue = (String) getAttributes().get("myString");
     //Here i change the value
     originalValue = "HERE IM SETTING A NEW VALUE";
   }
 }
My page.xhtml

<h:body>
 <h:form id="myform">
 <test:myComponent myString="#{myBean.myString}/>
 <p:commandButton value="Review change"
     actionListener="#{myBean.showValue}"/>
<h/form>
</h:body>
ManagedBean:

@Named
@ViewAccessScoped
public void MyBean implements Serializable{
   public String myString = "ORIGINAL VALUE";

   public void showValue(ActionEvent e){
    //why here i see ORIGINAL VALUE if my component change the reference value??
     System.out.println("Value: "+myString);
   }

  //setters and getters...
}



What im doing wrong???

Reply via email to