I have 50 different command links on a jsff page. I want to get the commandlink clicked in the backing bean? How to do this? I just have to use one single method in the backing bean
Write a listener and call the same listener on all of your command links. Inside the Listener Metod call event.getAttributes() which will return the Map of attributes. From the Map you can find the id property of the link submitted by the user.
Simply attach an actionListener:
<af:commandLink text="Command link 1" actionListener="#{bean.link1}"/>
<af:commandLink text="Command link 2" actionListener="#{bean.link2}"/>
<af:commandLink text="Command link 3" actionListener="#{bean.link3}"/>
...
The methods link1, link2, link3 etc. are called when you press the corresponding command link, so you implicitly know which link has been pressed.
Write a listener in backing bean , listener method will have "ActionEvent" as an argument.
ActionEvent has apis getSource(),getComponent(), which can be leveraged to get the commandlink clicked.
if you want to call 50 command link from backing bean,
you can queue them one after- see
Invoking Button Action Programmatically,Queuing ActionEvent
Related
I some links in my application which I want to track the click on those links with the help of GTM. Imagine I have a link to download page like this
<a ui-sref="main.download">Download</a>
I create a tag of type 'Universial Google Analytics' for this click named MainDownloadLink.
How should I define a trigger to fire this tag when that link is clicked? Also note that I don't want to use angularitics library. Imagine that I have no control over the source code. just GTM panel.
I define a trigger of type Clicks-Just Link and I am confused for the condition when this event should be fired.
any help is welcomed.
You must make sure that "link validation" is disabled (since GTM does not consider links without href to be valid).
As long as your links are actually named "Download" it probably would be easiest to use the built-in "click text" variable and set a filter "if click text equals download" on your link trigger.
Else you might want to try to access the "main.download" attribute. The built-in click element variable returns the clicked DOM element, so you'd create a custom variable
function() {
return {{Click Element}}.getAttribute('ui.sref');
}
and then test in your trigger if "{{your custom js var}} equals main.download".
Untested, but basically this should work.
Currently I have a two commandButtons:
one to execute a validation using actionlistener that populates a Return.inputValue
and another to move the return value from the previous listener to a
pageflowscope variable as below
<amx:commandButton text="commandButton1" id="cb4" action="godecide">
<amx:setPropertyListener from="#{bindings.Return.inputValue}" type="action" to="#{pageFlowScope.ReturnValue}"/>
</amx:commandButton>
<amx:commandButton actionListener="#{bindings.CheckUser.execute}" text="CheckUser"
disabled="#{!bindings.CheckUser.enabled}" id="cb3"/>
How can achieve this with one command button please?
I think you can call a method in the button action and within that method take the value from Return, set this value whenever you want and then redirect the page to some other page. As you want to have this value in pageFlowScope, define the scope of the bean in adfc-config as pageFlow or I thing Session should be fine as well.
There are two approaches:
Do everything you need within the taskflow action. Thats the action you have described in first button, you can add method call, used in the second button as a listener.
Do all the job in your bean. Set actionListener in the button, that will handle all the work needed to be done.
In both cases you can keep propertyListener to set this value.
Give more details on the case, if you need further explanation.
in first command button execute method via action which will your required task and in actionListner pass that generated value to other manager that is fine.
by this you no need to use sesssion moreover session are havey.
I'm trying to solve a problem. I want that when a perform an action or function in the controller to be saved in the brose history. For example, I want to do this:
Type something in a textbox.
Click a link to call a function that will set the string I typed to a variable in $scope and save it at the browser history.
Do the same as the previous step with a different value.
If I click the "back" button from the browser, I want to display the first value I entered.
I have a very simple example of what I want but I don't know what do I have to add to be able to use the "back" and "forward" button from the browser.
http://jsfiddle.net/XMFua/
Thank you very much in advance!
You should use the $location service to set the URL. I don't know how to make it work on jsFiddle, however the following should work:
http://jsfiddle.net/marcenuc/BSDxG/
I have visualforce page CompetitorSearch.page that use CompSearchDummy__c as standard controller.
<apex:page StandardController="CompSearchDummy__c" extensions="CompetitorSearch">
If I am to add custom button on the page of CompSearchDummy, CompetitorSearch.page shows up for the page destination.
But I have Talent page which use Talent__c sObject and when I tried to add custom button and attempt to set destination, CompetitorSearch.page does not show up as an option because I did not set Talent__c as standard controller.
Is it possible to somehow add my CompetitorSearch.page link to Talent page?
If I understand your question correctly, you want to add an apex:commandButton to go to another page. When you were on the same page, it was just refreshing itself, but to go to another page, you need to specify an action in the apex:commandButton that points to a method in a controller extension that returns a PageReference for where you want to go. Like this:
<apex:commandButton action="{!gotoCompetitorSearch}" value="Competitor Search" />
public PageReference gotoCompetitorSearch() {
return Page.CompetitorSearch;
}
Note, if you don't really need a button or special logic and just want to go to another page, you can do this with just an apex:outputLink with no need for a controller extension, like this:
<apex:outputLink value="{!$Page.CompetitorSearch}">CompetitorSearch</apex:outputLink>
I'm writing a VisualForce page to replace an old legacy S-Control.
Originally the Custom S-Control was launched from a Custom Button, and it opened in a new browser window (The S-Control is type HTML, and the Custom Button has Behavior: Display in new window)
For certain old records, I want to do a similar thing from VisualForce.
So: Do HTML S-Controls have a URL that I can launch using a link? In which case, how do I figure out the URL?
Or:
Is there a way of embedding 'Custom Buttons' (that is, the buttons defined in "Setup->Customise->Account->Buttons and Links") into VisualForce pages? If so, I can embed the existing button that knows how to open the S-Control
Or:
Can you suggest some other way of doing this? Key features: Open an S-Control in a new window from VisualForce.
Thanks
Got an answer from this forum post courtesy of aballard:
Basically, the !Urlfor() function can be used to get the URL of an S-Control. So, you can use an outputLink like this:
<apex:outputLink value="{!UrlFor($SControl.my_scontrol_name)}"
target="_blank">Show SControl</apex:outputLink>
If you need to pass an object ID to the S-Control, you can add a second parameter that calls a propery on the custom controller, e.g:
<apex:outputLink value="{!UrlFor($SControl.my_scontrol_name, AccountID)}"
target="_blank">Show SControl</apex:outputLink>
... where AccountID is defined on the custom controller as public string getAccountID()
See also this blog post at SalesforceSource for more info on the UrlFor function.