• esbium99
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 8
    Replies

If you look at the Apex Language reference pdf, on page 278, you will see an example of how to invoke an action from within another action.  This sounds great in theory but doesn't work in practice.  All we get is a system error like this:

 

 

Salesforce System Error: 1598249974-2475 (-814351657) (-814351657) An unexpected error has occurred. Your solution provider has been notified. (ApexPages)  

 To save you time, here is the code:

 

Controller:

 

public with sharing class Page2Controller { private ApexPages.Action saveAction = new ApexPages.Action('{!onSave}'); public Page2Controller() { } public PageReference doSomething() { saveAction.invoke(); return null; } public void onSave() { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'why dont I work?')); } }

 

Page:

 

 

<apex:page controller="Page2Controller" sidebar="false" showHeader="false"> <apex:messages /> <apex:form > <apex:commandButton action="{!doSomething}" value="doSomething" /> </apex:form> </apex:page>

 

Any Ideas?  This seems so simple, I am not sure what is going on.

 

Thanks in advance for any help you can provide!

 

 

 

 

 

I am trying to develop a reusable component that contains some stylized buttons.  I want to include this component on all of the pages for a force.com app.  The problem I am running into is that I want to pass the action for the commandlink/commandbutton tag into the component as an attribute and its not working.  When I click a button that was included via the component with an action that was passed in, it just refreshes the page (via a post which, in the end, is what I want) and doesn't call my action.  I am pretty sure its refreshing because the action method I am passing isn't being interpreted correctly in the component but I am not sure.

 

 

I am wondering if I need to change the type of the attribute in the component but not sure what to change it to...

Here is some code to help explain (lots of things ommitted to keep it simple).

 

Page:

 

<div>Some html

<c:myComponent myAction="myCustomAction"/>

 

Component

 

<apex:component>

<apex:attribute name="myAction" required="true" type="String" description=""/>

     <apex:commandButton action="{!myAction}">My Button</apex:commandButton>

</apex:component>

 

Thanks for any help anyone can provide!

If you look at the Apex Language reference pdf, on page 278, you will see an example of how to invoke an action from within another action.  This sounds great in theory but doesn't work in practice.  All we get is a system error like this:

 

 

Salesforce System Error: 1598249974-2475 (-814351657) (-814351657) An unexpected error has occurred. Your solution provider has been notified. (ApexPages)  

 To save you time, here is the code:

 

Controller:

 

public with sharing class Page2Controller { private ApexPages.Action saveAction = new ApexPages.Action('{!onSave}'); public Page2Controller() { } public PageReference doSomething() { saveAction.invoke(); return null; } public void onSave() { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'why dont I work?')); } }

 

Page:

 

 

<apex:page controller="Page2Controller" sidebar="false" showHeader="false"> <apex:messages /> <apex:form > <apex:commandButton action="{!doSomething}" value="doSomething" /> </apex:form> </apex:page>

 

Any Ideas?  This seems so simple, I am not sure what is going on.

 

Thanks in advance for any help you can provide!

 

 

 

 

 

I am trying to develop a reusable component that contains some stylized buttons.  I want to include this component on all of the pages for a force.com app.  The problem I am running into is that I want to pass the action for the commandlink/commandbutton tag into the component as an attribute and its not working.  When I click a button that was included via the component with an action that was passed in, it just refreshes the page (via a post which, in the end, is what I want) and doesn't call my action.  I am pretty sure its refreshing because the action method I am passing isn't being interpreted correctly in the component but I am not sure.

 

 

I am wondering if I need to change the type of the attribute in the component but not sure what to change it to...

Here is some code to help explain (lots of things ommitted to keep it simple).

 

Page:

 

<div>Some html

<c:myComponent myAction="myCustomAction"/>

 

Component

 

<apex:component>

<apex:attribute name="myAction" required="true" type="String" description=""/>

     <apex:commandButton action="{!myAction}">My Button</apex:commandButton>

</apex:component>

 

Thanks for any help anyone can provide!

Any way to get the Name or Id of the current Visual Force page from within the controller class?
Message Edited by Vintara on 08-13-2009 01:06 PM