Redirect from any component to another page in adf - oracle-adf

Hello im new on af and I´m trying to redirect by clicking on any adf component to another page. But i dont want to use javascript only with adf and beans.
I have been looking for something similar to the onclick of javascript that you can use it on any html element and with a click you can invoke a function.
On my test i had tried to redirect to another page by clicking on a af:inputText like when i click on an af:link and execute the action with the name of the control flow case for navigate from one activity to another, looking on the documentation, the af:inputText doesn´t have any onclick/action event or something similar.
primera.jsff
<?xml version='1.0' encoding='UTF-8'?>
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<!--af:link When i click on it i get redirected to another jsff page on my project -->
<af:link text="link 1" id="link1" action="gonext"></af:link>
<!--I want a similar behavior here -->
<af:inputText label="Label 1" id="it1"/>
</ui:composition>
My task-flow has defined a control flow case from primera.jsff to a empty segunda.jsff named gonext
I just want the similar behavior on the af:inputText than on the af:link, but only using adf not javascript code. Thanks and sorry for the redaction.

Related

Service Cloud Toolkit API cannot be used with your browser - salesforce

Salesforce interaction/console methods not executed after redirecting to other URL in CTI console softphone. I have mapped the CTI Adapter URL(for ex: http://domain1:port1/xyz/test.jsp) in softphone layouts of the call center, the interaction/console methods get executed on that particular page.
Method Like :
sforce.interaction.runApex(...);
On click event I redirect to some other URL (for ex: http://domain1:port2/abc/test1.jsp) on this page interaction/console methods not executed.
Methods Like :
sforce.console.setCustomConsoleComponentPopoutable(...);
sforce.interaction.runApex(...);
On console - "Service Cloud Toolkit API cannot be used with your browser" appears after page redirects.
Please help with the scenario
This error is caused by the validation of sfdcOriginIframe and nounce properties when sending out the window message to the top window.
Actually this two properties are populated from the window.location.search field once the softphone loaded.this search field goes like :
?sfdcIFrameOrigin=https%3A%2F%2Fap5.salesforce.com&nonce=3c1d1c360732e6754323247e711324b86d027c3c2809abb163754069d02365c5&isAdapterUrl=true&
I think they come from the src of the iframe tag
<iframe
id="SoftphoneIframe"
name="SoftphoneIframe"
allow="camera *; geolocation *; microphone *"
src="/loadSoftphone.html?sfdcIFrameOrigin=https%3A%2F%2Fap5.salesforce.com&nonce=3c1d1c360732e6754323247e711324b86d027c3c2809abb163754069d02365c5&isAdapterUrl=true"
style="display: block;"
width="100%"
height="650"
frameborder="0"
></iframe>
if you redirect the location of your softphone frame, the search field is gone, and you can't use any methodes in interaction.js anymore.
so maybe there are two approaches to resolve this problem:
retain your search field in a hidden field and bring it ot your next page as a searchQuery string;
refresh your top window just before you redirect your softphone
sforce.interaction.refreshPage();
Finally I used the second solution to fix my problem.
Code sample

Grails: save to Database without page reloading

How can i save the textfields and checkboxes to the DB without reloading the page?
Just to click on the button and then its in the DB. Nothing more. I don't get it. This means when I have a textfield where I type in a content -> then click the button, the content from the textfield should be in the DB and should do nothing more (not reloading the page, or go to top for example).
I don't get it.
EDIT:
When I have a a <div> tag with the id="testid" in the standard create.gsp:
def create() {
def mytestInstance = new Mytest(params)
}
and the <g:remoteLink> which should save this part looks like:
<g:remoteLink class="button" name="myForm" update="testid"
url="[controller:'mytest', action: 'create']" value="....." />
That does not work because the page is refreshing or something like this and the things are not stored in the DB, plus they are not in the textfields any more.
Use <g:formRemote> or <g:submitToRemote> to do the form submission with an Ajax call.
You should be able to use the formRemote tag to send the data to a controller via Ajax
Edit
As it says on that page;
This tag also requires the use of either the <g:javascript/>(link) or <g:setProvider/>(link) tags. See the AJAX section of the user guide to find out more.
Have you done that?

Liferay: Showing Related Assets for Calendar Event in the list page

I'm working to customize liferay's Calendar portlet and have created a hook for this.
I want to show all the "Related Assets" associated with a Calendar Event directly in the list page itself where all the Events are displayed instead of the Event's detail view page.
Currently liferay shows the "Related Assets" only when we click on the Event to view the details of that Event.
Can anyone help me?
Environment: Liferay 6.1
Thanks a lot
Sabrina
I assume you already have liferay's source code and you know how to create a hook.
The JSPs you would be modifying would be in this path:
portal-web/docroot/html/portlet/calendar
So here are some steps to help you solve your query:
You need to modify the event_iterator.jspf: row.addText(event.getTitle(), rowURL);
You have to adjust the following code taken from view_event.jsp in event_iterator.jspf.
<%
AssetEntry layoutAssetEntry = AssetEntryLocalServiceUtil.getEntry(CalEvent.class.getName(), event.getEventId());
%>
<%-- <liferay-util:buffer> is a tag which stores all that is written inside
its body in a single variable string, in this case "relatedAssetsLinksBuffer"
--%>
<liferay-util:buffer var="relatedAssetsLinksBuffer">
<c:if test="<%= enableRelatedAssets %>">
<%=event.getTitle() %>
<div class="entry-links">
<liferay-ui:asset-links
assetEntryId="<%= layoutAssetEntry.getEntryId() %>"
/>
</div>
</c:if>
</liferay-util:buffer>
Now the line in step-1 becomes: row.addText(relatedAssetsLinksBuffer, rowURL);
I have not tried this but I think it would work or will atleast give you some help in solving your query.
Tip for Hooks (might be useful in future):
Liferay follows a convention in storing its JSPs, so for custom-jsps Hook (i.e. a hook created for modifying liferay's JSP) you just need to search for that particular JSP & modify it.
For Eg: You wanted to modify the first page of calendar portlet. So liferay portlet's first page is always view.jsp located in the folder with the same name as the portlet-name in this case "Calendar" and view.jsp will contain some tags like <%# include /> or <liferay-util:include /> which would include other files to show the content. So you can always start with a view.jsp and navigate ahead. By the way the names of the JSPs are also most of the time self-explanatory.
Hope this helps.

How to add a link to a jsp page in an adf tree node?

I have made an adf tree but I am not able to add links to each child node.
You didn't mentioned that whether or not you are in WebCenter Portal application. But if you are in Portal Application you can take help of NavigationContext for navigation, you can find more information and examples in the documentation. Also you can use NavigationContext from backing bean. You could define actionListener of your commandLink and from that method you can navigate to the various pages from backend as well as from the jspx page.
If you are not in Portal application, in Fusion Web Application you should define your navigation by control-flow-case of adfc-config.xml. Don't use FacesConfig for navigation. Read this documentation to know how navigation system works.
Since you are in a Tree Model and if you need to parameter then you can set some value to session as:
<af:tree value="#{ConnectorTest.model}" var="node" >
<af:commandLink text="#{node.text}" action="#{node.action}">
<af:setPropertyListener from="#{node.value}" to="#{sessionScope.value}" type="action"/>
</af:commandLink>
</af:tree>
here the action will be defined in adfc-config. If you don't need to pass parameter then ignore the af:setPropertyListener but you should define the action in config file.
Hope this will help.
Edit:
Suppose you have two pages: Page1.jspx and Page2.jspx. Now you need to define the action (specifically from-action) in adfc-config.xml as following way:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
<view id="p1">
<page>/path-to-the/Page1.jspx</page>
</view>
<view id="p2">
<page>/path-to-the/Page2.jspx</page>
</view>
<control-flow-rule>
<from-activity-id>p1</from-activity-id>
<control-flow-case>
<from-outcome>goToP2</from-outcome>
<to-activity-id>p2</to-activity-id>
</control-flow-case>
</control-flow-rule>
</adfc-config>
Now if you have a commandLink:
<af:commandLink id="link" action="goToP2" /> will navigate you to the Page2.jspx. The action attribute also accept el expression.
Have u mean to add hyperlink on child node?
<af:tree var="node" value="#{myBean.myTree.root}" id="t1" focusListener="#{myBean.eventMethod}">
<af:commandLink text="#{node.firstname}" />
</af:tree>
when u click on node it fire focus event and call method eventMethod that accepts FocusEvent obj as arguments, in this method u set navigation rule etc etc.....
try it
You can use the <af:switcher> tag, if you want to display different action, for different child nodes

Add a custom link/button to a visualforce page?

I have a custom link on the opportunity object which points to an external site. Is it possible to add this custom link to a visualforce page?
The solution I came up with was to copy the url salesforce creates for this custom link, and paste it in the page. It looks something like this:
my custom link
This works fine, however, it won't work once it's in a managed package installed on other servers because the lid param will be different (the custom link id). Is there a solution for this?
Have you thought about putting the URL of the link in a field on the opportunity object and then creating an output link on your VF page?
Paul
Look under $Action. Buttons and links are available via that global variable. For example $Action.Opportunity.CustomLink
To build off the answer from danieljimenez, the $Action global variable provides access to the button/link objects. From there you need to use the URLFOR function to get it into a usable form. Then you can either put it into the action param of a command button, or use it as you'd like anywhere else in your markup.
<apex:commandButton action="{!URLFOR($Action.My_Obj__c.My_custom_link)}" value="My custom button"/>
or
My link
create New Contact (Salesforce button target _blank)
<apex:commandLink target="_blank"
styleClass="btn"
style="text-decoration:none;padding:4px;"
action="{!URLFOR($Action.Contact.NewContact)}"
value="Create New Contact" />

Resources