• AC Slater
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
I'd like to be able to dynamically generate buttons on my Visualforce page. Once the user has clicked on one of the buttons, I'd like to redirect the user to a second page and display different information on that page depending on which button the user clicked on. I've poked through a number of posts on these boards and can't quite figure out how to accomplish this. These these posts seem close, but the solutions described require a 'reRender', which I don't want to deal with for reasons irrelevant to this discussion:

http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=1000  http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=1000

http://community.salesforce.com/sforce/board/message?board.id=Visualforce&thread.id=810

Here's a picture of what I'm trying to accomplish:
 


Here's my VF page:
Code:
<apex:page controller="SimpleRepeatController"> 
  <apex:form >
    <apex:pageBlock mode="edit" >
        Lorem Ipsum
        <apex:pageBlockButtons >
            <apex:repeat value="{!Users}" var="user" id="repeat">
                 <apex:commandButton action="{!NextPage}" id="cmdBtn" value="Select '{!user.Name}'">
                      <apex:param value="{!user.Id}" name="UserId"/>
                 </apex:commandButton>
            </apex:repeat>
        </apex:pageBlockButtons> 
    </apex:pageBlock>
  </apex:form>
</apex:page>


 Here's my controller:
Code:
public class SimpleRepeatController 
{
 public List<User> Users
 {
     get
     {  
      return [SELECT Id, Name
                       FROM User
                       WHERE Name != 'License Manager'
                       AND IsActive = true
                       ORDER BY LastName];
    }
 }
    
    public PageReference NextPage()
    {
     PageReference selectedUserResults = Page.SelectedUserResults;
     selectedUserResults.setRedirect(true);
     return selectedUserResults;
    }
}


Here's my second VF page:
Code:
<apex:page controller="SimpleRepeatController">
    Selected User: "{!$CurrentPage.parameters.UserId}"
</apex:page>

Unfortunately, the results are always:      

     Selected User: ""


Is there a better way to accomplish what I'm trying to do?

Thanks in advance!
I'd like to be able to dynamically generate buttons on my Visualforce page. Once the user has clicked on one of the buttons, I'd like to redirect the user to a second page and display different information on that page depending on which button the user clicked on. I've poked through a number of posts on these boards and can't quite figure out how to accomplish this. These these posts seem close, but the solutions described require a 'reRender', which I don't want to deal with for reasons irrelevant to this discussion:

http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=1000  http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=1000

http://community.salesforce.com/sforce/board/message?board.id=Visualforce&thread.id=810

Here's a picture of what I'm trying to accomplish:
 


Here's my VF page:
Code:
<apex:page controller="SimpleRepeatController"> 
  <apex:form >
    <apex:pageBlock mode="edit" >
        Lorem Ipsum
        <apex:pageBlockButtons >
            <apex:repeat value="{!Users}" var="user" id="repeat">
                 <apex:commandButton action="{!NextPage}" id="cmdBtn" value="Select '{!user.Name}'">
                      <apex:param value="{!user.Id}" name="UserId"/>
                 </apex:commandButton>
            </apex:repeat>
        </apex:pageBlockButtons> 
    </apex:pageBlock>
  </apex:form>
</apex:page>


 Here's my controller:
Code:
public class SimpleRepeatController 
{
 public List<User> Users
 {
     get
     {  
      return [SELECT Id, Name
                       FROM User
                       WHERE Name != 'License Manager'
                       AND IsActive = true
                       ORDER BY LastName];
    }
 }
    
    public PageReference NextPage()
    {
     PageReference selectedUserResults = Page.SelectedUserResults;
     selectedUserResults.setRedirect(true);
     return selectedUserResults;
    }
}


Here's my second VF page:
Code:
<apex:page controller="SimpleRepeatController">
    Selected User: "{!$CurrentPage.parameters.UserId}"
</apex:page>

Unfortunately, the results are always:      

     Selected User: ""


Is there a better way to accomplish what I'm trying to do?

Thanks in advance!