Amira
Amira

Reputation: 3270

setPropertyActionListener is not passing the right value

i have an editor component that displays the selected family (from a tree ) description

so after editing it the user click on save button in there i want to use this

 <f:setPropertyActionListener  target="#
            {projectTestManagementMB.selectedNodeDescription}" 
             value="projectTestManagementMB.selectedFamily.description" />

to pass the new value of the description to this variable selectedNodeDescription . but when i check it i found it containing the old value of projectTestManagementMB.selectedFamily.description and not the new one .

Here's the code :

<p:editor id="familyDescriptionEditor" value="#
     {projectTestManagementMB.selectedFamily.description}" width="600"/>  

      <p:commandButton id="submitButton" value="Save"   icon="ui-icon-disk"  
       actionListener="#{projectTestManagementMB.saveDescription}">
          <f:setPropertyActionListener  target="#
            {projectTestManagementMB.selectedNodeDescription}" 
             value="projectTestManagementMB.selectedFamily.description" />

      </p:commandButton>  

Upvotes: 0

Views: 459

Answers (1)

Amira Manai
Amira Manai

Reputation: 2599

The ActionListener instance created and installed by this tag has the following behavior and contract. Only create and register the ActionListener instance the first time the component for this tag is created.

So Try using the action attribute instead of actionListener :

   <p:commandButton id="submitButton" value="Save"   icon="ui-icon-disk"  action="#   
        {projectTestManagementMB.saveDescription}" >
          <f:setPropertyActionListener  target="#
         {projectTestManagementMB.selectedNodeDescription}" value="#
          {projectTestManagementMB.selectedFamily.description}" />
    </p:commandButton>  

Upvotes: 1

Related Questions