+ Start a Discussion
JerryhncJerryhnc 

Rerender Issue

I am still relatively new to developing VisualForce pages and customer controllers.  I would like to retrieve fields from a form and then pass the values to a webservice.  When I click on the actionFunction, the method is executed.  The form values are reset to blanks (at one time they stayed on the form).  I can see the debugtxt flash up on the screen before it is reset to blanks as well.  I would like for the form fieldss to not be blanked out, so I think this is a rerender issue.

VisualForce Page
<apex:page controller="Product_UsersController" sidebar="false" >
<apex:form >
<apex:pagemessages id="errors" />

    <apex:pageBlock title="Search" id="edit">   
    
    
    
    <table border="2" style="width:100%;">
    <tr>
    	<td style="font-weight:bold;width:200px;">
    		Find Product Users
    	</td>  
    	<td>
    		Filter Options: 
    		<input type="checkbox" name="chkShowRequesters" />Show Requesters
    		<input type="checkbox" name="chkShowAdministrators"/>Show Only Administrators
    	</td>
    </tr>
    </table>
    
    <table border="2" style="width:100%;">
    <tr>
    	<td style="width:200px;valign:top;border:1;">
    		<apex:pageBlock mode="edit" id="parameters">
    
    <script type="text/javascript">
    
    function getParameters() 
    {
    	try
    	{
    	
    	passVariables(
    		"SD",
    		"MD",
    		document.getElementById("txtFirstname").value,
    		document.getElementById("txtLastname").value,
    		document.getElementById("txtLoginname").value,
    		document.getElementById("txtEmail").value,
    		document.getElementById("txtCountry").value,
    		document.getElementById("txtCity").value,
    		document.getElementById("txtState").value,
    		document.getElementById("txtZip").value);
    	}
    	catch(err)
    	{
    		alert("getParameters Error: " + err.message);
    	}
    	
    }	  		
    </script>
    <apex:actionfunction name="passVariables" action="{!runSearch}" rerender="debug,errors">
    	<apex:param name="rbBusinessUnit" value=""  />
    	<apex:param name="slProduct" value="" />
    	<apex:param name="txtFirstname" value="" />
    	<apex:param name="txtLastname" value="" />
    	<apex:param name="txtLoginname" value="" />
    	<apex:param name="txtEmail" value="" />
    	<apex:param name="txtCountry" value="" />
    	<apex:param name="txtCity" value="" />
    	<apex:param name="txtState" value="" />
    	<apex:param name="txtZip" value="" />
    </apex:actionfunction>
    
    		<table border="2" cellpadding="2" cellspacing="2" width="200px">
    		<tr>
        		<td style="font-weight:bold;">Business<br />
            		<input type="radio" id="rbBusinessUnit" name="rbBusinessUnit" value="SD" checked="true" />SD 
            		<input type="radio" id="rbBusinessUnit" name="rbBusinessUnit" value="FD" />FD
        		</td>
    		</tr>
    		<tr>
        		<td style="font-weight:bold;">Product<br />
        	 		<apex:selectlist value="{!SDProducts}" id="slProduct"  size="1">
        	 			<apex:selectOptions value="{!SDProducts}" />
        	 		</apex:selectlist>
        		</td>
    		</tr>
    		<tr>
        		<td style="Font-weight:bold;">First Name<br />
        			<input type="text" id="txtFirstname" name="txtFirstname"  />
        		</td>
    		</tr>
    		<tr>
        		<td style="Font-weight:bold;">Last Name<br />
        			<input type="text" id="txtLastname" name="txtLastname"  />
        		</td>
    		</tr>
    		<tr>
    		    <td style="Font-weight:bold;">Login Name<br />
        			<input type="text" id="txtLoginname" name="txtLoginname"  />
        		</td>
    		</tr>
    		<tr>
        		<td style="Font-weight:bold;">Email<br />
        			<input type="text" id="txtEmail" name="txtEmail"  />
        		</td>
    		</tr>
    		<tr>
        		<td style="Font-weight:bold;">Country<br />
        			<input type="text" id="txtCountry" name="txtCountry"  />
       		 	</td>
    		</tr>
    		<tr>
        		<td style="Font-weight:bold;">City<br />
        			<input type="text" id="txtCity" name="txtCity" />
        		</td>
    		</tr>
    		<tr>
        		<td style="Font-weight:bold;">State<br />
        			<input type="text" id="txtState" name="txtState" />
        		</td>
    		</tr>
    		<tr>
        		<td style="Font-weight:bold;">Zip<br />
        			<input type="text" id="txtZip" name="txtZip" />
        		</td>
    		</tr>
    		<tr>
    			<td> 
    				
    				<button onclick="getParameters()">Search</button>
    				
    				<!-- <apex:commandButton value="Search" action="{!getParameters}" id="SearchButton" rerender="results,debug,errors" /> --> 
    			</td>
   			</tr>
    			  
    	</table>
    	</apex:pageBlock>  
    	</td>
    	</tr>
    </table>
    
     
    <apex:pageBlock title="Debug" id="debug">
      <apex:outputText value="{!debugtxt}" />           
    </apex:pageBlock>
    
	</apex:pageBlock>
</apex:form>    

</apex:page>

Custom Controller
public with sharing class Product_UsersController {
        
        
        public String debugtxt {get ;  set;    }
        public List<Product2> ProductTemp = new List<Product2>();
        public string selectedProduct {get; set;}
        
        public List<SelectOption> SDProducts 
        {
        	get 
        	{
        		ProductTemp = [Select p.SDProductID__c, p.Name From Product2 p 
        			where SDProductID__c > 'A' and Family like 'SD%'
        			order by p.Name];
        		SDProducts = new List<SelectOption>();
        		SDProducts.add(new SelectOption('','<== Optional Product ==>'));
        		for (Product2 temp : ProductTemp)
        		{
        			SDProducts.add(new SelectOption(temp.SDProductID__c, temp.Name));
        		}
        		return SDProducts;
        	  }
        	  set; }
        	  
//         public List<SelectOption> FDProducts 
//        {
//        	get 
//        	{
//        		ProductTemp = [Select p.SDProductID__c, p.Name From Product2 p 
//        			where SDProductID__c > 'A' and Family like 'FD%'
//        			order by p.Name];
//        		FDProducts = new List<SelectOption>();
//        		for (Product2 temp : ProductTemp)
//        		{
//        			FDProducts.add(new SelectOption(temp.SDProductID__c, temp.Name));
//        		}
//        		return FDProducts;
//        	  }
//        	  set; }
       
 
 		public Product_UsersController() {
 //			debugtxt = 'Complete search parameters and click run search to view selections';
 			system.debug('Entered Product_usersController');
 			
 		}
 		public  PageReference runSearch()  {
 			system.debug('***Entered runSearch function');
 			string rbBusinessUnit = apexpages.currentPage().getParameters().get('rbBusinessUnit');
 			string slProduct = apexpages.currentPage().getParameters().get('slProduct');
 			string txtFirstname = apexpages.currentPage().getParameters().get('txtFirstname');
 			string txtLastname = apexpages.currentPage().getParameters().get('txtLastname');
 			string txtLoginname = apexpages.currentPage().getParameters().get('txtLoginname');
 			string txtEmail = apexpages.currentPage().getParameters().get('txtEmail');
 			string txtCountry = apexpages.currentPage().getParameters().get('txtCountry');
 			string txtCity = apexpages.currentPage().getParameters().get('txtCity');
 			string txtState = apexpages.currentPage().getParameters().get('txtState');
 			string txtZip = apexpages.currentPage().getParameters().get('txtZip');
 			
 			
 			debugtxt = 'Business Unit: ' + rbBusinessUnit;
 			debugtxt = debugtxt + '; Product: ' + slProduct;
 			debugtxt = debugtxt + '; First Name: ' + txtFirstname;
 			debugtxt = debugtxt + '; Last Name: ' + txtLastname;
 			debugtxt = debugtxt + '; Login Name: ' + txtLoginname;
 			debugtxt = debugtxt + '; Email: ' + txtEmail;
 			debugtxt = debugtxt + '; Country: ' + txtCountry;
 			debugtxt = debugtxt + '; City: ' + txtCity;
 			debugtxt = debugtxt + '; State: ' + txtState;
 			debugtxt = debugtxt + '; Zip: ' + txtZip;
			system.debug('*** ' + debugtxt);
 			return null;
 		}
}

 
JerryhncJerryhnc
There are two debug logs generated each time I click on the Search button.  One has the debug messages from the runSearch method and the second debug log does not have those messages.
AdrianCCAdrianCC
Hi Jerry,

Can you please give us more info on what this page should do? Why are you using standard html and not apex components? Did you find a solution to this by any chance since you posted this on the Nov 5th :P?

Ty,
Adrian