Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Server side validation - query

Avatar

Avatar
Boost 1
Level 1
harimst
Level 1

Like

1 like

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
harimst
Level 1

Like

1 like

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
harimst
Level 1

22-06-2018

I have a requirement to collect some info from casual visitor to the site (unauthenticated) using AEM Forms. On posting data to backend (custom rest endpoint), there may be some validation failures - in which case, the form should be rendered back to the user with the data filled in (whatever was just entered) along with an error message. The validation cannot be done from client side. I tried the 3 options below, none of them seem to work.

SlingHttpServletRequest wrappedErrorRequest = new CustomParameterRequest(slingRequest, "GET");

wrappedErrorRequest.setAttribute("error", "error details here");

wrappedErrorRequest.setAttribute("data", request.getParameter("jcr:data"));

//option 1

//slingRequest.getRequestDispatcher(slingRequest.getParameter(GuideConstants.SELF_URL) + ".html", options).forward(wrappedErrorRequest, response);

//option 2

GuideSubmitServlet.setForwardPath(slingRequest, slingRequest.getParameter(GuideConstants.SELF_URL)+ ".html", null,null );

//option 3

//GuideSubmitServlet.setRedirectUrl(slingRequest, slingRequest.getParameter(GuideConstants.SELF_URL + ".html");

In case of option 1 & 2, I get an error "resource cannot be modified". Turns out that I cannot forward to a page. With option 3, the request attributes are lost after the redirect. Any suggestions on how to resolve this?

Thanks

Replies

Avatar

Avatar
Springboard
Level 10
Mayank_Gandhi
Level 10

Likes

310 likes

Total Posts

1,131 posts

Correct Reply

184 solutions
Top badges earned
Springboard
Establish
Validate 1
Contributor 2
Ignite 5
View profile

Avatar
Springboard
Level 10
Mayank_Gandhi
Level 10

Likes

310 likes

Total Posts

1,131 posts

Correct Reply

184 solutions
Top badges earned
Springboard
Establish
Validate 1
Contributor 2
Ignite 5
View profile
Mayank_Gandhi
Level 10

26-06-2018

Can you preserve the state of AF and try restoring it later. Check for getGuideState and restoreGuideState method in the GuideBridge API doc shared below :

Adaptive Forms Class: GuideBridge

Avatar

Avatar
Validate 1
Level 6
Jared_Langdon
Level 6

Likes

19 likes

Total Posts

305 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 6
Jared_Langdon
Level 6

Likes

19 likes

Total Posts

305 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
Jared_Langdon
Level 6

19-09-2018

I have the same question