+ Start a Discussion
DrBixDrBix 

Editing Text Fields in Child Objects

I have a Visualforce page that is used to edit an object's values.  The relationship is such that the object being edited has a master-detail relationship with another object, and those children also have a master-detail relationship with another object.

Object1 -> Object2 -> Object3

Object1 has a few fields that the user can edit.
Object 2 is iterated over and displays four fields that are also editable.
Object 3 has two fields that are displayed and can be edited.

While it may sound a little confusing, the presentation is fairly clean and understandable to the user.  The data is presented in <apex:repeat> tags and uses the normal "__r" attributes as to what gets iterated over.  For example:

 

<apex:inputText value="{!object1.field1}"/>
<apex:repeat value="{!object1.object2__r}" var="object2">
  <apex:repeat value="{!object2.object3__r}" var="object3">

     <apex:inputText value="{!object3.field1}"/>

     <apex:inputText value="{!object3.field2}"/>

  </apex:repeat>
</apex:repeat>

 

I've left out much of the detail to make it simple.  Anyhow, I have a command button that submits the information but when I inspect what's going on, none of the child input fields seem to be passed back in the response.  The command button has the rerender attribute set, and I see Object1's data being changed, but the child object's fields do not seem to be there.

 

Am I doing something wrong here?

 

Thanks in advance.

S91084S91084

try the below code:

 

<apex:repeat value="{!object1.object2__r}" var="object2">
  <apex:repeat value="{!object2.object3__r}" var="object3">
     <apex:inputText value="{!object3.field1}">
         <apex:actionSupport action="{!temp}" event="onchange">
             <apex:param value="{!object3.field1}" assignTo="{!temp1}" name="t1"/>
         </apex:actionSupport>
     </apex:inputText>
     <apex:inputText value="{!object3.field2}">
         <apex:actionSupport action="{!temp}" event="onchange">
             <apex:param value="{!object3.field2}" assignTo="{!temp2}" name="t2"/>
         </apex:actionSupport>
     </apex:inputText>
  </apex:repeat>
</apex:repeat>

 and in your controller define the following:

 

publis String temp1 {get;set;}

public string temp2 {get;set;}

 

public pageReference temp(){

   return null;

}

 

Let me know if you face any issues

aballardaballard

It certainly should not be necessary to use apex:param/assignto to achieve the result you want...  inputField bound to the object reference as in your code should be fine. 

 

Are you using actionRegion in your page?   Incorrect use of actionRegion is one common cause of fields not getting updated when expected. 

 

 

DrBixDrBix

I am not using any action regions, no.

DrBixDrBix

The page is rather large, so I'd rather not paste it into here unless necessary.