Form values need to manipulated for xssapi FOR AEM 5.6.1 before getting stored under /content/usergenerated/

Avatar

Avatar
Validate 10
Level 2
srinivasc110177
Level 2

Like

1 like

Total Posts

71 posts

Correct reply

2 solutions
Top badges earned
Validate 10
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 10
Level 2
srinivasc110177
Level 2

Like

1 like

Total Posts

71 posts

Correct reply

2 solutions
Top badges earned
Validate 10
Validate 1
Boost 1
Affirm 1
View profile
srinivasc110177
Level 2

07-11-2016

Hi,

I am using AEM 5.6.1
I  need to modify  the values  of  the attribute that get  stored in  the  /content/usergenerated/ for the form fields that gets stored on form submit

I find that there is  a server validation /apps/foundation/components/form/defaults/field/servervalidation.jsp. But i find i cannot use it to change the value attribute that could get stored under  /content/usergenerated/ 

I tried the below /apps/foundation/components/form/defaults/field/servervalidation.jsp for "Country" field and changed the value of Country to cs   but found  that the value submitted using form got stored. please let me how this can be achieved. 


for(final FieldDescription desc : descs) {
        if ( FieldHelper.checkRequired(slingRequest, desc) ) {
            FieldHelper.checkConstraint(slingRequest, slingResponse, desc);
        } 

        if ( desc.isRequired()) {  
         String[] values = request.getParameterValues(desc.getName());  
         // You can check for length of values in the string array/values whatever 
//suits you for required validation.  
 }  
        

        if(desc.getName().equalsIgnoreCase("Country")){
            
            slingRequest.setAttribute("Country","cs");
        }


    }

 

Thanks

Replies

Avatar

Avatar
Validate 10
Level 2
srinivasc110177
Level 2

Like

1 like

Total Posts

71 posts

Correct reply

2 solutions
Top badges earned
Validate 10
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 10
Level 2
srinivasc110177
Level 2

Like

1 like

Total Posts

71 posts

Correct reply

2 solutions
Top badges earned
Validate 10
Validate 1
Boost 1
Affirm 1
View profile
srinivasc110177
Level 2

07-11-2016

Any inputs from anyone for the above will be helpfull??

Avatar

Avatar
Boost 50
Level 10
Sham_HC
Level 10

Likes

161 likes

Total Posts

2,114 posts

Correct reply

1,204 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 25
Boost 100
View profile

Avatar
Boost 50
Level 10
Sham_HC
Level 10

Likes

161 likes

Total Posts

2,114 posts

Correct reply

1,204 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 25
Boost 100
View profile
Sham_HC
Level 10

11-11-2016

The client or server validation is used to generate a snippet of javascript that will be used on the front side to validate the entered value. Avoid misuse of it.  You should implement custom action type & in  post.POST.jsp  handle the changes required.   Out of the box location reference like /libs/foundation/components/form/actions/<actiontype>/post.POST.jsp

Avatar

Avatar
Validate 10
Level 2
srinivasc110177
Level 2

Like

1 like

Total Posts

71 posts

Correct reply

2 solutions
Top badges earned
Validate 10
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 10
Level 2
srinivasc110177
Level 2

Like

1 like

Total Posts

71 posts

Correct reply

2 solutions
Top badges earned
Validate 10
Validate 1
Boost 1
Affirm 1
View profile
srinivasc110177
Level 2

11-11-2016

Thanks Sham for the inputs.

I have custom  form field name  "email" i tried changing its value in forward.jsp

under the below path i the below jsps

/apps/app1/components/form/actions/store
/apps/app1/components/form/actions/store/addfields.jsp
/apps/app1/components/form/actions/store/forward.jsp

the above code is taken from /libs/foundation/components/form/actions/store

in the /apps/app1/components/form/actions/store/forward.jsp we have the existing code

try {
                    final Node node = JcrUtil.createPath(path, "sling:Folder", adminSession);
                    final Node parent = node.getParent();
                    node.setProperty("email","what@abc.com"); // i added the custom  form field that i wanted to get stored under /content/usergenerated/path


                    
but the email value was always overwritten with the actual value i had passed using form.
                    

  1. I   found that FormsHelper.setForwardPath(slingRequest, path, true); was causing this to happen as when i commented this line the email was getting set correctly like i wanted above.
  2. But FormsHelper.setForwardPath(slingRequest, path, true); is always required for the form to show the  results correctly to the user.

From the above could you please tell me as how could i set the "email" value to "what@abc.com"  to be stored in /content/usergenerated/path

Thanks