You need to sign in to do that
Don't have an account?
visulaforce
how to pass object as parameter of command link
Hi,
In the code written below i do have one VF page. this page display list of documents. Each row displayed with three command link for Edit, Delete and View the doc. on action of Edit, View and Delete command link method will get called. I have defined these editDoc, deleteDoc and viewDoc methods in "ViewDocumentControllerExt" controller class. I hav 2 issues with that.
1) when i click on any of commandlink same page is getting refreshed and controlller is not getting transfered to the page in pageRef variable and i dont know wether method is getting called or not cos i no debug is getting displayed.
2) I wanna pass a object as parameter of command link and wanna get this object value in Apex class . how to do that.
Pls provide me solution asap.
<apex:page action="{!loginDocMall}" standardController="Opportunity" extensions="ViewDocumentControllerExt" tabstyle="Opportunity">
<apex:form >
<apex:pageBlock title="Document">
<apex:dataTable value="{!propertyList}" var="docProperty" columns="9">
<apex:column >
<apex:commandLink value="Edit" action={!editDoc}>
<apex:param name="docId" value="{!docProperty.docId}"/>
</apex:commandLink >
</apex:column>
<apex:column >
<apex:commandLink value="View" action="{!viewDoc}">
<apex:param name="docId" value="{!docProperty.docId}"/>
</apex:commandLink>
</apex:column>
<apex:column >
<apex:commandLink action="{!deleteDoc}" value="Del">
<apex:param name="docId" value="{!docProperty.docId}"/>
</apex:commandLink>
</apex:column>
<apex:column value="{!docProperty.category}"/>
<apex:column >
<apex:commandLink value="{!docProperty.title}" />
</apex:column>
<apex:column value="{!docProperty.size}"/>
<apex:column value="{!docProperty.subject}"/>
<apex:column value="{!docProperty.keywords}"/>
<apex:column value="{!docProperty.lastModified}"/>
</apex:dataTable>
</apex:pageBlock>
</apex:form>
</apex:page>
In the code written below i do have one VF page. this page display list of documents. Each row displayed with three command link for Edit, Delete and View the doc. on action of Edit, View and Delete command link method will get called. I have defined these editDoc, deleteDoc and viewDoc methods in "ViewDocumentControllerExt" controller class. I hav 2 issues with that.
1) when i click on any of commandlink same page is getting refreshed and controlller is not getting transfered to the page in pageRef variable and i dont know wether method is getting called or not cos i no debug is getting displayed.
2) I wanna pass a object as parameter of command link and wanna get this object value in Apex class . how to do that.
Pls provide me solution asap.
<apex:page action="{!loginDocMall}" standardController="Opportunity" extensions="ViewDocumentControllerExt" tabstyle="Opportunity">
<apex:form >
<apex:pageBlock title="Document">
<apex:dataTable value="{!propertyList}" var="docProperty" columns="9">
<apex:column >
<apex:commandLink value="Edit" action={!editDoc}>
<apex:param name="docId" value="{!docProperty.docId}"/>
</apex:commandLink >
</apex:column>
<apex:column >
<apex:commandLink value="View" action="{!viewDoc}">
<apex:param name="docId" value="{!docProperty.docId}"/>
</apex:commandLink>
</apex:column>
<apex:column >
<apex:commandLink action="{!deleteDoc}" value="Del">
<apex:param name="docId" value="{!docProperty.docId}"/>
</apex:commandLink>
</apex:column>
<apex:column value="{!docProperty.category}"/>
<apex:column >
<apex:commandLink value="{!docProperty.title}" />
</apex:column>
<apex:column value="{!docProperty.size}"/>
<apex:column value="{!docProperty.subject}"/>
<apex:column value="{!docProperty.keywords}"/>
<apex:column value="{!docProperty.lastModified}"/>
</apex:dataTable>
</apex:pageBlock>
</apex:form>
</apex:page>
public class ViewDocumentControllerExt
{
private static String sessionId = null;
private final Opportunity opportunity;
private static List<DocProperty> propertyList = new List<DocProperty>();
// The extension constructor initializes the private member
// variable acct by using the getRecord method from the standard
// controller.
public ViewDocumentControllerExt(ApexPages.StandardController stdController) {
this.opportunity = (Opportunity)stdController.getRecord();
}
public List<DocProperty> getPropertyList()
{
return propertyList;
}
public String getSessionId()
{
return sessionId;
}
.........
some more methods here
.........
public PageReference editDoc()
{
String id = System.currentPageReference().getParameters().get('docId');
PageReference pageRef = new PageReference('/apex/docEditPage');
pageRef.setRedirect(true);
return pageRef;
}
public PageReference viewDoc()
{
System.debug('inside viewDoc method');
PageReference pageRef = new PageReference('/apex/docViewPage');
pageRef.setRedirect(true);
return pageRef;
}
public PageReference deleteDoc()
{
System.debug('inside deleteDoc method');
String id = System.currentPageReference().getParameters().get('docId');
PageReference pageRef = new PageReference('/apex/docDeletePage');
pageRef.setRedirect(true);
return pageRef;
}
}
Back to your specific problem - something like this (NOTE: some content omitted for brevity) would be much more direct and will also perform better (no need to post back to the server and invoke any action methods):
BTW can you please use SRC blocks to contain code in your posts and also post indented VF markup - both make it much easier for folks to read and understand your markup which ultimately helps you get your questions answered faster - thanks!
Message Edited by dchasman on 06-15-2008 10:43 AM
Thnx for reply . But problem is still there.
1)I wanna pass some sensitive information sessionId and object. If i use "outputLink" tag then this will appened in url query string n will be visible.
2) When i am passing object as parameter in outputLink tag n trying to get the same in Apex class it's giving me error like
in expression in code below:
I am trying to do something similiar.. well, I have the list of contacts in a new tap. I would like to view the details of each contact when clicking on the name.. however, I don't want to load a new page and staring to a blank browser during the process.. I would like to display the details in the same tap (same funtionality as the Contact tap) so just the content of the tap should change... do you know how to do that? here is my code..