This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Aug 18, 2011, 8:29 AM
26 Posts

Passing URL Parameters to xp:Link

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags: xp:link
  • Replies: 3
 Hi,
 
I have an xp:link on my xpage as shown below: 
 
<xp:link escape="true" text="Search" id="Search" styleClass="but_search" target="MainFrame" value="/xp_GlobalSearch.xsp">
</xp:link> 
 
 The requirement that I am having is that I need to append a couple of URL Parameters to the value attribute. Something like this:
 
<xp:link escape="true" text="Search" id="Search" styleClass="but_search" target="MainFrame" value="/xp_GlobalSearch.xsp?search=" + varSearch>
</xp:link> 
 
In the above, the varSearch would be dynamic value entered by the user on the UI. 
 
Can anyone guide me on this one? 
 
Thanks for your time. 
 
Regards, 
Yusuf 
Aug 18, 2011, 9:48 AM
272 Posts
Re: Passing URL Parameters to xp:Link
Hi.
 
Try this one:
 
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:link escape="true" text="Search" id="Search"
        styleClass="but_search" target="MainFrame">
        <xp:this.value><![CDATA[#{javascript:var urlParam = context.getUrlParameter("search");
            "/xp_GlobalSearch.xsp?search=" + urlParam;}]]></xp:this.value>
    </xp:link>
</xp:view>
 
 
Sven
Aug 18, 2011, 9:51 AM
272 Posts
Re: Passing URL Parameters to xp:Link
Or do you mean something like this? The first one adds a value from the URL to the link, this one adds a value to the link from the input box:
 
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

    <xp:div id="linkUpdate">
        <xp:link escape="true" text="Search" id="Search"
            styleClass="but_search" target="MainFrame">
            <xp:this.value><![CDATA[#{javascript:var urlParam = "";
try{
    urlParam = getComponent("inputText1").getValue();
}catch(e){}

"/xp_GlobalSearch.xsp?search=" + urlParam;}]]></xp:this.value>
        </xp:link>
       
   
    <xp:br></xp:br>

    <xp:inputText id="inputText1"></xp:inputText>
    <xp:button value="Label" id="button1">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="partial" refreshId="linkUpdate">
        </xp:eventHandler></xp:button>
       
    </xp:div>   
</xp:view
>
 
Sven
Aug 18, 2011, 11:19 AM
26 Posts
Re: Passing URL Parameters to xp:Link
 Hi Sven,
 
 Thanks for your input. I had tried getComponent("fieldname").getValue(), but I dont know for some reason it was just returning me null every time.  I finally did it using client side javascript as below:
 
<xp:link escape="true" text="Search" id="lkSearch" title="Search" styleClass="but_search">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[
document.getElementById("MainFrame").src = "/database.nsf/xp_GlobalSearch.xsp?search=" + document.getElementById("#{id:searchInput}").value]]></xp:this.script>
</xp:eventHandler>
</xp:link>
 
Thanks for your help. 
 
Regards, 
Yusuf 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal