Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Managibility, Propagation, Form Validation, and getting rid of js

Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have several pages with several forms on them, some are unique and some aren't. The problem with our current implimentation of JSP and Javascript is that there is a massive amount of code within each page and in order to make a common change you must edit every single page. We want to move to a model where the front end stuff is seperated from the back end; the designers don't have to scroll through text that doesn't concern them, but they can still do their job without bugging the programmers. We want to be able to edit one page, or one form, or one component, and have it propagate every where it is used. We currently have Javascript handeling form validation! Ewww!

An example of our current model: To kick things off a radio button is selected and then depending on the option more items appear... right now the forms/items are just hidden and then revealed by javascript... this is ugly for both client and programer. another problem with the current version is that if there is more then 5000 charecters in a text box a message the "form validation" we have set in place gives a error message... and then wipes out everything they have Which is NOT ideal.

What do you suggust we do inorder to solve these problems? Should I bring in jsf or tapastry or whatever?
any thoughts, ideas, comments?

I'm in desprate need of help! any would be endlessly apreciated!
Posts: 67425
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly, investigate the concepts "Model 2" and "MVC". This is a pattern for separating the concerns of your application into managable layers.

Secondly, while Javascript validation can be a good thing for the "user experience" (e.g. quick notification of entry errors) it should never be relied upon. All validations must occur (or be repeated) on the server side.

Adopting a framework might be a possiblity for you, but I'd refrain from a wholesale adoption until you've got a good handle on the Model 2/MVC pattern so you can make a determination if a framework is appropriate for you, and if so, which framework to adopt.
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking at existing frameworks is always a good idea, Tapestry, Struts, Tiles, etc.....

You don't have to use a framework, however, to have a well constructed 'Model, View, Controller' (MVC) application. I have a site full of servlet examples that are almost all written in an MVC pattern.

One project, the Dynamic Select Lists app, works much like the requirement you have described. The user picks a value from one list and the other list updates itself according to what they picked.

If you look at the JSP code in that example, there is almost no JS other than an onclick event to submit the form.

[yet, another collision with Bear B.]
[ July 15, 2005: Message edited by: Ben Souther ]
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel, you say that to make a change, you must do it across a whole set of pages. If your javascript code is not being loaded from an external source, there's a great first step at refactoring. Another would be implementing server-side validation classes (especially if you feel that moving your app into a framework is too big of an initial leap).

My rule of thumb has always been to use client-side validiation in a lightweight manner, and server-side validation heavily.
New rule: no elephants at the chess tournament. Tiny ads are still okay.
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic