Hippo Forms Redirect

159 views
Skip to first unread message

riaz...@gmail.com

unread,
Oct 20, 2014, 10:22:37 AM10/20/14
to hippo-c...@googlegroups.com
Hi all,

I'm very new to Hippo CMS and just getting a feel of the product. I've searched the forum for my problem but perhaps I'm not doing something correct.
Basically I'm trying to submit a form which redirects to a different page that should retrieve the previously submitted form details and display them. I've seen the easyforms plugin and can see that the form is submitted to redirected to the same sitemapitem. I'll try and explain how my approach differs

1. submit form to sitemapitem:register
2. register is configured with componentconfigurationid [hst:pages/register]
3. [hst:pages/register] is configured with componentclassname [com.acme.RegisterComponent]
4. sitemapitem:survey is configured with componentconfigurationid [hst:pages/survey]
5. [hst:pages/survey] is configured with componentclassname [com.acme.SurveyComponent]

The doAction method in RegisterComponent redirects to "/site/survey?"+request.getReferenceNamespace()+":"+FormUtils.DEFAULT_UUID_NAME+"="+UUID so that it has the expected path with the form UUID.

Now when the redirect occurs, the UUID fails to resolve as the reference namespace returned from request.getReferenceNamespace() is different to the one that is passed in the URL. I'm assuming this is due to the use of different components.

So my question is what is the correct way to submit a form that redirects to a different sitemapitem that references a different page that uses a different component such that the form can be retrieved?

Thanks

Tobias Jeger

unread,
Oct 20, 2014, 10:46:31 AM10/20/14
to hippo-c...@googlegroups.com
Hi,

I guess that you would avoid the component-specific parameter name-spacing when handling your form-data on a different component (or even page in your use-case). AFAIK, the parameter name-spacing is only there to avoid collisions if multiple components on your page "try to set" the same URL parameter name. But I may be wrong there...

cheers

Tobi



--
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.



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 101 Main Street, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

riaz...@gmail.com

unread,
Oct 20, 2014, 10:52:51 AM10/20/14
to hippo-c...@googlegroups.com
Hi Tobi,

Thanks for the quick response. Do you mean turn off the parameter name-spacing?

Tobias Jeger

unread,
Oct 20, 2014, 11:09:35 AM10/20/14
to hippo-c...@googlegroups.com
at least for this specific case, yes.

Woonsan Ko

unread,
Oct 20, 2014, 11:13:29 AM10/20/14
to hippo-c...@googlegroups.com
The reference namespace is the window reference name of the current
runtime page (/register), not the page of /survey. So, the reference
namespace cannot be used in the /survey page.
Also, there's no way you can know the specific reference name of a
component in the next page.

>
> So my question is what is the correct way to submit a form that
> redirects to a different sitemapitem that references a different page
> that uses a different component such that the form can be retrieved?

If you want to pass the UUID to allow a component in the next page to
read (for form reading), then you can simply redirect to something like
/site/survey?"+FormUtils.DEFAULT_UUID_NAME+"="+UUID.
Then, in the survey component you can read it by using the following method:

org.hippoecm.hst.component.support.bean.BaseHstComponent.getPublicRequestParameter(HstRequest,
String)

HTH,

Woonsan

>
> Thanks
>
> --
> 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
> <mailto: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

Woonsan Ko

unread,
Oct 20, 2014, 11:16:24 AM10/20/14
to hippo-c...@googlegroups.com
On 10/20/14 10:52 AM, riaz...@gmail.com wrote:
> Hi Tobi,
>
> Thanks for the quick response. Do you mean turn off the parameter
> name-spacing?

You don't have to turn it off.
In you case, you can read it by invoking the following method after
sending it without namespace reference prefix (see my other reply):

org.hippoecm.hst.component.support.bean.BaseHstComponent#getPublicRequestParameter(HstRequest,
FormUtils.DEFAULT_UUID_NAME);

HTH,

Woonsan


>
> On Monday, October 20, 2014 3:46:31 PM UTC+1, t.jeger wrote:
>
> Hi,
>
> I guess that you would avoid the component-specific parameter
> name-spacing when handling your form-data on a different component
> (or even page in your use-case). AFAIK, the parameter name-spacing
> is only there to avoid collisions if multiple components on your
> page "try to set" the same URL parameter name. But I may be wrong
> there...
>
> cheers
>
> Tobi
>
>
>
> On Mon, Oct 20, 2014 at 4:22 PM, <riaz...@gmail.com <javascript:>>
> <javascript:>
> RSS:
> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> <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
> <javascript:>.
> <http://groups.google.com/group/hippo-community>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
>
>
> --
> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
> Boston - 101 Main Street, Cambridge, MA 02142
>
> US +1 877 414 4776 (toll free)
> Europe +31(0)20 522 4466
> www.onehippo.com <http://www.onehippo.com/>
>
> --
> 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
> <mailto: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

riaz...@gmail.com

unread,
Oct 21, 2014, 4:19:15 AM10/21/14
to hippo-c...@googlegroups.com
Hi Woonsan,

Thank you for responding so quickly.

I'm not sure that your approach will work due to the fact that within doAction method of the RegisterComponent I'm using FormUtils.persistFormMap to temporarily save the form. Then from the doRender method of the SurveyComponent I'm using FormUtils.populateFormMap to retrieve the form. However, due to the namespaces differing, the formMap isn't populated as the UUID cannot be resolved.

Tobias Jeger

unread,
Oct 21, 2014, 5:12:56 AM10/21/14
to hippo-c...@googlegroups.com
you say "due to the namespaces differing [...]". What makes you think that the problem is there? I'd expect that the UUID (which is unique in your repository, and hence also unique in your /formdata store) is sufficient to retrieve the form data.

cheers

Tobi

To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.



--

riaz...@gmail.com

unread,
Oct 21, 2014, 5:20:25 AM10/21/14
to hippo-c...@googlegroups.com
Hi Tobi,

Maybe I'm wrong, but stepping through FormUtils.populateFormMap(...), it is unable to retrieve the UUID parameter from the request (request.getParameter(DEFAULT_UUID_NAME) )

Stepping furthing into the code, the HstRequestImpl.getParameter(String name) delegates the retrieval of the parameter to getParameterMap().get(String)and the getParameterMap() method is what uses the reference namespace.

Admittedly I can retrieve the repository node that holds the form data using the UUID but how then can I populate the formMap?

Thanks
> 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 - 101 Main Street, Cambridge, MA 02142
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

--
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.

Woonsan Ko

unread,
Oct 21, 2014, 9:38:35 AM10/21/14
to hippo-c...@googlegroups.com
Hi,

I see now the problem. HstRequest is directly used in FormUtils to read
the parameter.
However, I think you can use the following method instead:

org.hippoecm.hst.component.support.forms.FormUtils#populate(HttpServletRequest,
FormMap);

So, instead of passing HstRequest instance, if you pass the container
request, then it might work:

FormUtils.populate(RequestContextProvider.get().getServletRequest(),
formMap);

Could you try this?

Thanks,

Woonsan

On 10/21/14 5:20 AM, riaz...@gmail.com wrote:
> Hi Tobi,
>
> Maybe I'm wrong, but stepping through FormUtils.populateFormMap(...), it
> is unable to retrieve the UUID parameter from the request
> (request.getParameter(DEFAULT_UUID_NAME) )
>
> Stepping furthing into the code, the HstRequestImpl.getParameter(String
> name) delegates the retrieval of the parameter to
> getParameterMap().get(String)and the getParameterMap() method is what
> uses the reference namespace.
>
> Admittedly I can retrieve the repository node that holds the form data
> using the UUID but how then can I populate the formMap?
>
> Thanks
>
> On Tuesday, October 21, 2014 10:12:56 AM UTC+1, t.jeger wrote:
>
> you say "due to the namespaces differing [...]". What makes you
> think that the problem is there? I'd expect that the UUID (which is
> unique in your repository, and hence also unique in your /formdata
> store) is sufficient to retrieve the form data.
>
> cheers
>
> Tobi
>
> On Tue, Oct 21, 2014 at 10:19 AM, <riaz...@gmail.com <javascript:>>
> wrote:
>
> Hi Woonsan,
>
> Thank you for responding so quickly.
>
> I'm not sure that your approach will work due to the fact that
> within doAction method of the RegisterComponent I'm using
> FormUtils.persistFormMap to temporarily save the form. Then from
> the doRender method of the SurveyComponent I'm using
> FormUtils.populateFormMap to retrieve the form. However, due to
> the namespaces differing, the formMap isn't populated as the
> UUID cannot be resolved.
>
> On Monday, October 20, 2014 4:16:24 PM UTC+1, w.ko wrote:
>
> On 10/20/14 10:52 AM, riaz...@gmail.com wrote:
> > Hi Tobi,
> >
> > Thanks for the quick response. Do you mean turn off the
> parameter
> > name-spacing?
>
> You don't have to turn it off.
> In you case, you can read it by invoking the following
> method after
> sending it without namespace reference prefix (see my other
> reply):
>
> org.hippoecm.hst.component.__support.bean.BaseHstComponent#__getPublicRequestParameter(__HstRequest,
> to"/site/survey?"+request.__getReferenceNamespace()+":"+__FormUtils.DEFAULT_UUID_NAME+"=__"+UUID
>
> > so that it has the expected path with the form UUID.
> >
> > Now when the redirect occurs, the UUID fails to
> resolve as the
> > reference namespace returned from
> > request.getReferenceNamespace(__) is different to
> the one that is
> > passed in the URL. I'm assuming this is due to the
> use of
> > different components.
> >
> > So my question is what is the correct way to
> submit a form that
> > redirects to a different sitemapitem that
> references a different
> > page that uses a different component such that the
> form can be
> > retrieved?
> >
> > Thanks
> >
> > --
> > 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
> > <javascript:>
> > RSS:
> >
> https://groups.google.com/__group/hippo-community/feed/__rss_v2_0_msgs.xml?num=50
> <https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50>
>
> >
> <https://groups.google.com/__group/hippo-community/feed/__rss_v2_0_msgs.xml?num=50
> <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
> > <javascript:>.
> > Visit this group at
> > http://groups.google.com/__group/hippo-community
> <http://groups.google.com/group/hippo-community>
> > <http://groups.google.com/__group/hippo-community
> <http://groups.google.com/group/hippo-community>>.
> > For more options, visit
> https://groups.google.com/d/__optout
> <https://groups.google.com/d/optout>
> > <https://groups.google.com/d/__optout
> <https://groups.google.com/d/optout>>.
> >
> >
> >
> >
> > --
> > Amsterdam - Oosteinde 11, 1017 WT Amsterdam
> > Boston - 101 Main Street, Cambridge, MA 02142
> >
> > US +1 877 414 4776 (toll free)
> > Europe +31(0)20 522 4466
> > www.onehippo.com <http://www.onehippo.com>
> <http://www.onehippo.com/>
> >
> > --
> > 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
> <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
> > <mailto:hippo-communit...@googlegroups.com>.
> > Visit this group at http://groups.google.com/__group/hippo-community
> <http://groups.google.com/group/hippo-community>.
> > For more options, visit https://groups.google.com/d/__optout
> <https://groups.google.com/d/optout>.
>
>
> --
> w....@onehippo.com www.onehippo.com
> <http://www.onehippo.com>
> Boston - 101 Main Street, Cambridge, MA 02142
> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
> US +1 877 414 4776 (toll free)
> Europe +31(0)20 522 4466
>
> --
> 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
> <mailto:hippo-communi...@googlegroups.com>.

riaz...@gmail.com

unread,
Oct 21, 2014, 10:40:02 AM10/21/14
to hippo-c...@googlegroups.com
Hi Woonsan,

I actually got it working but in a very crude manner by configuring a redirect page in the repo and using it within the component as shown below:

            String requestNs = request.getReferenceNamespace();
            String ns = mount.getHstSite().getComponentsConfiguration().getComponentConfiguration(
                getComponentLocalParameter("redirectPage")).getReferenceName();
            requestNs = requestNs.replaceAll(requestNs.split("_")[0],ns);
            response.sendRedirect("/site/survey?"+requestNs+":"+FormUtils.DEFAULT_UUID_NAME+"="+sfr.getUuid());

However, I'm pleased to say that your suggested approach has solved the problem. I can pass the UUID without using a namespace and I do not need to set ignore.namespace to true in hst-config.properties.

           response.sendRedirect("/site/survey?"+FormUtils.DEFAULT_UUID_NAME+"="+sfr.getUuid()); //RegisterComponent.java
and
           FormUtils.populate(request.getRequestContext().getServletRequest(), map); //SurveyComponent.java

Thank you very much.
>             > <mailto:hippo-community+__unsub...@googlegroups.com>.

Woonsan Ko

unread,
Oct 21, 2014, 10:47:02 AM10/21/14
to hippo-c...@googlegroups.com
That's great! I'm very glad to see it working as well.

Cheers,

Woonsan
> <https://groups.google.com/__group/hippo-community/feed/__rss_v2_0_msgs.xml?num=50>
>
> >
> <https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> <https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50>>
>
> >
> > >
> >
> <https://groups.google.com/__group/hippo-community/feed/__rss_v2_0_msgs.xml?num=50
> <https://groups.google.com/__group/hippo-community/feed/__rss_v2_0_msgs.xml?num=50>
>
> >
> <https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> <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
> > > <javascript:>.
> > > Visit this group at
> > >
> http://groups.google.com/__group/hippo-community
> <http://groups.google.com/__group/hippo-community>
> > <http://groups.google.com/group/hippo-community
> <http://groups.google.com/group/hippo-community>>
> > >
> <http://groups.google.com/__group/hippo-community
> <http://groups.google.com/__group/hippo-community>
> > https://groups.google.com/d/__optout
> <https://groups.google.com/d/__optout>
> > <https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>>
> > > <https://groups.google.com/d/__optout
> <https://groups.google.com/d/__optout>
> > <https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>>>.
> > >
> > >
> > >
> > >
> > > --
> > > Amsterdam - Oosteinde 11, 1017 WT Amsterdam
> > > Boston - 101 Main Street, Cambridge, MA 02142
> > >
> > > US +1 877 414 4776 (toll free)
> > > Europe +31(0)20 522 4466
> > > www.onehippo.com <http://www.onehippo.com>
> <http://www.onehippo.com>
> > <http://www.onehippo.com/>
> > >
> > > --
> > > 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
> <https://groups.google.com/__group/hippo-community/feed/__rss_v2_0_msgs.xml?num=50>
>
> >
> <https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> <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
> <http://googlegroups.com>
> > >
> <mailto:hippo-communit...@googlegroups.com <javascript:>>.
> <http://groups.google.com/__group/hippo-community>
> https://groups.google.com/d/__optout
> <https://groups.google.com/d/__optout>
> > <https://groups.google.com/d/optout
> > www.onehippo.com <http://www.onehippo.com>
> <http://www.onehippo.com/>
> >
> > --
> > 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
> <javascript:>
> > RSS:
> >
> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> <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 <javascript:>
> > <mailto:hippo-communi...@googlegroups.com <javascript:>>.
> w....@onehippo.com <javascript:> www.onehippo.com
> <http://www.onehippo.com>
> Boston - 101 Main Street, Cambridge, MA 02142
> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
> US +1 877 414 4776 (toll free)
> Europe +31(0)20 522 4466
>
> --
> 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
> <mailto:hippo-communi...@googlegroups.com>.
Reply all
Reply to author
Forward
0 new messages