Re: problem with HttpSession in Resin-2.1.2

2002-07-24 Thread Jonathan Fuerth

On Tue, Jul 23, 2002 at 06:06:08PM +0100, David Mulligan wrote:
 Everthing works just fine on Tomcat 4.0.3 and Websphere. 
 But for some strange reason the HttpSession I create in my LogonAction loses
 an attribute (The UserBean) in the next request (only with Resin)!

Are there any JSPs involved in your testing?  They always seem to
create a session when they start up.  If for some reason (short
timeout or otherwise) the initial session you created and put the user
bean into was invalid when a JSP started, it would create a new
(empty) session, which could be what you're seeing in that second
servlet.  The locale attribute probably comes from a html:html
locale=true tag in your JSP (assuming you are using a JSP).

Do try and set the session timeout in web.xml (as you mentioned).. a
very short session timeout is one possible explanation for what's
going on.

I don't know if this will help you solve the problem, but that's my
best guess at what's happening to your session.  Good luck with it!

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - http://www.sqlpower.ca/

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: problem with HttpSession in Resin-2.1.2

2002-07-24 Thread Jonathan Fuerth

On Wed, Jul 24, 2002 at 04:08:33PM +0100, David Mulligan wrote:
 Now I'm really confused!!!

Oops, sorry. :)

 I'm using Velocity for the presentation, so no JSPs or tags. 
 I'm guessing the LOCALE attribute is coming from the web 
 browser! I also tried setting the session-timeout to 30 
 minutes in web.xml and that didn't work either.

No, the session is stored only on the server side.  The web browser
has no direct control over what's actually in the session.. it just
remembers a session key which helps the server figure out which
session object to use for the current request.  Your browser can make
the whole session seem to go away (by refusing to remember the session
key) but it can't add or remove items that are stored inside a
particular session.

 But this is where things get really strange! 
 
 I started up K-Meleon (Mozilla browser) to check and see if 
 MS-IE was sending my location in the request (Hence the 
 LOCALE attribute) and everything worked just fine! 
 
 Not one problem! I can login/logout etc. UserBean is getting 
 saved in the Session. Everything works as expected!
 
 Back to IE and it still doesn't work. IE is setup to check 
 for newer page version with each request. So it's not a 
 problem with the cache. 

Maybe we've both overlooked the obvious: Is it at all possible that
you've got cookies turned off in your MSIE privacy options?  That's
what it sounds like at this point.

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - http://www.sqlpower.ca/

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: how to search this list's archives

2002-07-05 Thread Jonathan Fuerth

On Fri, Jul 05, 2002 at 10:53:13AM +0100, Jim Clayson wrote:
 I don't know how to use the search! I mean I use the search by
 plonking words in the text input box but I'm wondering whether I'm
 using a spaceship to go and buy bread on the corner - if you know
 what I mean. How sophisticated is the search mechanism?

I don't know which archive of the struts-user list you're using (there
are several on the web), but the most common one I've seen cited here
is the one on mail-archive.com.

Personally, I haven't had too much luck with searching
mail-archive.com.  It seems to get the threading wrong most of the
time, and the previous and next buttons usually do the wrong thing
(IMHO).  But they do provide a valuable service.  The archive updates
with new messages amazingly quickly, and the whole site is
lightning-fast to use.

 Can someone please point me to a doc or previous post if applicable?

http://www.mail-archive.com/faq.html#search

Ok, now that I've read that I understand why I've been having problems
with mail-archive.  They only thread and index-by-date the newest 1000
messages in each list.  This makes me feel better.. it's not broken
software, just good old-fashioned resource constraints. :)

Cheers.

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - http://www.sqlpower.ca/

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Confused about exception handling design, 1.1 beta

2002-06-05 Thread Jonathan Fuerth

On Wed, Jun 05, 2002 at 02:34:48PM +, [EMAIL PROTECTED] wrote:
 Have you read my exception handling chapter on 
 theserverside.com? If that doesn't answer this question, 
 than I've failed and I need to rewrite that chapter. 
 Take a look at it and send me some feedback if it 
 doesn't answer your question enough and I'll fix it.

I signed up and downloaded that chapter, but it appears to be an
MS-Word file or some other proprietary format.  Is there any chance
you can post updates in a more open format such as PDF, HTML,
Postscript or plain text?  I'd be happy to read it and give feedback
if I could read the file's contents.

Thanks!

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - http://www.sqlpower.ca/

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: bean:write

2002-06-03 Thread Jonathan Fuerth

On Mon, Jun 03, 2002 at 02:58:45PM +0200, [EMAIL PROTECTED] wrote:
 Is there a possibility to write some values from the session to the
 jsp, without having a bean for this value?

Yes, with standard JSP:

%= session.getAttribute(mySessionAttr) %

See http://java.sun.com/products/jsp/tags/11/syntaxref115.html#11258
for details on all the stuff you can do with standard JSP 1.1.

To use the Struts custom tags (such as bean:write), I think you always
need to define a bean before using the session attribute's
value... but I've never tried it without.  Maybe it works. :)

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - http://www.sqlpower.ca/

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: errorPage directive works incomprehensibly sometimes

2002-05-31 Thread Jonathan Fuerth

On Fri, May 31, 2002 at 03:21:19AM -0700, Sergey Sinelnichenko wrote:
 process exception. But sometimes, output of /app_error.jsp page
 APPENDS to output of page, where an exception occur (error-fire
 [...]
 
 What is it, and how may I fix this behaviour?

When something in your JSP throws an exception, some special errorPage
handler code tries to forward the user to the error page you specified
by using an HTTP redirect response.

The problem is, you can only send one HTTP response per user request,
which means you can't send an HTTP redirect header to the user if
you've already started sending data to the user.

The way JSP gets around that problem is that your output data gets
saved in a server-side buffer for a little while before being sent to
the user.  If an exception happens in your JSP's code, the server will
throw out all that buffered data and send an HTTP redirect to the
error page instead of sending an HTTP ok header.

The JSPWriter's output buffer doesn't have unlimited capacity though,
and the server will eventually start sending data to the user even
before your JSP is finished executing.  If an exception gets thrown
after the server has started sending data, the forward will be
impossible, and the best alternative will be to append the error page
instead of forwarding to it.

You might be able to optimise your JSP so that all of the code that
might cause exceptions gets executed before you've tried to write out
much HTML.  You might also be able to increase the size of the
JSPWriter's buffer enough to avoid sending the data before your
exception gets thrown.

Happy coding!  It's Friday afternoon and I'm headed home!

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - http://www.sqlpower.ca/

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: 'm*n' no of dynamic Text boxes in form Bean ???????

2002-05-29 Thread Jonathan Fuerth

On Thu, May 23, 2002 at 05:10:19PM -0400, Boyalla, Raveendra wrote:
 I have variable no of rows and variable no of columns of text boxes.
 
 So ActionForm should be able to store them in Arrays in Array .
 
 I can not use a simple Array in ActionForm.
 It should be an Arrays in Array.
 Does ActionForm grabs and populate text boxes from Arrays-in-Array type of
 Objects?

Yes, you can do it with Struts by combining indexed and nested
properties on your form.  No additional components are required.  I
worked this code out just now:

in your form class
protected List gridRows;

public void reset(ActionMapping mapping, HttpServletRequest request) {
gridRows=new ArrayList(10);
for(int i=0; i10; i++) {
gridRows.add(new Row(7));
}
}

/** Returns the list of Row objects */
public List getGridRows() {
return gridRows;
}

/** Sets the new list of Row objects */
public void setGridRows(List newGridRows) {
gridRows=newGridRows;
}

/** A class with a single property that the Struts ActionServlet can populate */
public static class Row {
protected List items;
public Row(int length) {
items=new ArrayList(length);
for(int i=0; ilength; i++) {
items.add();
}
}

public List getItems() {
return items;
}

public void setItems(List newItems) {
items=newItems;
}

public int size() {
return items.size();
}
}
---

In your JSP
html:form action=/categoryEditScreen method=get
  bean:define id=form name=categoryForm type=CategoryForm/
  %
int height=form.getGridRows().size();
int width=((CategoryForm.Row)form.getGridRows().get(0)).size();
  %
  table
% for(int y=0; yheight; y++) { %
  tr
% for(int x=0; xwidth; x++) { %
  tdhtml:text property='%= gridRows[+y+].items[+x+] %'//td
% } %
  /tr
% } %
  /table
/html:form
---

Of course, you could use logic:iterate tags if you prefer, but I've
been running into problems on Tomcat 4.0 with Java 1.4 on Solaris,
where the JSP won't compile if there are many JSP custom tags.  Taking
out the iterate tags solves the compilation problem for us without
killing too much readability.

Let me know if you get it working on your end.

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - http://www.sqlpower.ca/

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: html:select selected=selected ?

2002-05-23 Thread Jonathan Fuerth

On Thu, May 23, 2002 at 05:22:28PM -0400, Michael Marrotte wrote:
 I want an item selected...  I just don't want it selected like that,
 i.e.  selected=selected.  I don't understand why it's generated
 this way.  Why not just selected?

It's for XHTML compliance.  SGML (and HTML) supports (as you know)
attributes with no value, but XML (and XHTML) requires a value
enclosed in double quotes for every attribute of a tag.  Also, XML is
supposed to be case-sensitive, and they chose all-lowercase tags and
attributes.

The XTML spec says to use, e.g. selected=selected or
noshade=noshade for an XHTML attribute where the old HTML attribute
had an implied value of true whenever the attribute was present.
They presumably tested a bunch of browsers to make sure this was
backward-compatible before recommending it. :)

See http://www.w3.org/TR/xhtml1/#h-4.5 for the actual recommendation.

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - http://www.sqlpower.ca/

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Help: Problems attempting to migrate to nightly build from 1.0.2

2002-05-22 Thread Jonathan Fuerth

On Wed, May 22, 2002 at 08:35:12AM -0700, Dan Rasmussen wrote:
 I have attempted to install the nightly build in my
 application and ran into all sorts of problems that began
 with this message when I restart tomcat:
 
 MessageResourcesFactory.createFactory
 java.lang.ClassNotFoundException:
 org.apache.struts.util.PropertyMessageResourcesFactory

Some of the struts utility classes have been moved out of struts.jar
ant into the commons-*.jar archives.  Have you downloaded those and
placed them in your WEB-INF/lib directory along with struts.jar?

 I tried moving struts jar files around (like into the
 $TOMCAT_HOME/lib directory) but there is nothing but worms
 in that can.  

Yeah, that doesn't work.  The struts.jar file definitely goes in
WEB-INF/lib.

 I also need to move th jdk 1.4 and tomcat 4.  Should I do
 that migration first?

I can't reccommend that.  I've been working on it all week, and still
haven't solved the problem: When I moved to Tomcat 4 and JDK 1.4, all
of the Struts tags that use the ApplicationResources.properties file
stopped working.  I can't even get the login screen to display under
JDK 1.4, although everything works fine for Tomcat 3.x and 4.0 under
JDK 1.2.x and 1.3.x on Solaris, Linux, and NT!

Having said that, please follow-up in this thread if you upgrade to
JDK1.4 and all goes well!  Maybe I've just lost my marbles. :)

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - http://www.sqlpower.ca/

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: ApplicationResources has gone missing

2002-05-22 Thread Jonathan Fuerth

On Tue, May 21, 2002 at 06:30:46PM -0400, Jonathan Fuerth wrote:
 But when we run the same codebase on:
 -Tomcat 4.0 with Sun JDK 1.4.0 on Sparc Solaris 8
 
 We get the following exception:
 
 javax.servlet.jsp.JspException: Cannot find message resources under key 
org.apache.struts.action.MESSAGE
 at org.apache.struts.util.RequestUtils.message(RequestUtils.java:735)
 at org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:295)
 at org.apache.jsp.login$jsp._jspService(login$jsp.java:99)
 [...]

Upgrading from a Struts February nightly build to the 1.1b1 milestone
release made the problem go away.

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - http://www.sqlpower.ca/

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




ApplicationResources has gone missing

2002-05-21 Thread Jonathan Fuerth

Hi!  I'm working on a multi-developer struts-based project which is
nearing the end of its first development cycle.  Our app is running
properly in the following testing environments:

-Tomcat 3.2 with Sun JDK 1.2.1 on Intel Solaris 8
-Tomcat 3.2 with Sun JDK 1.3.0 on NT4 SP? for Intel
-Tomcat 3.3 with Sun JDK 1.2.1 on Sparc Solaris 8
-Tomcat 3.3 with Sun JDK 1.3.0-green threads on NetBSD/i386 (Linux emul)
-Tomcat 4.0 with Sun JDK 1.3.1 on NT4 SP6 for Intel
-Tomcat 4.0 with Sun JDK 1.3.1 on Sparc Solaris 8

But when we run the same codebase on:

-Tomcat 4.0 with Sun JDK 1.4.0 on Sparc Solaris 8

We get the following exception:

javax.servlet.jsp.JspException: Cannot find message resources under key 
org.apache.struts.action.MESSAGE
at org.apache.struts.util.RequestUtils.message(RequestUtils.java:735)
at org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:295)
at org.apache.jsp.login$jsp._jspService(login$jsp.java:99)
[...]

Has anyone seen this problem under Tomcat 4.0 and JDK 1.4 before?  My
first guess is that this is a JDK 1.4 quirk... I'd be interested in
hearing from anyone who's had trouble upgrading to 1.4.

Thanks!

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - http://www.sqlpower.ca/

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Off Topic how to download mirror of web site

2002-04-01 Thread Jonathan Fuerth

On Tue, Mar 26, 2002 at 03:10:01AM -0800, Struts Newsgroup wrote:
 A client has asked me to produce an 'off-line' copy of his static
 web site - lnks go down at least 6 levels.

 If it were possible I would just get ftp access and download the lot
 - but time and the effort of liaison with 5 subsidiary company
 webmasters prevents.

Ok, I know this is 6 days after the fact.. but the ideal tool for your
needs is wget.  Its webpage is

http://www.gnu.org/software/wget/wget.html

from there, you can download the source for *nix as well as Win32
binaries.

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - http://www.sqlpower.ca/

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: What's a good practice to reuse formBeans with validation

2002-03-08 Thread Jonathan Fuerth

On Fri, Mar 08, 2002 at 12:55:01AM -0800, Struts Newsgroup wrote:
 What we wanted was exactly the same as you: insert, update, delete,
 different actions with different validations. If I want different
 validations I want different formbeans (formbean for insert, one for
 update and one for delete). The problem is that the html form
 section (html:form action = youraction)can only contain one
 action and so you can only go to one formbean. If this form has
 multiple buttons then what do you do?

We've encountered the same problem, and here's how we chose to solve
it (using only one formbean):

-For each submit button, assign a different property name:
  html:submit property=insertSubmit
bean:message key=button.newRecord/
  /html:submit

  html:submit property=updateSubmit
bean:message key=button.updateRecord/
  /html:submit

  html:submit property=deleteSubmit
bean:message key=button.deleteRecord/
  /html:submit

-Then in your validate(mapping,request) method of the form bean:
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest req){
boolean doInsert=(req.getParameter(insertSubmit) != null);
boolean doUpdate=(req.getParameter(updateSubmit) != null);
boolean doDelete=(req.getParameter(deleteSubmit) != null);

// Check for always-required fields here

if(doInsert || doUpdate) {
  //Check for some special-case required fields here
}
if(doDelete) {
  //Check for different set of required fields here
}
  }

-This method has worked really well for us: it's easy to implement,
 and easy to understand for new people who join the project.

 The area we haven't checked is the area of using hyperlinks instead of
 submit buttons, so the solution might be there.

This could work if you required your users to have a
javascript-enabled browser, but the method I'm using works with all
forms-enabled browsers... which is most (but not all) of them. :)

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - www.sqlpower.ca

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: What's a good practice to reuse formBeans with validation

2002-03-08 Thread Jonathan Fuerth

On Fri, Mar 08, 2002 at 08:40:01AM -0800, Struts Newsgroup wrote:
 From: Pim [EMAIL PROTECTED]
 Looks like a fine solution, but.. I'm using davids winterfeldt's
 validator.  This means that you can (and must) validate per
 ActionForm. So I'm forced to using multiple ActionForms since I have
 different validations (insert/update and delete)

I see.  I guess everything is a tradeoff in the end. :)

I've heard lots of great things about David Winterfeldt's validator.
I plan on trying it some time when I'm not under so much time
pressure.  (It's ironic that sometimes we're so busy that we don't
have the time to learn how to do things more efficiently).

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - www.sqlpower.ca

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RT expression in html:errors tag

2002-03-08 Thread Jonathan Fuerth

Hi.  I'm trying to do this on a JSP page:

logic:iterate collection=foobar id=foo indexId=i
  html:text name=foo property=myValue indexed=true/
  html:errors property=foo%= i %/
/logic:iterate

And my form's validate method adds to the ActionErrors using:
  errors.add(foo+i, new ActionError(errors.badFoo));

The problem is, I can get all the error messages back with a simple
html:errors/ tag, but the above construct doesn't show the error
messages at all.

I have double-checked that I'm using the same error names in the form
validtor and on the jsp.

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - http://www.sqlpower.ca/

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: RT expression in html:errors tag

2002-03-08 Thread Jonathan Fuerth

On Fri, Mar 08, 2002 at 06:05:42PM -0500, Jonathan Fuerth wrote:
   html:errors property=foo%= i %/

I figured it out.  I changed the above line to:

html:errors property='%= foo+i %'/

And now it works just as I wanted it to!

Does anyone know why this is?  Something to do with the way RTExpr
attributes are supposed to work in JSP?  Or maybe it's a quirk with
the way code gets generated by Jasper.

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - http://www.sqlpower.ca/

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




html:error and html:text enhancements

2002-03-07 Thread Jonathan Fuerth

I have two quick questions about the html:errors tag:

1. Has anybody thought about implementing a remove attribute on the
   errors tag that removes the ActionError objects as they're printed?
   That way, you could report all of the property-specific errors
   alongside their form input boxes, then render the leftovers at the
   bottom of the form with a simple html:errors/ tag.

2. Has anybody thought about implementing a printErrors attribute
   on the html:text tag?  This would have to mesh well with the
   indexed property to report all the errors encountered in a
   collection of indexed text boxes.

If nobody is currently working on this, I'd be happy to do it.  I'm
especially interested in input from the Struts maintainers so that I
can do the modificiation properly.  That way, it could be integrated
with future releases.

Thanks!

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - www.sqlpower.ca

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Exception handling best-practise

2002-02-22 Thread Jonathan Fuerth

On Fri, Feb 22, 2002 at 04:58:28AM -0500, Ted Husted wrote:
 IMHO, the messages and the messages keys belong to the model. The
 controller is simply transferring this data to the view, as it does with
 everything else, like records from a database. 

Aha, that makes perfect sense to me!  Thanks for clarifying that.  I'm
sure I would have worked myself into a real mess while labouring under
that misconception. :)

 In most cases, exceptions can be converted to ActionErrors. I would try
 and do all of this in the Action, so that the view doesn't have to
 think about anything. Also, in the Action it is much easier to access
 utility methods to parse the exception for you. A base method for your
 Actions might be able to do everything; so in the main perform, all you
 end up doing is passing back the instant request, ActionError object,
 and the exception. A base method could handle it from there. 

This sounds like a good plan.  Would this base class also be an
appropriate place to acquire a Connection, then make sure it's
released using try .. finally around the call to the subclass?  I'm
getting connections via a getConnection call in my custom LoginSession
class, which I plan to hook up with Poolman later on.

Thanks again for your help.

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - www.sqlpower.ca

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Exception handling best-practise

2002-02-19 Thread Jonathan Fuerth

I'm refactoring an existing web application into the Struts MVC
framework, and I'm moving from the implementation planning to the
coding stage now.  Before I act on some potentially poor choices, I'd
like to run some of my ideas past the group:

The Model part of my application, which handles all the SQL database
interaction and business logic, will inevitably encounter semantically
incorrect user input that the ActionForms in the view could not have
known was incorrect (example: invalid username/password on the login
screen).  Some of these semantic errors will result in SQLExceptions
and the like, which the view (JSPs, ActionForms) should not have
visibility to.

My knee-jerk reaction to this problem was to have the controller
(Action class) catch these exceptions and add ActionErrors to the
response, indicating appropriate message keys which the JSP could
display in the user's favourite language.

This seems to break the MVC design pattern though, because now the
controller contains information the belongs to the view (message keys)
and is making decisions that are the responsibility of the model
(handling the exceptions that the model generated).  Or is it, in
fact, the controller's job to do exception handling?  If so, what
mechanism in MVC generates the error message that the user sees?

My current plan of attack is to create a custom exception class for
everything that could go wrong while the model is doing its thing, and
let them pass through my Action classes to the JSPs.  The JSPs will
handle the exceptions by cross-referencing the exception type to a
message key.. and the user will get an error message in their native
language.

The main problem with this approach is that a lot of things can go
wrong in an application, and this will entail a large number of
exception classes.  An ultimate goal of MVC is to keep the application
maintainable as it grows.  A large number of documented exceptions
*seems* reasonably maintainable... but I haven't started coding yet. :)

So, I hope to learn from your experiences.  What have you people done
when a login fails, a database goes away, a resultset overflows, or
other nasty things happen to the business layer?

Thanks!

-- 
Jonathan Fuerth - SQL Power Group Inc.
(416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free)
Unleash the Power of your Corporate Data - www.sqlpower.ca

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Bug in struts-1.0 framework

2001-07-09 Thread Jonathan Fuerth

Hello!  I've discovered a bug in the struts initialisation:

If the data source specified in struts-config.xml is not valid, then
the initialisation steps that are normally performed after setting up
the data source are skipped!  The steps are below:

2001-07-09 05:23:33 - path=/pt :jsp: init
2001-07-09 05:23:33 - path=/pt :action: init
2001-07-09 05:23:33 - path=/pt :action: Loading application resources from resource 
ApplicationResources
2001-07-09 05:23:33 - path=/pt :action: Initializing configuration from resource 
path /WEB-INF/struts-config.xml
2001-07-09 05:23:33 - path=/pt :action: Initializing application data source 
org.apache.struts.action.DATA_SOURCE
[*** If there's an exception here, the following two lines are not
present in tomcat's servlet.log ***]
2001-07-09 05:23:34 - path=/pt :action: Process servletName=action, urlPattern=*.do
2001-07-09 05:23:34 - path=/pt :action: Mapping for servlet 'action' = '*.do'

Hope this one's not too tough to fix. :)

Thanks!

-Jonathan Fuerth



Connection Pool from JSP tag?

2001-07-06 Thread Jonathan Fuerth

Hello!

I've made up a custom JSP tag that I'm using with a struts
application: It loads an organisation hierarchy from a JDBC data
source and renders it to HTML.

My question is this: How does my JSP custom tag class ask the Struts
connection pool for one of its connections?


Thanks!

Jonathan Fuerth



Form Bean Validation

2001-06-27 Thread Jonathan Fuerth

Hi.  I'm new to struts (I've been working on my first struts webapp
for the past few days), but I have a design question to ask:

Why is there a separate validation call to an ActionForm?  Isn't the
normal JavaBeans PropertyVetoException model cleaner and easier to
maintain?

I may well be missing the point.  Is there some design pattern in the
validate() method which doesn't make the programmer separate
validation from the property setter method, which is also compatible
with PropertyVetoException?

Thanks!



Re: Form Bean Validation

2001-06-27 Thread Jonathan Fuerth

On Wed, Jun 27, 2001 at 09:27:13AM -0700, David Winterfeldt wrote:
 The ActionForm is considered to be a container for
 holding and preserving the information the user has
 entered.  So you don't want to reject any data at this
 level because if the validation fails you want to
 return exactly what the user has entered.  So most

Aha!  Ok, that makes a few things clearer in my head.  Unfortunately,
it also raises some new questions. :)

For instance, how would you go about modeling this generic and (I
imagine) common web-application scenario:

-A server-side validated form is presented to the client, who is
expected to make mistakes.
-The server catches the mistakes and presents the previous values to
the user, flagging the ones that need to be re-entered.
-Finally, the user gets everything right.  A page is presented to the
user which summarises the input, along with an accept or cancel
choice at the bottom.
-The user gives the go-ahead, and the correct information is stored in
a JDBC-accessed database.
-Later, the user (or other interested parties) will be presented with
this data.

This is essentially what I've been trying to figure out for a year now
(when I first got into servlets).  In my experience, the fields in the
form will change fairly often, as will their default values and
acceptable ranges.  What I'm aiming for is to be able to perform this
sequence of events for any given set of database-stored data, while
only specifying the labels, datatypes, defaults, accepted ranges, and
underlying SQL statements once (and hopefully in one place, but that
may be too much of a stretch).

Have you (or other struts users) managed this feat yet?  I'm very
interested in anything anyone has to say on this topic.. It's become
an obsession (since my full-time job is to design and implement
java-based, RDBMS-backed web applications).


 * When the exception/validation happens in the setter,
 you can't do things that depend on other fields.  Like
 this field is required only if another field is filled
 in.

Ok, excellent point.  That JavaBeans constrained property model kind
of relies on an AWT/Swing-type GUI, where this isn't an issue.  As
you've observed, it's certainly an issue in a web application.
Dependant fields would have to be informed whenever their dependencies
change value.

 Also the current system isn't able to handle an
 exception being thrown during the auto-population of
 the ActionForm from the request.

Ok.  It sounds like I'll have to make a similar (but different) bean
to each FormAction bean which does the actual database manipulation
and stuff.  That throws me off my little quest for the
single-specification-of-everything-in-the-form paradigm. :)

Thanks for your reply.