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
DaniHellDaniHell 

How to modify apex properties with visualforce

I have some apex properties and want to modify them by visualforce

 

kind regards

harsha__charsha__c

Hi

 

If you mean apex properties to apex data variables, yes you can..!

 

The property should be public and {get;set;}

 

As : public String str1 {get;set;}

 

This means that you can set a value from controller or get it's new value from  the page..!

 

 

DaniHellDaniHell

Ok thanks,

 

so i want to access and modify this String object with VisualForce?!

 

public String objectid {get; set;}

 

Kind Regards

harsha__charsha__c

Yes..!

 

DaniHellDaniHell

Yes I know, But i want to know how can I set parameter / call the setter of the apex property in VISUALFORCE? I have an visualforce page and want to set parameter.

 

How can I do that with VIsualforce? Which tag?

harsha__charsha__c

 

You can use <apex:inputText value="{!objectId}/> for this..!

 

If you initialize objectId with some value in the controller's constructor, then the same will display on the page

 

If you change it to any other in the page the same is reflected in the controller..!

vishal@forcevishal@force

One way is as Harsha told you a above. Other way to do this is by passing a value as a param in your actionfunction. <apex:param> has a "assignTo" attribute, which lets you assign the specified value to a property in the controller.

 

Example:

 

<apex:commandButton value="Submit" action="{!submit}" rerender="error" >

     <apex:param name="anything" value="any_value" assignTo="{!any_public_property}" />

</apex:commandButton>

Hajie CarpioHajie Carpio
Hi,

I have a class defined:
public with sharing class ScheduleSlotControllerApx

with a property
public string DPSURL{get; set;}

in the visual force page it is mapped to 
<apex:form id="cciForm0"> 
<apex:inputText label="DSP URL" value="{!DPSURL}" id="DPSURL"/>
</apex:form>

then i have a button that calls a FetchScheduleSlotInfo method, in another form
<apex:form id="cciForm">        
         <!-- The rerender attribute causes addressList to be re-rendered when the button is clicked -->
         <apex:commandButton action="{!ViewScheduleSlotInfo}" value="Load Schedule Slots!" rerender="cciForm" status="callZipAPIStatus">         
         </apex:commandButton>
</apex:form>

in the code i have line of code 
System.debug('setPropertyValues URL - ' + this.DPSURL); 

to see if i'm able to get the updated value of the property.