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
Meer SalmanMeer Salman 

Setting property from VFPage

Hi,

 

I have a Controller in which i have a property as following:

 

public class test

{

public string mystr {get; set;}

}

 

I have a VFPage for this controller now I want to set the property on the click event of outputlink how can I set the property? I know how to get the value fromt he property but I am a bit confuse in setting a property via VFPage.

 

<apex:page controller = 'test'>

<apex:form>

<apex:outputlink value="xyz" onclick???>Meer</outputlink>

</apex:form>

</apex:page>

 

 

Regards,

Meer Salman

Best Answer chosen by Admin (Salesforce Developers) 
kiranmutturukiranmutturu

try like this. u need to replace the value in param tag...

 

<apex:page controller = "test">
<apex:form>
<apex:outputlink value="xyz">Meer

<apex:param assignTo="{!mystr}" value="need to fill the respective property"/>
</outputlink>
</apex:form>
</apex:page>

All Answers

kiranmutturukiranmutturu

try like this. u need to replace the value in param tag...

 

<apex:page controller = "test">
<apex:form>
<apex:outputlink value="xyz">Meer

<apex:param assignTo="{!mystr}" value="need to fill the respective property"/>
</outputlink>
</apex:form>
</apex:page>

This was selected as the best answer
Navatar_DbSupNavatar_DbSup

Hi,

Try the below code snippet as reference:

--------------- Vf page-----------------

<apex:page controller="test">

<script>

function chkfun(val)

{

    alert(val.href);

    assignvalue(val.href);

}

</script>

 

<apex:form >

 

<apex:outputLink value="http://google.com" onclick="chkfun(this)" >abc </Apex:outputLink>

<apex:actionFunction name="assignvalue" action="{!getvalue}"><apex:param value="" assignTo="{!mystr}" name="assignvalue"/> </apex:actionFunction>

</apex:form>

 

</apex:page>

 

 

------------- Apex controller-------------

public class test

 

{

 

public string mystr{get; set;}

public void getvalue()

{

    system.debug('##################'+mystr);

}

 

}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.