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
KitpithKitpith 

ActionFunction Not rendering the InputField inside Panel

Hello I am trying to rerender the input inside a panel but its not refreshing the input text but also creating a new input text field.

 

Below is the Controller code which is fetching value and after checking the logs i found the name is properly coming but when displaying it into the input text field its not showing.

 

Controller code :

=========================================================================================

public class toolExtension {         

  public  RecordedTools__c Recordtools; //User sobject   

  public String selectedTool {get;set;}

    public String lname{get;set;}

    public String lookupvalue{get;set;}

    //initializes the private member variable u by using the getRecord method from the standard controller   

// public toolExtension(ApexPages.StandardController stdController) {                   // }   

   public toolExtension(ApexPages.StandardController stdController) {     }   

      public PageReference retrieveVal()     {

        String ipString = changepicklistvalue();         return null;     }   

 

  public string changepicklistvalue()

{

 //system.debug(apexpages.currentpage().getparameters().get('selectedTool'));   

  System.debug('lookup val**'+selectedTool);   

  ToolResponsible__c toolres = [SELECT p.User__c FROM ToolResponsible__c p where p.DTools__c =:selectedTool];     User user=[SELECT p.Name FROM User p where p.id =:toolres.User__c];   

  //System.debug('Val***'+toolres.User__c);    

System.debug('Name***'+user.Name);

  String lname = user.Name;    

//System.debug "Values"+name;   

// System.debug('Name'+name);

     System.debug('Name'+lname);   

  return lname;

}

 

}

 

 

===================================================================================

VF Page :

===================================================================================

<apex:page standardController="User" extensions="toolExtension">     

     <apex:outputText id="NbLoginTool" value="21" rendered="true"/>   

  <apex:messages id="messages" />  

   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

      <script type="text/javascript" >       

    function callonlookup(val) {

    alert('check'+val.value);

           callpicklistmethod(val.value);     }

 

         function loadLoginTool(idGet, idBut, fldTool, nbMax) {    

        $('[id $="lTool22"]').css('display','block');        

   // 'input[id $="fl_Tools_Tool_21"]').val()=$('input[id $="fl_Tools_Tool_21"]').val()+1      

     // 'input[id $="NbLoginTool"]').val()=$('input[id $="NbLoginTool"]').val()+1     

      }     </script>

 

   <apex:form id="FrmTools">   

      <apex:pageBlock >  

      <apex:pageBlockSection id="UserInfo" title="UserInformation">  

     <div id='LoginTool' >

        <TABLE WIDTH="100%" BORDER="1" CELLSPACING="0" CELLPADDING="2">           

    <tr id='lTool21' >  

               <TD VALIGN="Top" COLSPAN="2" ><br></br>   

                  <apex:selectList id="tools1" value="{!selectedTool}" size="1" title="tools" onchange="callonlookup(this)">                   <apex:selectOptions value="{!tools}" ></apex:selectOptions>  

              <apex:actionFunction name="callpicklistmethod" reRender="lpanel1,messages" action="{!retrieveVal}">  <apex:param name="selectedTool" value="{!selectedTool}" assignTo="{!selectedTool}"/> </apex:actionFunction></apex:selectList>

</TD>     

  <apex:outputPanel id="lpanel1" >

      <TD VALIGN="Top" COLSPAN="2" ><br></br>

       <apex:inputText id="fl_Tools_Tool_21" label="hello" value="{!lname}"/>

            </td>     

      </apex:outputPanel>       

       <td><br></br><span id='lToolBut'>

<a class="bouton" style = "cursor:hand" onclick="loadLoginTool('lTool', 'lToolBut', 'NbLoginTool', '30');">Add a Tool</a></span></td> </TR>  

   </TABLE>  

   </div>

</apex:pageBlockSection>

</apex:pageBlock>

    </apex:form>   

</apex:page>

 

===================================================================================

 

==========================================================================================

Shiv ShankarShiv Shankar

Hi Kitpith,

 

As far as i understood since you are using <apex:outputPanel> outside the td. so you are getting unexpected result.

Just make following change and check.

 

Previous code

<apex:outputPanel id="lpanel1" >

      <TD VALIGN="Top" COLSPAN="2" ><br></br>

       <apex:inputText id="fl_Tools_Tool_21" label="hello" value="{!lname}"/>

            </td>     

      </apex:outputPanel>  

 New Code

<TD VALIGN="Top" COLSPAN="2" ><br></br>
<apex:outputPanel id="lpanel1" >

       <apex:inputText id="fl_Tools_Tool_21" label="hello"  value="!lname}"/>

      </apex:outputPanel>  
</td>  

 

KitpithKitpith

Hi Shiv,

                Did the same you suggested, but did not work.

Shiv ShankarShiv Shankar

Hi Kitpith,

 

You are calling function "retrieveVal" this function does nothing but set the value. My question is that than why you returning pageReference.

 

just make it like this way

 public void retrieveVal()     {

        String ipString = changepicklistvalue(); 
}   

 No need to return page reference.

Shiv ShankarShiv Shankar

Hi Kitpith,

 

In my understanding changepicklistvalue method is enough for us.

 

controller code can be like this.

public class toolExtension {         

    public  RecordedTools__c Recordtools; //User sobject   
    public String selectedTool {get;set;}
    public String lname{get;set;}
    public String lookupvalue{get;set;}


    public toolExtension(ApexPages.StandardController stdController) {   
	
    } 
  
	public void changepicklistvalue() {

	  ToolResponsible__c toolres = [SELECT p.User__c FROM ToolResponsible__c p where p.DTools__c =:selectedTool];     User user=[SELECT p.Name FROM User p where p.id =:toolres.User__c];   
	  String lname = user.Name;    

	}

}

 VF Page can be like this.

<apex:page standardController="User" extensions="toolExtension">     
	<apex:outputText id="NbLoginTool" value="21" rendered="true"/>   
	<apex:messages id="messages" />  
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" >       
		function callonlookup(val) {
			alert('check'+val.value);
            callpicklistmethod(val.value);     
		}
         
		function loadLoginTool(idGet, idBut, fldTool, nbMax) {    
			$('[id $="lTool22"]').css('display','block');        

        }     
	</script>

   <apex:form id="FrmTools">   
		<apex:pageBlock >  
			<apex:pageBlockSection id="UserInfo" title="UserInformation">  
				<div id='LoginTool' >
					<TABLE WIDTH="100%" BORDER="1" CELLSPACING="0" CELLPADDING="2">           
						<tr id='lTool21' >  
							<TD VALIGN="Top" COLSPAN="2" ><br></br>   
								<apex:selectList id="tools1" value="{!selectedTool}" size="1" title="tools" onchange="callonlookup(this)">                   
									<apex:selectOptions value="{!tools}" ></apex:selectOptions>  
									<apex:actionFunction name="callpicklistmethod" reRender="lpanel1,messages" action="{!changepicklistvalue}">  
										<apex:param name="selectedTool" value="{!selectedTool}" assignTo="{!selectedTool}"/> 
									</apex:actionFunction>
								</apex:selectList>

							</TD>     
							
							<TD VALIGN="Top" COLSPAN="2" ><br></br>
								<apex:outputPanel id="lpanel1" >
									<apex:inputText id="fl_Tools_Tool_21" label="hello" value="{!lname}"/>
								</apex:outputPanel>
							</td>     
							       

							<td>
								<br></br>
								<span id='lToolBut'>
								<a class="bouton" style = "cursor:hand" onclick="loadLoginTool('lTool', 'lToolBut', 'NbLoginTool', '30');">Add a Tool</a></span>
							</td> 
						</TR>  

					</TABLE>  

				</div>
			</apex:pageBlockSection>
		</apex:pageBlock>
    </apex:form>   
</apex:page>

 

KitpithKitpith

Hello Shiv,

I did the same thing, what you suggested but getting the erorr as "

Visual Force Page Error :  java.lang.IllegalArgumentException: Illegal view ID '. The ID must begin with / " So in forum I read that i need to define it in the same way what is currently.

 

Even this is fine because i check the logs and getting the data but the same data is not reflecting in VF page.

 

Regards

Kith

Shiv ShankarShiv Shankar

To reflect data in VF page. made this change

public class toolExtension {         

    public  RecordedTools__c Recordtools; //User sobject   
    public String selectedTool {get;set;}
    public String lname{get;set;}
    public String lookupvalue{get;set;}


    public toolExtension(ApexPages.StandardController stdController) {   
	
    } 
  
	public void changepicklistvalue() {

	  ToolResponsible__c toolres = [SELECT p.User__c FROM ToolResponsible__c p where p.DTools__c =:selectedTool];     User user=[SELECT p.Name FROM User p where p.id =:toolres.User__c];   
	  lname = user.Name;    // modified code....................

	}

}