function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rafael.Martins.SantosRafael.Martins.Santos 

How pass a value from outputfield to variable of controller?

Hi,
I'm trying to pass a value of a field OutputField to a variable of controller, but I can't.
I'm using outputField because I'm using inline editing tag.
What happens is:
When I edit the value, the record is not updated.

So I must get the new value that I'm inserting in this field (OutputField) and send to a variable on Controller,So I can make an update by this way.

Can someone help me?

Best Regards
Rafael
 
Suresh(Suri)Suresh(Suri)
Hi
  You can pass the value by using ActionFunction . Here is some code you can refer ...
   This is a small page which contains one pickList field ie Type... when you will choose "Other" from that Field an section is rendred which contains only hello..
here is my page..
<apex:page controller="Mycontrollernew">
     <script type="text/javascript">
  function Callmefunc(id)
   {
   alert(''+id); 
   var type = document.getElementById(id).value;
   alert(type);
  
    
    check(type); 
    //return true;
    
   
   }
   </script>
    <apex:form >
    <apex:actionFunction name="check" action="{!makingfield}" reRender="refresh">
                    <apex:param name="Mahavir" value="" />
                </apex:actionFunction>
        
    <apex:pageBlock >
        <apex:pageBlockSection >
            <apex:inputField value="{!account.Type}" id="check" onchange="Callmefunc('{!$Component.check}');">
                
            </apex:inputField>
           
        </apex:pageBlockSection>
        <apex:outputPanel id="refresh" >
        <apex:outputPanel rendered="{!readonly=='true'}" >
                
                    
              helooooo
            </apex:outputPanel> 
            </apex:outputPanel> 
    </apex:pageBlock>
    
     </apex:form>
 </apex:page>
Controller class
public class Mycontrollernew {
     public Account account{get;set;}
     public String act{get;set;}
     public String readonly {get;set;}
     public Mycontrollernew(){
     }
     
     public void makingfield() {
        act =System.currentPageReference().getParameters().get('Mahavir');
        System.debug('!!!!!!!!!!!!!!!!!!!asish!!!!!!!!!!!!!LeadType!!!!!!!!!!!!!!!!!'+act);
        if(act=='Other') {
          readonly = 'true';
        }
     }
 }

 
Rafael.Martins.SantosRafael.Martins.Santos
Hi Suresh,
Thanks for your help.
I will test your code and I let you know if it work.

Best Regards
Rafael