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 can I call a apex method with an parameter?

I want to call an apex method with an parameter on my own visualforce page?

 

public void getListe(String objectId){

        Zeiterfassungsliste__c [] zeiterfassungslisteList;
        zeiterfassungslisteList = [SELECT Id FROM Zeiterfassungsliste__c WHERE Id =: objectId];
		
	delete zeiterfassungslisteList;
		
   }

 

kiranmutturukiranmutturu

i hope you want to set the objectid value from the visualforce page.  is this  that you are looking out?

DaniHellDaniHell

Yes, I want to call an apex method with an parameter from my custom visualforce page.

ManjunathManjunath

Hi,

 

Use <apex:param> tag to pass value from visualforce page to controller.

 

Regards,

Manjunath

kiranmutturukiranmutturu

you can simply call the method using the method name in the visualforce whether it is a parameterized or not....

 

if you want to pass a value to that parameter you can make use of query strings or apex:param tags to assign the value to a property varaible... or you can make use remoteaction like this

DaniHellDaniHell

It's not working. I am getting the following error message.

I tried the same apexfunction with apex:param. I am getting the same error.

<apex:form >
    			<apex:actionFunction name="loescheZeiterfassungsListe" action="{!loescheZeiterfassungsListe}" onComplete="">
    			<apex:param name="objectId" value="asdasd"/>
    			</apex:actionFunction>
    		</apex:form>

 

 

Please help.

 

 Error Message:

Description	Resource	Path	Location	Type
Save error: /apex/mobilepage @414,117 action="#{loescheZeiterfassungsListe}": Unknown method 'Zeiterfassung__cStandardController.loescheZeiterfassungsListe()'	mobilepage.page	/Mobile/src/pages	line 0	Force.com save problem

 

My Code:

	<div data-role="page" id="loeschenPage">
    		<apex:form >
    			<apex:actionFunction name="loescheZeiterfassungsListe" action="{!loescheZeiterfassungsListe}" onComplete="">
    			</apex:actionFunction>
    		</apex:form>

    		<div data-role="header">

 

 

 public void loescheZeiterfassungsListe(String objectId){
		
		Zeiterfassungsliste__c [] zeiterfassungslisteList;
        zeiterfassungslisteList = [SELECT Id FROM Zeiterfassungsliste__c WHERE Id =: objectId];
		
		delete zeiterfassungslisteList;
   }

 

 

kiranmutturukiranmutturu

if you are passing as param then you neeed to get the value of the param using 

 

apexpages.currentpage().getparameters().get('objectid')..........

 

you can do in an another way also

 

prepare a property in the class like

 

publis string objectid{get;set;}

 

and then in the vf page add the property to param like

 

<apex:param name="objectid" assignto="{!objectid}"/>

 

then you can use the objectid in the query directly....

DaniHellDaniHell

ok and how can I set the parameter dynamically?

I want to set the value with javascript oder jquery.

 

<apex:form >
		<apex:actionFunction name="loescheZeiterfassungsListe" action="{!loescheZeiterfassungsListe}" onComplete="">
		<apex:param name="idpar" assignto="{!objectid}" id="idparam" value="ss"/>
		</apex:actionFunction>
		</apex:form>