Thanks "dim" for the interesting web link. I think I'll definitely browse
it in depth at a later point. For this web application that I am working on
we have most of the architecture designed and built, and are just running
into this minor glitch when implementing some of our JSP pages. It
unfortunately has big impacts in JSP coding style. Let me explain:
Supposing I have the following bean declared.
<jsp:useBean id="myBean" class="com.cool.MyBean" scope="session" />
If I have ten fields in my form that I want to put into this bean, I would
like to code the following:
<jsp:setProperty name="myBean" property="*"/>
The problem is that if "fieldOne" is left blank value will NOT be "set"
using the setFieldOne method on my JavaBean. However, if I code the
following:
<%
myBean.setFieldOne(request.getParameter("fieldOne"));
myBean.setFieldTwo(request.getParameter("fieldTwo"));
myBean.setFieldThree(request.getParameter("fieldThree"));
.
. You get the idea
.
%>
This works fine, it is just much more tedius, especially on forms with many
fields.
Also, as a side note, this does not work either.
<jsp:setProperty name="myBean" property="fieldOne" VALUE="" />
Thanks!
Mike
-----Original Message-----
From: Dmitri Colebatch [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 28, 2001 11:36 PM
To: [EMAIL PROTECTED]
Subject: Re: JSP / JavaBean problem
firstly - right list. unfortunately I dont have a direct answer for you,
although do see what you're asking. what might help you though is something
like struts (http://jakarta.apache.org/struts). it handles the sorts of
issues that are (by the sounds of it) at the base of your problem
cheesr
dim
On Fri, 29 Jun 2001 14:10, you wrote:
> Hi, I'm new to this list, and hope this is the appropriate forum. Kick me
> over to a developer forum if not...
>
> I am developing JSPs with JavaBeans and have run into an issue with
"blank"
> input fields on the form. An empty string, "", is NOT passed to the
setter
> method on my beans. I have researched the source code in
> JspRuntimeLibrary.java and found the introspect (Tomcat 3.1) /
> introspectHelper (Tomcat 3.2.1) method intentionally excludes parameters
> that have a NULL or "" value - of course NULL could never happen because
of
> the flow of the code, but never mind that.
>
> I guess my question is this. Is this correct functionality. I have read
> the JSP 1.1 specification on the topic of the setProperty tag, and it is
> NOT specific regarding this matter. It is a huge problem for me because I
> have beans that have a session scope and a particular property of the bean
> may be "Fred" but if I blank out the related input field it doesn't
> overwrite the value in the bean when I submit the form. Hope this makes
> sense.
>
> Any and all help would be appreciated.
>
> Thanks!
>
> Michael W. Housman Jr.
> Optimal Systems Design, Inc.
> Consulting at Wells Fargo Services Company
> Phone: 612.341.9784
> Cell: 612.386.6785
> Office: 763.537.2631