Re: no action object

2001-12-18 Thread Brian K. Buckley

> Is it possible to forward to something without
> creating an action class and coding the perform
> method?



Or one could write a NullAction class... 

public class NullAction extends Action {
  public ActionForward perform(ActionMapping mapping,
  ActionForm form,
  HttpServletRequest request,
  HttpServletResponse response){
  return mapping.findForward("success");
  }
}

And use it like this...


  



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




extending StrutsValidator

2001-11-30 Thread Brian K. Buckley

Hello,

I've attempted to write my own Validator class by extending StrutsValidator.
My class adds my own static validate method.  It doesn't work.  Instead,
when I use it I get a message appearing in the Tomcat console
"Validator::validate() reflection - MyValidator".

What's wrong?  Is this a proper use of the Validator framework?

Shown below is my class and also my corresponding validator entry in my
validate.xml file.

-Brian

public class MyValidator extends StrutsValidator {

public static boolean validateWidget(Object bean,
ValidatorAction va, Field field,
ActionErrors errors,
 HttpServletRequest request, ServletContext
application) {
  ...

}






--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: [Newbie] Display multiple error messages in a list

2001-09-25 Thread Brian K. Buckley

>Otherwise it works like html:errors.

Will html:messages replace and deprecate html:errors?





Re: [Newbie] Display multiple error messages in a list

2001-09-25 Thread Brian K. Buckley

The examples I've seen solve this by mixing html formatting right in with
the error messages.

error.myerror=This is my error message

This seems like bad practice to me.  If one needs to display errors in a
different format, one has to rewrite the errors files.

It seems to me html:errors would be more flexible if it were changed to
allow one to go, for example,



Comments?




how to capture html

2001-09-24 Thread Brian K. Buckley

Is there a good way to capture the output from a snippet of jsp into a
String variable that can be reused multiple times in a page?

- Brian

As a simple example, if one needed to have the line:

Name

appear in several places, how can one set a String namerow so that the line
can be redisplayed by saying <%=namerow%> instead of repeating the whole
snippet?  Note that the snippet includes a custom tag.






Re: populate form using parameters instead of form

2001-09-16 Thread Brian K. Buckley

Thanks Eric,  Just asking those question make me study things harder and I
got it working.  Amongst other things, I was omitting the input attribute
necessary to tell struts where to go if there are errors.




Brian





populate form using parameters instead of form

2001-09-16 Thread Brian K. Buckley

Hello,

I have a working MyForm subclass ActionForm.  Elsewhere in my application,
I'd like to use the same MyForm but populate it using the parameters in the
httpquest (the querystring), so that a user can click on a link (setup with
the appropriate querystring) to submit data.

To get this done, one could just process the parameters in the perform
method of the Action class, but since the MyForm and its validate() already
contains the logic I need, I've rather reuse it.

I've found that if I go  in struts-config.xml, but
access that action from a link, I get an "Attempted a bean operation on a
null object" error.

Is there a way to do what I'm trying to do?

Brian




Re: LogoffAction example

2001-09-05 Thread Brian K. Buckley

Alright :).

I was thinking it might have been intentional to give any
HttpSessionListeners a chance to do something.

I'm not clear on when HttpSessionBindingEvents occur - do they happen
automatically when a session timesout or sesion.invalidate() is called, or
do they happen only when it removeAttribute() is explicitly called as in
LogoffAction?

- Brian

> Thats what is called as paranoid cleanup-lol

> >Hi, In LogoffAction in the struts example,  the main three lines are:
> >
> >session.removeAttribute(Constants.SUBSCRIPTION_KEY);
> >session.removeAttribute(Constants.USER_KEY);
> >session.invalidate();
> >
> >What is the purpose of the first two lines - why bother removing the
items
> >right before the session is invalidated?





LogoffAction example

2001-09-05 Thread Brian K. Buckley

Hi, In LogoffAction in the struts example,  the main three lines are:

session.removeAttribute(Constants.SUBSCRIPTION_KEY);
session.removeAttribute(Constants.USER_KEY);
session.invalidate();

What is the purpose of the first two lines - why bother removing the items
right before the session is invalidated?

-Brian




Re: display error messages for errors found in an Action

2001-09-04 Thread Brian K. Buckley

>  yes, you can do this.  If you have a message in your
> ApplicationResources file called my.test.error, you can add an error
> like this:
>
> errors.add("myTestField", new ActionError("my.test.error"));
>
> where the string  "myTestField" is the field that caused the error.
>  Look at the constructor for org.apache.struts.action.ActionError for
> more details.

Bill,

Yes but how do I access that errors object from the perform() method of
Action?  (or if we create a new ActionErrors object, where do we put it
since perform() returns an ActionForward object, not an ActionErrors
object).

I wanted to be able to add the errors in the perform() method of my action
object so that when the perform method returned for example,
"mapping.findForward("failure")", the appropriate errors messages get
displayed with the  tag in the jsp.

-Brian




display error messages for errors found in an Action

2001-09-04 Thread Brian K. Buckley

Hi,  I'm a relative struts newbie, seeking advise.

I have a class MyForm and in the validate() method of MyForm I check for
input errors and add them to the ActionErrors object which gets returned.

Later in my MyAction action, I check for additional business logic type
input errors.  If I find errors, I want to put them into to the same error
list that the form's ActionErrors creates, so that  in my jsp
pages can display them the same way.

Is there a way to do this?

-Brian




struts and Geary's templates

2001-08-28 Thread Brian K. Buckley

Hi,

I'm using struts along with the template tags from David Geary's Advanced
JavaServer Pages book.

As described in the book, I have defined all my pages in a single definition
file (for example, regionDefinitions.jsp shown below), and in order to use
the pages, I have created 2-line jsp files for each id in the definition
file, each of which calls region:render for the id (example below).

Is there a way in struts to avoid creating all these little helper jsp
files?  It would be cleaner to be able to just name ids in the actions and
forwards of the struts-config.xml file rather than having to name jsp files.

Besides being bothersome, changes to the basic template file do not "take"
automatically - it is necessary to "touch" each helper jsp file before
Tomcat knows to recompile pages.

Any suggestions or comments?

- Brian

--
regionDefinitions.jsp--


   
   



  ...



  ...


etc...

--

--
myfirstPage.jsp--
<% @ include file="regionDefinitions.jsp %>
<% region:render region='myfirstpage'/>

--

--
mysecondPage.jsp--
<% @ include file="regionDefinitions.jsp %>
<% region:render region='my2ndpage'/>

--

--
my3rdPage.jsp--
<% @ include file="regionDefinitions.jsp %>
<% region:render region='my3rdpage'/>

--

etc...







Re: Help with logic:iterate

2001-08-22 Thread Brian K. Buckley

Wow, that's nice!

One minor fix I needed was to put the collection onto the request prior to


<% Collection songs = SongCache.getInstance().fetchAll(); %>

  <% pageContext.setAttribute("songs", songs); %>
  


- Brian





Re: Cannot retrieve mapping for action

2001-08-13 Thread Brian K. Buckley

Tom,

Thanks for your help.  With all the struts traffic, I missed your response
at first.

It turns out that my problem was I was I was saying




Cannot retrieve mapping for action

2001-08-09 Thread Brian K. Buckley

Hi,  I'm a brand new Struts user.  I installed the struts 1.0 binary and I'm
attempting to work through a struts trailmap tutorial (the one at
bluestone.com).

I am getting a Servlet Exception with the message "Cannot retrieve mapping
for action /custom" when I call a simple input.jsp.  My input.jsp, my
struts-config.xml and a piece of my web.xml are shown below.

Can someone suggest what is causing this errror?

Thanks,

-Brian

* input.jsp**




* struts-config.xml**
http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd";>






  


  



* piece of web.xml***
 
 action
 org.apache.struts.action.ActionServlet
  
   mapping
   custom.CustomMapping
  
 
   config
   /WEB-INF/struts-config.xml
  
 
  validate
  false
 
 
  application
  helloworld.HelloWorldResources
  
 2