Forum

Accueil » Liferay Portal » English » 3. Development

Vue combinée Vue Plate Arborescence
Sujets [ Précédent | Suivant ]
toggle
Cori Ryan
Creating forms using JavaScript vs taglibrary
5 avril 2011 07:23
Réponse

Cori Ryan

Rang: New Member

Publications: 2

Date d'inscription: 22 février 2011

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.
David H Nebinger
RE: Creating forms using JavaScript vs taglibrary
5 avril 2011 09:10
Réponse

David H Nebinger

Rang: Liferay Legend

Publications: 6258

Date d'inscription: 1 septembre 2006

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
RE: Creating forms using JavaScript vs taglibrary
6 avril 2011 07:16
Réponse

Cori Ryan

Rang: New Member

Publications: 2

Date d'inscription: 22 février 2011

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
RE: Creating forms using JavaScript vs taglibrary
16 juillet 2013 05:11
Réponse

Adeel Aslam

Rang: New Member

Publications: 18

Date d'inscription: 8 décembre 2012

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
RE: Creating forms using JavaScript vs taglibrary
23 octobre 2013 05:52
Réponse

Arun Kulasegaran

Rang: New Member

Publications: 8

Date d'inscription: 23 août 2013

Publications Récentes

Hi,
I'm new to liferay. Can u help me in validating dynamic data list fields before submitting it. Its Urgent