4

I have a visualforce page with an apex:component in it. (This component is for headers, used in various other places).

<apex:page title="" ... >
<apex:form>
      <c: HeaderV2 />
</apex:form>
</apex:page>

Here's my component.

<apex:component controller="TemplateController" allowDML="true">
     <apex:commandLink action="{!UpdateABC}" />
</apex:component>

The commandLink doesn't work, because there is no Apex:form in the component. So, I add the apex:form to the component.

    <apex:component controller="TemplateController" allowDML="true">
         <apex:form>
               <apex:commandLink action="{!UpdateABC}" />
         </apex:form>
    </apex:component> 

Now, my whole page gives error because there are 2 apex:forms! (one from the page and the other from the component) How to resolve this?

3

Try using a tag that doesn't need to live inside a form (like an outputLink), and adding actionSupport to call the UpdateABC method. Something like:

<apex:outputLink>
    [link text here]
    <apex:actionSupport event="onclick" action="{!UpdateABC}"/> 
</apex:outputLink>
0

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.