开发者

Visualforce link component for rerendering?

开发者 https://www.devze.com 2023-03-21 22:49 出处:网络
Is there a visualforce component for links? I\'d like a link () on my page which can trigger an ajax call to one of the functions in the controller and rerender an element on the page.

Is there a visualforce component for links? I'd like a link () on my page which can trigger an ajax call to one of the functions in the controller and rerender an element on the page.

This is how I'm doing it right now, but I don't want it to be a button,开发者_JAVA百科 I need a link:


There are two standard apex link components, an apex:outputLink and an apex:commandLink. Both render anchor tags in html. From what you are asking, it sounds like need the command link, but I've posted information about both of them here.

You can find out more about them in the Visualforce Developer's Guide.

The apex:outputLink should be used when you want to create a standard hyperlink:

This component is rendered in HTML as an anchor tag with an href attribute. Like its HTML equivalent, the body of an is the text or image that displays as the link. To add query string parameters to a link, use nested components.

 <apex:outputLink value="https://www.salesforce.com"
 id="theLink">www.salesforce.com</apex:outputLink>

The example above renders the following HTML:

 <a id="theLink" name="theLink"
 href="https://www.salesforce.com">www.salesforce.com</a>

The apex:commandLink is probably what you need.

... executes an action defined by a controller, and then either refreshes the current page, or navigates to a different page based on the PageReference variable that is returned by the action. An apex:commandLink component must always be a child of an apex:form component.

<apex:commandLink action="{!save}" value="Save" id="theCommandLink"/>

The example above renders the following HTML:

<a id="thePage:theForm:theCommandLink" href="#" onclick="generatedJs()">Save</a>
0

精彩评论

暂无评论...
验证码 换一张
取 消