Forums de discussion

Creating forms using JavaScript vs taglibrary

Cori Ryan, modifié il y a 13 années.

Creating forms using JavaScript vs taglibrary

New Member Publications: 2 Date d'inscription: 22/02/11 Publications récentes
I am working on dynamic creation of forms in portlets. In the past I have used jQuery/Dojo/Plain old JavaScript to create the elements of the form based off of JSON data for other products. Now I am developing for Liferay portlets.

In approaching the same situation in Liferay, I find that most of the blog posts and examples use the tag library to define the elements of the form and JavaScript/AUI to validate the user inputs.

Is it not recommended methodology to create forms dynamically using the AUI JavaScript library? Does Liferay intend that we use tag libraries instead? I know I can create form elements using the AUI javaScript library like the code sample that follows:

new A.Textfield({
labelText : "My Textfield"
}).render(parent);

but all blogging and examples seem to lead in a different direction.

Any guidance on intended Liferay best practices, references to documentation, or posts where this is described would be helpful. I have done a lot of searching and do not feel I have a clear picture.

Thanks in advance.
thumbnail
David H Nebinger, modifié il y a 13 années.

RE: Creating forms using JavaScript vs taglibrary

Liferay Legend Publications: 14916 Date d'inscription: 02/09/06 Publications récentes
The tag library approach is only going to be useful in jsp pages; still considered 'dynamic', although the rendering is based upon jsp and will be handled on the server side.

The AUI javascript approach will work on the client side to create your elements dynamically.

Although Liferay moved from jQuery to AUI in v6, you can still use jQuery/dojo/js in v6 and, since that's what you're familiar with, it may be easier for you to stick to that path (although I can tell you that AUI is not all that difficult to work with and you'll find it has some similarities to jQuery).

The approach you choose would basically depend upon whether you needed to create the dynamic elements on the server side or the client side.
Cori Ryan, modifié il y a 13 années.

RE: Creating forms using JavaScript vs taglibrary

New Member Publications: 2 Date d'inscription: 22/02/11 Publications récentes
Thank you!

I also found that the downloaded the liferay-portal-src-6.0.5 did not have dynamic JavaScript examples under the forms directory, but a co-worker downloaded an earlier version of the examples that had a file called form_widget.html that did create elements using AUI.

I am still curious as to why the older examples did it the JavaScript way and the newer ones do not use this approach. They are mainly markup. I understand from your explanation that I can do just about anything. I wonder if the Liferay/Alloy team is recommending a certain direction based off of the change in approach to the provided examples or if I am reading too much into it.

Thanks,

Cori
Adeel Aslam, modifié il y a 10 années.

RE: Creating forms using JavaScript vs taglibrary

New Member Publications: 22 Date d'inscription: 09/12/12 Publications récentes
Hi David,

I found that Alloy UI is set to replace the Ordinary JQuery but what about Automations and Tasks on Page Load, Document Resize, Refresh, Can you provide a more complete documentation here or in Alloy UI Forum or Tutorial Section.

Image Viewer Helps but I could not figure out how to start changing images automatically on page load.
Arun Kulasegaran, modifié il y a 10 années.

RE: Creating forms using JavaScript vs taglibrary

New Member Publications: 8 Date d'inscription: 23/08/13 Publications récentes
Hi,
I'm new to liferay. Can u help me in validating dynamic data list fields before submitting it. Its Urgent