You need to sign in to do that
Don't have an account?
Desk API
Use of apex:actionsupport with apex:commandButton
Hi everyone. I am trying to develop a VisualForce page which will allow users to selectively send Case attachments to an external service. The way I'm doing this is by selecting all ContentDocumentLinks related to the Case, then displaying them in a table with a "Send" button next to each one.
I thought about using apex:actionSupport as a way to store the ID of the specific ContentDocumentLink, however the variable I'm using to store the ContentDocumentLink is NULL after clicking.
Here is the relevant portion of my VF page:
And here is the relevant portion of my controller:
Any help would be greatly appreciated.
I thought about using apex:actionSupport as a way to store the ID of the specific ContentDocumentLink, however the variable I'm using to store the ContentDocumentLink is NULL after clicking.
Here is the relevant portion of my VF page:
<apex:pageBlockTable value="{!cdls}" var="cdl"> <apex:column> <apex:facet name="header">Documents</apex:facet> <apex:outputText value="{!cdl.ContentDocument.Title}"/> <apex:form> <apex:commandButton value="Send"> <apex:actionSupport event="onclick" action="{!sendCdl}"> <apex:param name="cdlToSend" value="{!cdl.Id}" assignTo="{!cdlToSend}"/> </apex:actionSupport> </apex:commandButton> </apex:form> </apex:column> </apex:pageBlockTable>
And here is the relevant portion of my controller:
public class SendToV1_Button { ... public Id cdlToSend {get; set;} ... public PageReference sendCdl() { System.debug(cdlToSend); return redirect(); } }
Any help would be greatly appreciated.
you can try using region it might solve it not 100% sure
<apex:pageBlockTable value="{!cdls}" var="cdl">
<apex:column>
<apex:facet name="header">Documents</apex:facet>
<apex:outputText value="{!cdl.ContentDocument.Title}"/>
<apex:form>
<apex:actionRegion>
<apex:commandButton value="Send">
<apex:actionSupport event="onclick" action="{!sendCdl}">
<apex:param name="cdlToSend" value="{!cdl.Id}" assignTo="{!cdlToSend}"/>
</apex:actionSupport>
</apex:commandButton>
</apex:actionRegion>
</apex:form>
</apex:column>
</apex:pageBlockTable>
if region did not work then action funcation will work
<apex:pageBlockTable value="{!cdls}" var="cdl">
<apex:column>
<apex:facet name="header">Documents</apex:facet>
<apex:outputText value="{!cdl.ContentDocument.Title}"/>
<apex:actionFunction action="{!sendCdl}" name="methodOneInJavascript">
<apex:param name="cdlToSend" assignTo="{!cdlToSend}" value="" />
</apex:actionFunction>
<apex:form>
<apex:actionRegion>
<apex:commandButton value="Send" onclick="MYJSFuncation({!cdl.Id})"/>
</apex:commandButton>
</apex:actionRegion>
</apex:form>
</apex:column>
</apex:pageBlockTable>
<script>
funcation MYJSFuncation(RecordId)
{
methodOneInJavascript(RecordId);
//return false; // if it do anything funny try return false
}
All Answers
you can try using region it might solve it not 100% sure
<apex:pageBlockTable value="{!cdls}" var="cdl">
<apex:column>
<apex:facet name="header">Documents</apex:facet>
<apex:outputText value="{!cdl.ContentDocument.Title}"/>
<apex:form>
<apex:actionRegion>
<apex:commandButton value="Send">
<apex:actionSupport event="onclick" action="{!sendCdl}">
<apex:param name="cdlToSend" value="{!cdl.Id}" assignTo="{!cdlToSend}"/>
</apex:actionSupport>
</apex:commandButton>
</apex:actionRegion>
</apex:form>
</apex:column>
</apex:pageBlockTable>
if region did not work then action funcation will work
<apex:pageBlockTable value="{!cdls}" var="cdl">
<apex:column>
<apex:facet name="header">Documents</apex:facet>
<apex:outputText value="{!cdl.ContentDocument.Title}"/>
<apex:actionFunction action="{!sendCdl}" name="methodOneInJavascript">
<apex:param name="cdlToSend" assignTo="{!cdlToSend}" value="" />
</apex:actionFunction>
<apex:form>
<apex:actionRegion>
<apex:commandButton value="Send" onclick="MYJSFuncation({!cdl.Id})"/>
</apex:commandButton>
</apex:actionRegion>
</apex:form>
</apex:column>
</apex:pageBlockTable>
<script>
funcation MYJSFuncation(RecordId)
{
methodOneInJavascript(RecordId);
//return false; // if it do anything funny try return false
}
If you like mark this as sovled i belive that will keep the community clean