• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem reg Validator

 
Raminder Singh
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 radio buttons. R1 and R2.
If R1 is clicked, we have to validate FOUR fields. F1,F2,F3,F4.
But in case of R2, only THREE F1,F2,F3.

We include/invoke javascript with <html:javascript formName="11">.
and this formName is as per refreance in validation.xml
<form-validation>
<formset>
<form name="11">
<field> tag for all 4
</form>
</formset>
</form-validation>
what will be approach to validate 3 tags? I have made <form name="22">
and write <field> tag for 3 fields.
but when i place <html:javascript> in jsp....only 2nd <html:javascript> tag is used.
so how to solve this??
------------------------
Also plz help me in validating Two date fields( d1 and d2) thr validator.
Conditions: d1 & d2 >= current date
d1 & d2 <=100
d2 can't less than d1.


Thanks
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may seem like a strange reply to your request, but whenever I find myself working really hard to get around the restrictions of a framework, I have to ask myself "Is it really worth it?". I find that when dealing with complex cases where I have to bend over backwards to get the framework to do something for me, it's sometimes easier just to abandon the framework and write the code myself. Just my 2 cents, but in this situation, I think I'd just write the javaScript to do what was needed and work outside the validation framework. If I were concerned about uniformity of error messages, it wouldn't be hard to make the message look like the other messages the validator generates.
 
alan do
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i agree with merrill that there are certainly limitations to the validation framework and from time to time you'll have to ask yourself whether or not it's worth it.

in your case, since you are using javascript for validation, why not just skip the validation framework all together? i never understood why people use the validation framework for javascript validation at all. it's cumbersome and adds lots of redundant js into your codes. this is not to mention the cross-browser compatibility, especially when you start adding your own validation. struts 1.2.x improved this quite a bit (i believe), but i still firmly believe i can write simple (shared) js validation more efficiently.

with that said, the validation framework is an extremely powerful tool and wonderfully designed for expandability for server-side validations. there IS a learning curve, but once you get over the hump, the world is in your hand. i think i've encountered many, many types of strange validations and have been able to tackle them all using the framework declaratively. there are a couple of cases i could think of that i had to pull the validations INSIDE the action classes and use struts message handling instead. still, messaging, if set up correctly, interact well with validation error display to create a seemless 'validation'.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic