Dear Sir,
FYI...I have done it through the following way.
My solution...
controller.xml
_____________________
<request-map uri="goToWebsite">
<security https="true" auth="true"/>
<event type="java"
path="com.akm.exim.events.CallExternalWebsite"
invoke="callExternalWebsite"/>
<response name="success" type="url-redirect" value="DomCustomerList"/>
<response name="error" type="view" value="errorPage"/>
</request-map>
_____________________
CallExternalWebsite java file
----------------------------------
public class CallExternalWebsite {
public static final String module = CallExternalWebsite.class.getName();
public static String callExternalWebsite(HttpServletRequest request,
HttpServletResponse response) {
Map<String, Object> parameters = UtilHttp.getParameterMap(request); //
To get parameters from ftl file
String url = parameters.get("customerWebsite").toString().trim();
String os = System.getProperty("os.name").toLowerCase();
Runtime rt = Runtime.getRuntime();
Debug.logInfo("=======url=========", url);
try {
if (os.indexOf( "win" ) >= 0) {
rt.exec( "rundll32 url.dll, FileProtocolHandler " + url);
//pls read this. this opens up new browser window
} else if (os.indexOf( "mac" ) >= 0) { // for Mac
rt.exec( "open " + url);
}
else if (os.indexOf( "nix") >=0 || os.indexOf( "nux") >=0) { // for unix
String[] browsers = {"epiphany", "firefox", "mozilla",
"konqueror", "netscape","opera","links","lynx"};
StringBuffer cmd = new StringBuffer();
for (int i=0; i<browsers.length; i++)
cmd.append( (i==0 ? "" : " || " ) + browsers[i] +" \"" +
url + "\" ");
rt.exec(new String[] { "sh", "-c", cmd.toString() });
} else {
request.setAttribute("_EVENT_MESSAGE_", url);
}
}
catch (Exception e) {
String errMsg = "Unable to open url." + e.toString();
request.setAttribute("_ERROR_MESSAGE_", errMsg);
return "error";
}
return "success";
}
}
----------------------------------
Form
-------------------------------
<form name="FindDomesticCustomers" type="single"
target="FindDomesticCustomers" default-entity-name="AkmCustomer"
header-row-style="header-row" default-table-style="basic-table">
<field name="customerTypeId"><hidden value="Domestic"/></field>
<!-- The above field customerTypeId is passed hidden with
value 'Domestic' is like the following sql statement
select * from AkmCustomer where customerTypeId = "Domestic" -->
<field name="noConditionFind"><hidden value="Y"/></field>
<!-- if the above "noConditionFind" field name isn't there
then with all fields empty no query will be done -->
<field name="customerId" title="${uiLabelMap.customerId}">
<drop-down allow-empty="true">
<entity-options description="${customerId} - ${companyName}"
key-field-name="customerId"
entity-name="AkmCustomer">
<entity-constraint name="customerTypeId" operator="equals" value="Domestic"/>
<entity-order-by field-name="customerId"/>
</entity-options>
</drop-down>
</field>
<field name="customerContactPerson"
title="${uiLabelMap.customerContactPerson}"><text-find
ignore-case="true"/></field>
<field name="searchButton" title="${uiLabelMap.CommonFind}"
widget-style="smallSubmit">
<submit button-type="button"
image-location="/images/icons/magnifier.png"/>
</field>
</form>
-------------------------------
List view form
---------------------------------
<form name="ListDomesticCustomers" type="list" list-name="listIt"
paginate-target="FindDomesticCustomers"
default-entity-name="AkmCustomer" separate-columns="true"
odd-row-style="alternate-row"
header-row-style="header-row-2"
default-table-style="basic-table hover-bar">
<actions>
<service service-name="performFind" result-map="result"
result-map-list="listIt">
<field-map field-name="inputFields" from-field="eximCtx"/>
<field-map field-name="entityName" value="AkmCustomer"/>
<field-map field-name="orderBy" from-field="parameters.sortField"/>
<field-map field-name="viewIndex" from-field="viewIndex"/>
<field-map field-name="viewSize" from-field="viewSize"/>
</service>
</actions>
<field name="customerWebsite" title="${uiLabelMap.customerWebsite}">
<hyperlink target="goToWebsite"
description="${customerWebsite}" also-hidden="false">
<parameter param-name="customerWebsite"/>
</hyperlink>
</field>
</form>
---------------------------------
Result: on find... the table shows up the rows. on clicking the
customerWebsite on each row, it is opening up a new window and taking
me to the respective url.
Thank you for your kind help.
regards
Avijit
On Sat, May 7, 2022 at 1:18 PM Jacques Le Roux
<[email protected]> wrote:
>
> Hi,
>
> That's why I recommended initially to read the "documentation", ie the
> related content in site-conf.xsd:
>
> <xs:enumeration value="url">
> <xs:annotation>
> <xs:documentation>
> Any URL, relative or absolute. Redirected
> parameters are not used, you can put them in the url.
> </xs:documentation>
> </xs:annotation>
> </xs:enumeration>
> <xs:enumeration value="url-redirect">
> <xs:annotation>
> <xs:documentation>
> Works like URL but you can also pass
> redirected parameters.
> </xs:documentation>
> </xs:annotation>
> </xs:enumeration>
>
> As you can see these features don't allow dynamic URLs. What you can do is
> something like:
>
> <actions>
> <set field="targetUrl"
> value="https://github.com/apache/ofbiz-framework"/> (here you need to
> dynamically set the value, like by using
> "${groovy:........", see examples in code - none about URL though)
> </actions>
>
> [...]
>
> <field name="supplierWebsite" title="${uiLabelMap.supplierWebsite}">
> <hyperlink target="${targetUrl}" target-window="_BLANK"
> description="${supplierWebsite}" also-hidden="false"/>
> </field>
>
> I did not try it, but it should work.
>
> HTH
>
> Jacques
>
> Le 07/05/2022 à 05:52, Avijit Bose a écrit :
> > Hello Sir,
> >
> > Your "<response name="success" type="url"
> > value="https://github.com/apache/ofbiz-framework"/>" is working. It is
> > going to the external site, but the value is hard coded as
> > "https://github.com/apache/ofbiz-framework".
> >
> > I am trying to set this value like this....but unable to set the
> > supplierWebsite value in the "value" field.
> >
> > <request-map uri="goToWebsite">
> > <security https="true" auth="true"/>
> > <response name="success" type="url" value="supplierWebsite">
> > <redirect-parameter name="supplierWebsite"/>
> > </response>
> > </request-map>
> >
> > My form is like this...
> >
> > <field name="supplierWebsite" title="${uiLabelMap.supplierWebsite}">
> > <hyperlink target="goToWebsite" target-window="_BLANK"
> > description="${supplierWebsite}" also-hidden="false">
> > <parameter param-name="supplierWebsite"/>
> > </hyperlink>
> > </field>
> >
> > How can I set dynamic value in the "value" attribute of the "response"
> > tag? Pls help.
> >
> > On Fri, May 6, 2022 at 12:46 PM Jacques Le Roux
> > <[email protected]> wrote:
> >> Hi,
> >>
> >> You can do something like that in your controller
> >>
> >> <request-map uri="testUrl">
> >> <security https="true" auth="true"/>
> >> <response name="success" type="url"
> >> value="https://github.com/apache/ofbiz-framework"/>
> >> </request-map>
> >>
> >> Jacques
> >>
> >> Le 06/05/2022 à 03:11, Avijit Bose a écrit :
> >>> Dear Sir,
> >>>
> >>> Unable to do so. Pls help with the code.
> >>>
> >>> regards
> >>> Avijit
> >>>
> >>> On Thu, May 5, 2022 at 11:52 AM Jacques Le Roux
> >>> <[email protected]> wrote:
> >>>> Hi Avijit
> >>>>
> >>>> TL;DR: use the "url" response type
> >>>>
> >>>> You could have helped yourself. If you look into a controller file you
> >>>> will see its related schemaLocation: site-conf.xsd
> >>>>
> >>>> In site-conf.xsd you can find under response element (for reques-map
> >>>> element) the possible types, "url" is there explained.
> >>>>
> >>>> A faster way, if you use an IDE (I guess you do), is to hover over the
> >>>> reques-map response type and you will see "url", though there there is no
> >>>> explanation shown
> >>>>
> >>>> HTH
> >>>>
> >>>> Jacques
> >>>>
> >>>> Le 05/05/2022 à 03:59, Avijit Bose a écrit :
> >>>>> Hello,
> >>>>>
> >>>>> My form list is as follows:
> >>>>> ----------------------------------------------------------------------------------------------------------------------------
> >>>>> <form name="ListSuppliers" type="list" list-name="listIt"
> >>>>> paginate-target="FindSuppliers"
> >>>>> default-entity-name="AkmSupplier" separate-columns="true"
> >>>>> odd-row-style="alternate-row"
> >>>>> header-row-style="header-row-2"
> >>>>> default-table-style="basic-table hover-bar">
> >>>>> <actions>
> >>>>> <service service-name="performFind"
> >>>>> result-map="result"
> >>>>> result-map-list="listIt">
> >>>>> <field-map field-name="inputFields" from-field="eximCtx"/>
> >>>>> <field-map field-name="entityName" value="AkmSupplier"/>
> >>>>> <field-map field-name="orderBy" from-field="parameters.sortField"/>
> >>>>> <field-map field-name="viewIndex" from-field="viewIndex"/>
> >>>>> <field-map field-name="viewSize" from-field="viewSize"/>
> >>>>> </service>
> >>>>> </actions>
> >>>>>
> >>>>> <field name="supplierWebsite"
> >>>>> title="${uiLabelMap.supplierWebsite}">
> >>>>> <hyperlink target="external" description="${supplierWebsite}"
> >>>>> also-hidden="false">
> >>>>> <parameter param-name="supplierWebsite"/>
> >>>>> </hyperlink>
> >>>>> </field>
> >>>>> </form>
> >>>>> -----------------------------------------------------------------------------------------------------------------
> >>>>>
> >>>>> ${supplierWebsite} in the above form ishttp://www.abconsultancy.co.in
> >>>>> which is an external website.
> >>>>>
> >>>>> While clicking the above link in the form, it is taking through the
> >>>>> controller. I want to open the external website directly bypassing the
> >>>>> controller and in a different window.
> >>>>>
> >>>>> Pls help.
> >>>>>
> >>>>> regards
> >>>>> Avijit Bose