You need to sign in to do that
Don't have an account?
tantonio
How to add a button to each row within a visualforce page and onclick a URL field value
Hello!
I am looking to add a button to each row in my pageblocktable and the button should call the value of the URL field called loginURL__c. Basically I'm trying to take the column in my pageblock which is a field value and make it a button. I'm having trouble even getting started with this one. All the only resources only show how to add a button to the top of a pageblocktable, which I've done and its not what I'm looking for.
Can anybody help me get going in the right direction?
VFP:
<apex:page controller="listorgs"> <apex:form > <Apex:pageblock > <Apex:pageblockButtons > <Apex:commandButton value="login" onclick="openpage('login'); return false;"/> </Apex:pageblockButtons> <br/> <br/> <apex:pageblockTable value="{!newlist}" var="obj"> <apex:column > <Apex:outputfield value="{!obj.name}"/> </apex:column> <apex:column > <Apex:outputfield value="{!obj.LoginURL__c}"/> </apex:column> <apex:column > <Apex:outputfield value="{!obj.Description__c}"/> </apex:column> <apex:column > <Apex:outputfield value="{!obj.HRM_Installed__c}"/> </apex:column> </apex:pageblockTable> </Apex:pageblock> </apex:form> </apex:page>
Controlling Class:
Public class listorgs implements iterator<org__c>{ public static List<org__c> newlist {get; set;} Integer i {get; set;} public listorgs(){ newlist = [select id, name , LoginURL__c , HRM_Installed__c, Description__c from org__c]; i = 0; } Public boolean hasnext(){ if(i>= newlist.size()){ return false; } else { return true; } } Public Org__c next(){ if(i==100){return null;} i++; return newlist[i-1]; } public string page{get;set;} public string openpageurl {get;set;} public void onload() { page = ''; openpageurl = ''; } public pagereference redirect() { if( page == 'login') { openpageurl = 'http://google.com'; } return null; } }
Thanks for the tips!!!
Hi
Try in this way ..
<apex:column >
<apex:commandButton>
<apex:outputfield value="{!obj.LoginURL__c}"/>
</apex:commandButton>
</apex:column>
If this post answers your questions Please mark it as solved and give kudos for this post
Thanks
All Answers
Hi
Try in this way ..
<apex:column >
<apex:commandButton>
<apex:outputfield value="{!obj.LoginURL__c}"/>
</apex:commandButton>
</apex:column>
If this post answers your questions Please mark it as solved and give kudos for this post
Thanks
As requested, this got me pointed in the right direction. Thanks!!