Change data in a bean

Change data in a bean

Post by AllIsPossi » Mon, 31 Jan 2005 17:45:25


Hi,

Sorry if this is a basic, simple, question :-P

I have a bean that retrieves data. I "set a property" for a field in
the bean that I would like to call ("the key") and it brings back the
data I want from the database - yippee!!

Now, I want to change what has been retrieved (using the bean) but it
looks as though before the .jsp is displayed *all* actions associated
with the use of the bean:

<jsp:useBean ...>
<bean:write ...
<jsp:setProperty name="....>

are executed BEFORE the display of the .jsp page (which really turns
into HTML). Is this the case? If so, then the only way that one can
change any data brought into the HTML page is when he/she hits the
SUBMIT button and the page goes to the server? Then, does that mean
that the bean is ONLY good for reading data INTO a page - in other
words, you can come in through the bean but you can't get out through
the bean?

That would be such a bummer :-|

TIA ..
 
 
 

Change data in a bean

Post by Tom Dyes » Tue, 01 Feb 2005 06:35:37


I'm not really sure what you're asking, but if you want to retrieve user
input from an HTML form, you need to go through either a submit button, or a
dynamicly created querystring with a redirect (which is kinda strange to me
for a form). Either of which need to be clicked and handled by a servlet or
jsp or whatever. That's just web architecture, you can't do much about that
unless you change from a HTML/JS container to an Applet or ActiveX or
something.

--
Tom Dyess
OraclePower.com

 
 
 

Change data in a bean

Post by John C. Bo » Tue, 01 Feb 2005 23:00:40

This is not really about Javabeans, and certainly not about databases.
Followups directed to comp.lang.java.programmer.




It depends what you mean. In an HTML / HTTP setting, JSP is a
technology for dynamically creating HTML pages in response to HTTP
requests. A JSP runs on the server, and the client only ever sees the
HTML results. (This is much like other web scripting technologies such
as PHP and ASP.) Thus, if you mean that bean manipulation happens
before the browser renders the page on the client then you're right.


If you want to modify an HTML page on the client side (without making a
new request to the server) then you need to use a client-side
technology, such as Javascript. Your JSP can very easily output
Javascript code as part of its HTML response.

Beans are useful for a wide variety of things in a JSP, but in that
context they are limited by the servlet request / response model. That
does, however, mean that people without Java-enabled browsers can use
your JSPs.


John Bollinger
XXXX@XXXXX.COM