Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

dynamically displaying the form  RSS feed

 
aliya sharma
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I'm really new to JSP. I have a form with one text value whichis used to look up the row associated to that field and another form which displays the row in a table form. My problem is I want to have only the first form displayed when the page is first loaded and if the user enters the value for the field, only then the other form should show containing the fields on the same page.

Could anyone please suggest me how this could be achieved or point me in the right direction. Thanks for your help.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37230
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can set an attribute in the request object for whether the second form should be displayed. Then you can conditionally display the second form.

This can be accomplished with an if statement, or better yet a taglib.
 
aliya sharma
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please elaborate more on setting the object in the request parameter and "if" statement...some code just to get me started would be really appreciated...Thanks for your response.
 
Ramaswamy Srinivasan
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Aliya,

According to me, since you want to display the rows in the same page, i guess somewhere down..... we can go for a javascript to check for the value and get the value. From javascript, you can contact the servlet if you have one and get the things done.

Also you talk of forms, in a same page. This is a problem, quite related to HTML issues. We can make use of DIV or some sort of a things.

If this is the case, the problem becomes quite simple.

I have a small working code to check for empty fields and changing the visibility. Hope this helps you. Kindly get back, if you need anything.

Am not able to post the code directly, it keeps showing some error message for my html tags. Any way, if you need the code, just send me ur mail ID and i shall send the code immediately.

Hope this helps.

Cheers,
Swamy
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37230
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aliya,
To get/set attributes in the request, you use:
request.setAttribute("name", "value");
request.getAttribute("name");

For the if statement/taglib, take a look at a book or tutorial on JSPs. This tutorial from Sun covers conditionals.
 
aliya sharma
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ram and Jeanne for your help.
Ram, i have emailed you at your yahoo account. please check it and reply back. Thanks.

aliya
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!