Redirect form data to another component

161 views
Skip to first unread message

Giacomo Lamonaco

unread,
May 30, 2016, 9:18:54 AM5/30/16
to Hippo Community
Hi all,
I'm having some troubles with hippo forms. Initially a defined a form in a specific page:

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

If I persist form data in the component (component-1),  I am able to retrieve data from the doBeforeRender() method:
Component-1.java
public void doAction(..)
{
..
FormMap map =
new FormMap(request, new String[]{"inputFieldName"});
FormUtils.persistFormMap(request, response, map, null);
..
}

public void doBeforeRender(..){
..
FormMap map = new FormMap();
FormUtils.populate(request, map);
..
}



Now I would to define a similar form that is rendered by another component (component-2): once this form has been submitted, I would to redirect form data from component-2 to component-1.
I tried to to store form data and then perform a sendRedirect 
Component-2.java

public void doAction(..) {
        ..
try {     
   HstLinkCreator linkCreator = request.getRequestContext().getHstLinkCreator();
   HstLink link = linkCreator.createByRefId("myRefId", request.getRequestContext().getResolvedMount().getMount());
   String location = link.toUrlForm(request.getRequestContext(), false);
   
   FormMap map = new FormMap(request, new String[]{"myData"});
   FormUtils.persistFormMap(request, response, map, null);
         
   response.sendRedirect(location);
} catch (IOException ex) {
   LOG.error("Error");
}
}

Unfortunately, from component-1 I'm not able to retrieve form data. 
Can you help me?

Thanks for your attention
Giacomo

marijan milicevic

unread,
May 30, 2016, 9:39:43 AM5/30/16
to hippo-c...@googlegroups.com
Hi,

you could try to add "u_u_i_d" parameter of your form to location object, so you could read form data again (unless you sealed your form data, in that case it is not readable anymore)

cheers
marijan

Thanks for your attention
Giacomo

--
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 https://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.

Giacomo Lamonaco

unread,
May 30, 2016, 10:31:35 AM5/30/16
to Hippo Community
Hi, 

thanks for your reply. I set the "u_u_i_d" parameter in component-2 using the response object
myParamtersMap.add(FormUtils.DEFAULT_UUID_NAME, ((HstResponseImpl) response).getRenderParameters().get(FormUtils.DEFAULT_UUID_NAME))

then, from component-1 I am able to retrieve form data from the servlet request (and not from the request it self !)

public void doBeforeRender(..){
FormMap map = new FormMap();
FormUtils.populate(request.getRequestContext().getServletRequest(), map);

Thanks!
Reply all
Reply to author
Forward
0 new messages