Hide parameters from Mobile Form URL

In ES4, Mobile Form had a limitation that it could only hide the template references from the form URL exposed to the user. In ES4 SP1, one can overcome it using the new ways of passing parameters to Mobile Form render service.

Based on your preference and requirement, you can choose to specify the render parameters like template reference, data reference, submit url etc either as node properties or as setAttribute API of server request object. In this post, I will go through both the options in detail and discuss pros and cons. Ideally, in production system, one should use any of these two methods of passing parameters over the request parameter method wherein all parameters are visible to the user accessing the url. Besides hiding the parameters, these two methods also make maintenance easy. For example, let’s say you want to change the data reference, then you wont need to update the URL everywhere because it is anyway not part of the URL.

Let’s say, you already have a servlet or JSP running on the same server and you want to forward the user request to the Mobile Form profile renderer using servlet forwarding. In this case, you can expose the URL of your servlet or jsp as Form URL. That user facing JSP may, in turn, set the template and data references in the request object before forwarding, using setAttribute API of servlet. Now this approach would mean you create one user facing JSP/servlet for each form or pass some parameter based on which it can select a form. The jsp would like the following:


request.setAttribute("template","test5.xdp");
request.setAttribute("contentRoot","c:/bugs/layout");
//similarly for other parameters and then get the request dispatcher of the profile URL and forward it.
RequestDispatcher rd = request.getRequestDispatcher("/content/xfaforms/profiles/default.html");
rd.forward(request, response);

If you create the user facing URLs in sling subsystem then it better to go for the other approach. Because, you have to create a content node anyway, to create a new REST URL. But if you are creating node, then you can specify the parameters as node properties as mention in post. In the following screenshot, you would notice, how I have specified Mobile Form render parameters as node properties of “leave” node created under /content section. Also, I specified resourceSuperType for this node to default profile renderer of Mobile Form.

node-prop

 

As is evident from the above, you need to create one node for each combination of render api parameter.

It is good practice to do mix and match of both approaches. It is good to specify the static or less dynamic properties like template reference as node properties and pass other dynamic or frequently changing parameters like data reference as setAttribute method.

 

2 Responses to Hide parameters from Mobile Form URL

  1. Paul says:

    Rag, do you know how in mobile forms can we access the form data xml? usually in the xfa world, livecycle will merge an xml with a xdp, my problem is in mobile forms, the code that use to work in pdf doesn’t work in mobile forms, so i need to find a way to access the input xml to the html generated form.

Leave a Reply

Your email address will not be published. Required fields are marked *


6 − = five

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>