0

I have a requirement where I have to create a popup (using addMessage) that display two options: confirm and cancel, each of these options has an action.

I already tried passing a command link in the variable of the addMessage like this:

ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Warning, '<apex:commandLink value="Confirm" action="{! addContact }" rendered="true" />'));

but it didn't work.

Someone could help me with this?

2
  • 2
    Please do not vandalize your posts. By posting on this site, you've irrevocably granted the Stack Exchange network the right to distribute that content under the CC BY-SA 4.0 license for as long as it sees fit to do so. For alternatives to deletion, see: I've thought better of my question; can I delete it?
    – Ollie
    Jun 10 at 22:21
  • I've rolled this post back to the version that was answered. Please do not deface it again.
    – David Reed
    Jun 10 at 22:53

1 Answer 1

0

You can't render a component this way. You could use Dynamic Visualforce, but this is probably overkill. I'd just use normal markup (you can add a message dynamically):

<apex:outputText rendered="{!showDialog}">
  {!message}
  <apex:commandButton label="Cancel" onclick="{!closeDialog}" />
  <apex:commandLink label="Confirm" onclick="{!confirmDialog}" />
</apex:outputText>

Which you'd then control via Apex:

showDialog = true;
message = 'Are you sure you want to create a new contact?';

You could even build this as a Visualforce Component for reusability on multiple pages or for multiple uses.

1
  • That's really not possible, I searched about every way to do that but without success, I will use normal markup, thanks for your help! Jun 3 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.