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
JieMeJieMe 

about parameter

as follows,content:

 

   <apex:commandButton value="删除" action="{!delOneIM}">
                    <apex:param value="{!lxr.Id}" name="iid"/>
    </apex:commandButton>
  

 like this,in the controller ,get param name's value is null.

but use commandLink ,as follows:

   <apex:commandLink value="删除" action="{!delOneIM}">
                    <apex:param value="{!lxr.Id}" name="iid"/>
    </apex:commandLink>

no problem ,can get param value.

 

why?can anyone explain?thanks!

Shashikant SharmaShashikant Sharma

No You have made a mistake in your code, the param you are passing should be assigned to any property ( property has to be public) in the controller. See this example

 

 

/*** Controller ***/
public class exampleCon {
String uname;
public String getUsername() {
return uname;
}
public PageReference sayHello() {
uname = UserInfo.getName();
return null;
}
public void setState(String n) {
state = n;
}
public String getState() {
return state;
}
public PageReference methodOne() {
return null;
}
private String state = 'no';
}

 

<!-- Page: -->
<apex:page controller="exampleCon">
<apex:form>
<!-- Define the JavaScript function sayHello-->
<apex:actionFunction name="sayHello" action="{!sayHello}" rerender="out"
status="myStatus"/>
</apex:form>
<apex:outputPanel id="out">
<apex:outputText value="Hello "/>
<apex:actionStatus startText="requesting..." id="myStatus">
<apex:facet name="stop">{!username}</apex:facet>
</apex:actionStatus>
</apex:outputPanel>
<!-- Call the sayHello JavaScript function using a script element-->
<script>window.setTimeout(sayHello,2000)</script>
<p><apex:outputText value="Clicked? {!state}" id="showstate" /></p>
<!-- Add the onclick event listener to a panel. When clicked, the panel triggers
the methodOneInJavascript actionFunction with a param -->
<apex:outputPanel onclick="methodOneInJavascript('Yes!')" styleClass="btn">
Click Me
</apex:outputPanel>
<apex:form>
<apex:actionFunction action="{!methodOne}" name="methodOneInJavascript"
rerender="showstate">
<apex:param name="firstParam" assignTo="{!state}" value="" />
</apex:actionFunction>
</apex:form>
209
</apex:page>

 See this assignTo="{!state}" , that ius what you also need to do.

 

assignTo    :  A setter method that assigns the value of this param to a 10.0 global variable in the associated Visualforce controller. If this assignTo Object attribute is used, getter and setter methods, or a property with get and set values, must be defined.

JieMeJieMe

hi,sharma, 

 <apex:commandLink value="删除" action="{!delOneIM}">
                    <apex:param value="{!lxr.Id}" name="iid"/>
    </apex:commandLink>

like this,no problem ,can get param value in the controller.

 

in addition,Attribute assignTo is not required.

 

like that you say,<apex:commandLink value="删除" action="{!delOneIM}">
                    <apex:param value="{!lxr.Id}" name="iid"/>
    </apex:commandLink>  

so,the must be not work,can'it ge param value in the controller also.

 

discuss together,thanks!

 

Shashikant SharmaShashikant Sharma

just try this one time

 

<apex:param value="lidvalue"  assignTo="{!lxr.Id}" name="iid"/>

 

Even though assignTo="{!lxr.Id}"  is not required and even you provide any wrong parameter like assignTo="{!doesNotExistInController}"  it will not give you compile time error. But in order to pass value to controller it is necessary that you provide this assignTo attribute and the propety you bind should be a public property in the controller.

JieMeJieMe

<apex:commandLink value="删除" action="{!delOneIM}">
                    <apex:param value="{!lxr.Id}" name="iid"/>
    </apex:commandLink>

 

in the controller , String gmid = ApexPages.currentPage().getParameters().get('iid'); can get the param value.

 

sure ,i will try it that you say,also.

 

can i add your msn? mine:xuwenliang1987@Hotmail.com

Shashikant SharmaShashikant Sharma

here are my contact details

yahoo : shashi_99_rocks@yahoo.co.in

gmail : shashi99rocks@gmail.com

skypeid : shashikant99sharma

 

 

you can catch me on my blog also : http://forceschool.blogspot.com/

JieMeJieMe

OK,may be i am in china,can't open your blog web.

kiranmutturukiranmutturu

you have to use the rerender attribute in the command link component... create a dummy outputpanel and give the rerender attribute as output panel..and the param will set....try like this... hope this will resolve your issue..