• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts validation - blank screen

 
Geoff Boushey
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has anyone had a problem with a blank screen on struts validation?
i.e., something like...

public ActionErrors validate(ActionMapping, HttpServletRequest request) {
ActionErrors = new ActionErrors();

if(form_field_1.equals("")) {
errors.add("form_field_1", new ActionError("error.input.notValid"));
}

return errors;
}

This actually worked earlier for me, but now I'm getting a blank screen when I submit the form with no value in form_field_1 (or whenever the if clause fails).

Any ideas as to why this is happening?

Thanks
 
Vani Bandargal
Ranch Hand
Posts: 82
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you saving the errors in request? You can see the thread "Srver side struts validation" which started earlier this week. It is good and will give you some idea.

http://www.coderanch.com/t/52301/Struts/server-side-struts-validation
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A blank screen usually means a bad forward. In your case, possibly no forward at all.

When validate="true" is set and validation fails, you'd better also have a input="" in the ActionMapping to tell the Front Controller where to navigate to when navigation fails. The input's value usually specifies a jsp or tile definition.
 
Geoff Boushey
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marc,

Thanks for the reply. The strange thing here is that it *does* work unless the if clause catches an error. So my input= configuration does work for form processing... just not for error handling.

I found a thread from a couple of months ago that seems to describe the same error...

http://forum.java.sun.com/thread.jspa?threadID=634680&messageID=3688289

I think you're right about the forwarding problem - I carefully stepped through my code through my code and found that the action is recognized, the actionform is created, and the validate method gets called. The only thing left to do is forward the request, as far as I can tell. But strangely, it isn't happening - just a blank screen.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Geoff Boushey:
Hi Marc,

Thanks for the reply. The strange thing here is that it *does* work unless the if clause catches an error. So my input= configuration does work for form processing... just not for error handling.


When validate="true" is set and validation fails, you'd better also have a input="" in the ActionMapping to tell the Front Controller where to navigate to when navigation fails. The input's value usually specifies a jsp or tile definition.

The input becomes your forward only when there are errors returned from the ActionForm's validate method.
[ October 26, 2005: Message edited by: Marc Peabody ]
 
Geoff Boushey
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marc,

here's an excerpt from my struts-config file...



(note - all my jsp's are in a subdirectory named jsp)

Does this have the "input=" parameter that you're referring to?

I greatly appreciate the help.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting. The input= is correct but I am concerned that "/jsp" is part of your ActionMapping's (the action tag's) path. Maybe it's fine and I'm just too used to tiles.

So is this snippet the way it's always been or did you just now add input=?
 
Geoff Boushey
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately, the "input=" has always been there.

This isn't too much of a surprise. I started by writing a very simple application, got the validation working, and then started elaborating on it (i.e., taking an iterative approach). Somewhere along the line, I must have added something that broke the validation.

It's pretty clear that something has gone wrong with the mapping. Unfortunately, I'm not getting an error message from struts (I've noticed some bug reports about struts failing silently). One possiblity is to go into struts and try to generate some outputs, but I think I'll just try retracing my steps first - ie., try to reconstruct the app from the simple one that works and see if I can figure out how and where this problem is happening.

Anyway, if I figure this out, I'll post a summary of what was going wrong. Thanks for your responses.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For what it's worth, I have seen people report the blank screen issue when their struts configuration was broken... I think usually because of a bad classpath or something. Rarely though do those reports say that it was working and all of a sudden isn't working. Usually these come from people following a Hello World tutorial and forgot a step.

You might be able to find something about that by searching the archives here.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic