You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Michael Molloy <mm...@ncycles.com> on 2002/03/28 16:11:46 UTC

JSP question

I'm working on a web application that will be used by about 150 people concurrently. One of the requirements is to show text field hints in the status bar whenever the mouse passes over a text field. All of the hints are stored in the database.

I need to write a class that will be available at the application level that returns some javascript along with the correct hint for whatever field the mouse is currently over. Since there are over 1000 fields in this web application, I'm looking for alternatives to writing a class with a get method for each field.

What would work very well is if I could pass an argument in a getProperty call. For example, 

<jsp:getProperty name="testBean" property="hintText" value="firstName" />

That way, I could store the values in a hashtable and just get whatever one was requested. Of course, I can't do that. I also can't set a property & then immediately call get property to get the one I just requested in the set since the class is going to be shared by all users.

Can anyone suggest a way to do this? I feel sure there must be a way, but I can't think of it.

Thanks
--Michael

Re: JSP question

Posted by Jeff Larsen <la...@qec.com>.
Assuming you have a controller servlet that could load
the hint text from the database, why not have a static
hashtable in your servlet code that is initialized with
the values from the database in the init() method. Then
as each session is initialized, you could put a reference
to the hashtable in each session with

session.setAttribute("hints", hintTable);

Then you have access to the hints wherever you need them.

<jsp:useBean name="hints" class="java.util.Hashtable" scope="session">
...
<input type="text" name="myField" onMouseOver="self.status='<%=
(String)hints.get("myField") %>'">


Or better yet you could write a custom taglib...

<mytags:textWithHint name="myField">

and then do the hint lookup in the custom tag code. You could even have your
hashtable stored and initialized in the taglib code. Then your pages would
never need to know about it.

I hope these ideas help...

Jeff



----- Original Message -----
From: "Michael Molloy" <mm...@ncycles.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Thursday, March 28, 2002 9:11 AM
Subject: JSP question


I'm working on a web application that will be used by about 150 people concurrently. One
of the requirements is to show text field hints in the status bar whenever the mouse
passes over a text field. All of the hints are stored in the database.

I need to write a class that will be available at the application level that returns some
javascript along with the correct hint for whatever field the mouse is currently over.
Since there are over 1000 fields in this web application, I'm looking for alternatives to
writing a class with a get method for each field.

What would work very well is if I could pass an argument in a getProperty call. For
example,

<jsp:getProperty name="testBean" property="hintText" value="firstName" />

That way, I could store the values in a hashtable and just get whatever one was requested.
Of course, I can't do that. I also can't set a property & then immediately call get
property to get the one I just requested in the set since the class is going to be shared
by all users.

Can anyone suggest a way to do this? I feel sure there must be a way, but I can't think of
it.

Thanks
--Michael


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>