You need to sign in to do that
Don't have an account?

Working with <apex;param> component in visualfoce along with controller
As the above page showing, If i click on the button, the corresponded output should be taken to respected detailed page. But it does not taking into respected output. I tried with following Controller and VF page.
Controller : public class Redirect_Main1 { public List<Account> accs { get; set; } public ID aid; public void access(){ accs = [select id,name,phone,Industry from account]; for(Account acc:accs){ aid = acc.id; } } public String getAccess2(){ return 'https://ap2.salesforce.com/'+aid; } }
VF Page : <apex:page Controller="Redirect_Main1" action="{!access}"> <apex:form > <apex:pageBlock > <apex:pageBlockTable value="{!accs}" var="a"> <apex:column value="{!a.Id}"/> <apex:column value="{!a.Name}"/> <apex:column value="{!a.Phone}"/> <apex:column value="{!a.Industry}"/> <apex:column > <apex:commandButton value="Click" action="{!access}"/> <apex:param name="account" assignTo="{!aid}" value="{!access2}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>I have tried maximum up to my best, but i could not get respected output. May be i think so, i committed wrong with <apex;param> component. Please let me know where i did mistake.
Try this simple way which works on onClick JS function,
Controller,
VF page,
Let me know if it works.
Thanks,
Nagendra
All Answers
Try this simple way which works on onClick JS function,
Controller,
VF page,
Let me know if it works.
Thanks,
Nagendra
Hi....
Thank you Nagendra. You made me so relief. The provided sample is working. But the respected output is coming in new window. Can you provide sample like output will open in new tab only.
Replace the button code with this code :
<apex:commandButton value="Click" onclick="window.open('/{!a.Id}','_blank')"/>
Note:
actually the issue is that whenever we set the third argument then it open in new window, because the third argument define the configuration of newly open window like width,height,toolbar etc.
Thanks.
Hi Rohit K Sethi,
Finally i got my requirement. But i have one doubt. Could you please explain it?
1. Why we are using using onclick="window.open('/{!a.Id}' '_blank')" ?
@Nagendra, if you know about this query, you can also explain...Please do not neglet to answer this query...
Thanking you
Kumaar
https://ap2.salesforce.com/0012800000jkgh6R
Hope I answered ur question. If it works please select above one as best answer which will help others searching for the same.
Thanks,
Nagendra
Hi Nagendra Prasad
As you said, we no need to append our salesforce org url and it will takes to url passed as parameter which takes to https://ap2.salesforce.com/followed by id.
Here i comes with another doubt, we are just passing id of an object record. then how it will take to https://ap2.salesforce.com/followed by id automatically even if are not passing full url
please feel free to clear my doubt and don't hasitate towards me. I am new to work with SFDC along with JS...
Thanking you
KS Kumaar
That is salesforce out of box feature. We no need to pass our org URL(https://ap2.salesforce.com), salesforce takes it from org and append it.
If we pass entire URL, then also it will work. But it is not best practice since URL changes from sandbox to sandbox and production. So if we hard code it, code developed in sandbox may not work in Production.
Thank you Nagendra. Your answers makes me some understandable.
Thanks for support. Hope we will continue in future too.
Can you please provide any other way for directly contact to you like skype, LinkedIn or any other. Because this forums site unable to conatct you directly or may take long time to contact you(that to if you see my query). So, Please provide any easy way to contact you. If you are feeling any secuirity issues for giving your details here, please take my email id: kumarks337@gmail.com. you can mail to it.
Thanking you
KS Kumaar