hst:actionUrl tag doesn't handle parameters

152 views
Skip to first unread message

Martijn van der Vorst

unread,
Nov 4, 2015, 8:34:11 AM11/4/15
to Hippo Community
Hello,

I am trying to pass a parameter to an actionUrl, however this parameter doesn't seem to get properly picked up.
Some technical detail below:

Let's say we enter the page on relative path: 
/the/page/with/form?param=A

We try to crerate an actionUrl for that component, this gives us the following URL:
/mijn-randstad/werkgevers/aanvragen-eigenwerving?_hn:type=action&_hn:ref=r150_r1_r1_r2&param=A&r150_r1_r1_r2:

now we try to pass the param with the <hst:param> tag:

<hst:actionURL var="formSubmitURL">
  <hst:param name="param" value="B"/>
</hst:actionURL>

that returns the following URL:

/mijn-randstad/werkgevers/aanvragen-eigenwerving?_hn:type=action&amp;_hn:ref=r150_r1_r1_r2&amp;param=A&amp;r150_r1_r1_r2:param=B

what I find interesting, and frustrating is that the original param is in the middle of the actionURL parameters, and that the newly appointed parameter is concatenated to the end of the URL without using the usual & connection.

Is this intended behaviour, and if so, are there ways to have it work by replacing and/or adding the param specified with the <hst:param> tag?

Kind regards,
Martijn van der Vorst

marijan milicevic

unread,
Nov 4, 2015, 8:44:21 AM11/4/15
to hippo-c...@googlegroups.com
Hi Martijn,

which version are you using? in case of v 10, this might be useful:


cheers
marijan
 
--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-c...@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
Visit this group at http://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.

Berkhan Dipso

unread,
Nov 4, 2015, 9:02:14 AM11/4/15
to Hippo Community
I think it is the intended behavior (Because of Wicket framework).

You should be able to fetch your parameter value in doAction() event.

    @Override
    public void doAction(HstRequest request, HstResponse response)
            throws HstComponentException {
        String param = this.getPublicRequestParameter(request, "param");
        ...

Martijn van der Vorst

unread,
Nov 4, 2015, 9:32:11 AM11/4/15
to Hippo Community
Hi,

indeed I can, but that gives me the old value, not the new one that I'm trying to set.
Also I looked at the "escapeXml" field, and sadly this does not fix the issue.

Woonsan Ko

unread,
Nov 4, 2015, 10:04:01 AM11/4/15
to hippo-c...@googlegroups.com
Hi Martijn,

I'd like to recommend you always try to use form parameters in POST method with hst:actionURL.
The reason is that single component is supposed to be executed in ACTION phase and multiple components in hierarchy are rendered/aggregated in RENDER phase. So namespaced parameters are really meaningful in RENDER phase.
In the render phase, HstRequest#getParameter(name) always to try to read namespaced parameter (e.g, r1_r2:p1) while in ACTION phase, HstRequest#getParameter(name) always to try to read unnamespaced parameter (e.g, p1) only in POST method.
Also, if you have multiple parameters with the same name in both query parameters and post form field params, servlet container may behave unexpectedly.
So, I would refrain from using <hst:param/> (which ends up adding query params instead of form post params) when invoking ACTION urls with a form. I would rather add that parameter only in form (e.g, hidden input field), with avoiding the same name as any other query|form params.

Regards,

Woonsan


--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-c...@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
Visit this group at http://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.



--
w....@onehippo.com     www.onehippo.com
Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

Ard Schrijvers

unread,
Nov 6, 2015, 6:14:07 AM11/6/15
to hippo-c...@googlegroups.com
On Wed, Nov 4, 2015 at 4:03 PM, Woonsan Ko <w....@onehippo.com> wrote:
> Hi Martijn,
>
> I'd like to recommend you always try to use form parameters in POST method
> with hst:actionURL.

It is not only a recommendation any more in CMS 10. In the upgrade
documentation we have:

*************************************************************************************
ActionURL in HTML FORM must have method post

This is a result of HSTTWO-1831 : actionURL is hard for infra to
support in combination with https filter and proxies. Also see Forms
and the HST ActionURL. Although an actionURL in a HTML form should
have hadmethod="post" even for pre CMS 10.0 versions since an
actionURL is not idempotent, it still used to work withmethod="get".
This is not allowed any more with CMS 10.0 and higher : An actionURL
in a HTML form must be of shape:

In a JSP template:

<hst:actionURL var="actionLink" />
<form action="${actionLink}" method="post">
<!-- form fields here -->
</form>

In a Freemarker template:

<@hst.actionURL var="actionLink"/>
<form action="${actionLink}" method="post">
<!-- form fields here -->
</form>
In html form with actionURL, method must be "post" (or "POST"). "get"
is not allowed
*************************************************************************************

Also see the public documentation at [1] where it is written that it
must be a post

HTH,

Regards Ard

[1] http://www.onehippo.org/library/concepts/component-development/hst-2-forms.html
Hippo Netherlands, Oosteinde 11, 1017 WT Amsterdam, Netherlands
Hippo USA, Inc.- 745 Atlantic Ave, Eight Floor, Boston MA 02111,
United states of America.

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com
Reply all
Reply to author
Forward
0 new messages