• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

how to design this JSP. need ur suggestion

 
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need your suggestins on this. I ahev a JSP whcih actually looks like this
---------------------Employee||||Search-----------------------------
Enter Department:............||||.......Enter employee last name:
Enter location:..............|OR|.......SearchButton2
SearchButton1.........||||
-----------------------------||||-------------------------------------
So it looks like the above one.. The user should either enter Dept and location anfd click Seachbutton1 or enter emp lastname and click on Searh button. Basically it will display search results in both the cases..
And I need to implement validation framework also ..
When the user clicks on SearchButton1, i need to make sure that he entered teh Dept and location and i need not bother abt the lastname firld.
OR
when the user clicks SearchButton2, , teh user should enter the lastname and obvously I need not bother whetehr he enterd sometuhing in dept and location..
I tried somthimng like this..
I made SearchButton1 as a submit button and SearchButton2 as ordinary button and am using a javascript to submit this form
So,When I click on SearchButton1 , it is validating all teh three fields Dept, location and lastname ( lastname should be validated only if SearchButton2 is clicked)..
PLease help me in solving this.. Do I need to use Multiform stuff or something like that. please hlp me in understanding this....
[ November 22, 2003: Message edited by: manasa teja ]
 
Sheriff
Posts: 16677
278
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Manasa, take a look at the documentation for requiredif or validwhen here first.
I don't think you need to make one button a submit and use javascript with the other "normal" button. Make both submits but use the property attribute to differentiate which button was selected:
// in JSP:
<html:submit property="searchByName" ... >
<html:submit property="searchByDept" ... >
// in Form:
private String searchByName;
private String searchByDept;
// add appropraite getters/setters
public void reset(...) {
...
searchByName = null;
searchByDept = null;
}
public boolean isSearchByName() {
return (searchByName != null);
}
public boolean isSearchByDept() {
return (searchByDept != null);
}
 
manasa teja
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Junilu.. I did nt know that we can use submitbutton's property like this..
1) first thing is validWhen is not available in my validations_rules.xml.. Looks like, this feature comes with struts latest version. And I am using 1.1 distribution only. Not sure, why it is not there..
2) So, i wanted to use requiredif to solve my problems..
But i am not very clear how to use this../
As suggested I created a form with getters and setters for all the fields in the JSP including submit button properties
and my validation.xml is

But it is not working.. How to call isSearchByDept() or isisSearchByName() methods.. ??validator frames automatically calls them, since we mentioned in the xml file or somewhere , do we need to call and manipulate them?? please adivse me on this.. I appreciate your help on this..
[ November 25, 2003: Message edited by: manasa teja ]
[ November 25, 2003: Message edited by: manasa teja ]
[ November 25, 2003: Message edited by: manasa teja ]
 
manasa teja
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Junilu,
Waiting for suggewstionson this
 
Junilu Lacar
Sheriff
Posts: 16677
278
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in the validator.xml, as in the struts tags, you use only the property name. So if you have a getter method called isSomething(), the property name will be "something", not "isSomething". I don't know if it matters but I would also use lowercase for true and false. Also, why are you using "OR"? You'd have two separate requiredif sections. One if searchByDept is true and the other would be if searchByName is true. From what you described, I don't think you should combine them.
Also, I would really appreciate a little patience on your part. As I said before, I don't spend all day just monitoring this forum -- I have a regular paying job, too. I'll pop in and out during the day and answer as I can. If you don't get answers as fast as you'd like, I suggest you keep trying some other things: try re-reading the documentation, study examples that work, debug and step through the code...don't just rely on people here to give you the answers. More often than not, a little trial and error can and does go a long way.
 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Manasa,
I would suggest that you avoid using the required-if validator in fav of validwhen. As per struts developers, required-if is going to be removed from struts distn eventually. validwhen is a much better and versatile tag. I am putting an example of a validwhen validation for your understanding. Also the valid-when comes with the post 1.1 stable release so you could actually get it on the internet somewhere or send me your email address and i will send it to you.
Thanks
Sahil
<field property="state"
depends="validwhen">
<msg name="validwhen" key="profile.state.validwhen"/>
<arg0 key="prompt.state"/>
<var>
<var-name>test</var-name>
<var-value>( ((country != 'us') and (country != 'ca')) or ( ((*this* != null) and (country == 'ca')) or ((*this* != null) and (country == 'us')) ) )</var-value>
</var>
</field>
State is valid when country is not us or canada or field is not empty. Since my field is a drop down, i dun have to worry about valid entries
 
manasa teja
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Sandy..
Looks like, this validwhen is very useful...
I want to us ethat. I tried finding necessary information abt this vaidwhen..
I downloaded teh latest struts distributiononoly.. but its validwhen rule is not availeble..
From where i can get this details abt this validwhen rule..
Do we need to change teh jar files and DTDs etc in lib directory..
I am currently using struts 1.1. Is there a way I can use the "validwhen"
functionality of future coming struts 1.2.
Something like I can take only the class files of validwhen and use it
along with struts 1.1

I am using Struts 1.1 with WSAD 5.0..
Please explain me in detail..
I coudl not enough info abt thsi in the net!!
thanks fo ryour help on this!!
My email id: manasa_teja@yahoo.co.in
[ November 27, 2003: Message edited by: manasa teja ]
[ November 27, 2003: Message edited by: manasa teja ]
[ November 28, 2003: Message edited by: manasa teja ]
[ December 05, 2003: Message edited by: manasa teja ]
 
manasa teja
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If somebosy has any suggestions this validwhen in validationframework, please explaine me in me detail@!!
 
sandy gupta
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have sent you the necessary files on your yahoo acct.
Hope that will go a long way in helping you out with the validwhen. You can read the http://jakarta.apache.org/struts/userGuide/dev_validator.html for furthur information and also post on this forum.

Sahil
:roll: OOPS the email bounced :roll:
[ December 02, 2003: Message edited by: sandy gupta ]
 
manasa teja
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sandy gupta:
I have sent you the necessary files on your yahoo acct.
Hope that will go a long way in helping you out with the validwhen. You can read the http://jakarta.apache.org/struts/userGuide/dev_validator.html for furthur information and also post on this forum.

Sahil
:roll: OOPS the email bounced :roll:
[ December 02, 2003: Message edited by: sandy gupta ]


oh God..!! may be the file size is very big..
Coud u please send me it again..
manasa_teja@yahoo.co.in
I really apprciate your helkp on this..
thnks
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic