Java Development with Ant

2002-12-28 Thread Erik Hatcher
All -

I'm proud (and worried about the support e-mails! :) to announce the 
near-final release of a project demonstrating Ant, XDoclet, Struts, 
JUnit, Cactus, and Lucene.  Its called JavaDevWithAnt as it was written 
for the book Steve and I co-authored and has been refined during 
several presentations I've been giving on Ant, XDoclet and Struts.

The documentation is in draft stage, and my primary goal is to collect 
feedback on polishing the documentation (and the application if there 
are any bugs that surface).  The site where I'm hosting the 
distribution and documentation is:

	http://www.ehatchersolutions.com/JavaDevWithAnt/

Please let me know if you try it out and have suggestions for 
improvement, or just to let me know you tried it and hate it or love 
it, etc.  Feedback more than welcome!  Direct feedback to me at 
[EMAIL PROTECTED]

	Erik

p.s. Since this is directed to the Struts lists, here are some hilights:

- XDoclet generation of struts-config.xml and validation.xml
- Custom XDoclet generation of starter JSP and application properties 
based on form bean source code
- My proudest taglib, LabelTag - shows fields in error and marks 
required fields with an asterisk.
- Use of StrutsTestCase in Cactus mode to test a Struts Action.


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



Re: LookupDispatcherAction

2002-01-09 Thread Erik Hatcher

Could you please provide the code that is causing this problem along with
the ApplicationResources.properties file that contains the mappings?

Have you checked the Javadoc for LookupDispatchAction to ensure you've got
all the pieces configured properly?

Erik

- Original Message -
From: Michael Clay [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Wednesday, January 09, 2002 7:32 AM
Subject: LookupDispatcherAction


Thanks! have allready found it..but now I found out a null pointer exception
in LookupDispatcherAction... it seem's like that the LookupDispatcherAction
want's to get a Ressource (MessageResources resources =
servlet.getResources();) wich never was initialized in the ActionServlet...

java.lang.NullPointerException

at
org.apache.struts.actions.LookupDispatchAction.perform(LookupDispatchAction.
java:216)

:-(

-Ursprüngliche Nachricht-
Von: Tom Goemaes [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 09. Jänner 2002 02:27
An: Struts Users Mailing List
Betreff: Re: Commons Logging Lib??

try
http://jakarta.apache.org/commons/index.html
:)


 Struts Users Mailing List [EMAIL PROTECTED] wrote:


Anybody knows where I can find/download the lib where this
class-org.apache.commons.logging.LogSource belongs in ??

Many thanks mc




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

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




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




Re: LookupDispatcherAction

2002-01-09 Thread Erik Hatcher

CC'ing over to dev as it seems that something has been broken.

I don't have the bandwidth right now to track down what the issue is, but
I'm successfully using LookupDispatchAction with no problems with an earlier
nightly build.

Also, its LookupDispatchAction, not LookupDispatcherAction - just to be
clear and avoid confusion!  :)

Ted?  Did something change that could have affected this?

Erik


- Original Message -
From: Michael Clay [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Wednesday, January 09, 2002 7:48 AM
Subject: AW: LookupDispatcherAction


Hi!

1. I have the latest nightly build 20020109

2. i think the LookupDispatcherAction shoud take the ressource from the
servletcontext (MESSAGES_KEY) instead of calling servlet.getResources()
because this returns an MessageResources (named application in
ActionServlet) wich was never be constructed ..see
//initApplication(); // Replaced by new-style initialization

3. my properties file


*** Method's for LookupDispatcherAction

method.load=Open
method.open=Open

4. my code is same as your sample from

http://www.mail-archive.com/struts-user@jakarta.apache.org/msg18378.html

Michael

-Ursprüngliche Nachricht-
Von: Erik Hatcher [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 09. Jänner 2002 13:40
An: Struts Users Mailing List
Betreff: Re: LookupDispatcherAction

Could you please provide the code that is causing this problem along with
the ApplicationResources.properties file that contains the mappings?

Have you checked the Javadoc for LookupDispatchAction to ensure you've got
all the pieces configured properly?

Erik

- Original Message -
From: Michael Clay [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Wednesday, January 09, 2002 7:32 AM
Subject: LookupDispatcherAction


Thanks! have allready found it..but now I found out a null pointer exception
in LookupDispatcherAction... it seem's like that the LookupDispatcherAction
want's to get a Ressource (MessageResources resources =
servlet.getResources();) wich never was initialized in the ActionServlet...

java.lang.NullPointerException

at
org.apache.struts.actions.LookupDispatchAction.perform(LookupDispatchAction.
java:216)

:-(

-Ursprüngliche Nachricht-
Von: Tom Goemaes [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 09. Jänner 2002 02:27
An: Struts Users Mailing List
Betreff: Re: Commons Logging Lib??

try
http://jakarta.apache.org/commons/index.html
:)


 Struts Users Mailing List [EMAIL PROTECTED] wrote:


Anybody knows where I can find/download the lib where this
class-org.apache.commons.logging.LogSource belongs in ??

Many thanks mc




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

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




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

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




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




Re: Programs become deprecated using nightly build 20011231 and onwards?!

2002-01-01 Thread Erik Hatcher

Do just what the message says... compile with deprecation warnings enabled.
If you are building with Ant (and who wouldn't?! :), then your javac task
should have deprecation=true.

Perhaps your build is using a property instead of true though
(deprecation=${build.deprecation}, perhaps), in which case run the build
with -Dpropertyname=true

Erik


- Original Message -
From: Steven Cheung [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, January 01, 2002 8:37 PM
Subject: Programs become deprecated using nightly build 20011231 and
onwards?!


 I encountered the following warnings when I compile my 'Form', 'Action'
 programs after I use nightly buidld 20011231 or 20020101.

 How can I check which functions I used was deprecated? ( as the
 application I am writing buids from the 'templete' of struts 'example')

 // begin
 Note: Some input files use or override a deprecated API.
 Note: Recompile with -deprecation for details.
 // end

 thx a lot

 Steven


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




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




Re: Reload resources without restarting server

2001-12-26 Thread Erik Hatcher

Actually if you look at the end of struts-config.xml; that is where you'll
find it (from the example, at least).

The action is /admin/reload.do - and is a real time-saver!

Erik


- Original Message -
From: Chen, Fang [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, December 26, 2001 11:35 AM
Subject: Reload resources without restarting server


 Hi, guys,

 I am pretty new to Struts. I was reading the Walk Through of the struts
 example from the struts installation. In the document, it is said that
You
 can even reload the configuration and message resources without restarting
 the container. See the end of the web.xml file for details. I do not know
 where I can find how to do this. Any help will be appreciated.

 Thanks,

 Fang Chen





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




Re: Form initialization and frames

2001-12-22 Thread Erik Hatcher

I have just tackled this very issue.  I did try to make my solution
extremely generalized, but I haven't decided if/when it will be ready to
contribute back.  But I will describe its architecture:

In our application we have many two-frame pages, top containing criteria,
bottom containing results.  I have a single action that I call
/subsystem/searchSetup.do that forwards to the two-frame JSP page. I have
a FramesetData object that is session-scoped. It encapsulates action errors,
criteria (a value object representing the form bean from the top frame,
typically), and the results (yes, results are stuffed into session, and I'll
explain why below).

The searchSetup.do action pulls action errors from request scope and puts
them into the FramesetData object, and the criteria and results, if present
in the request, are put into the FramesetData object also.  The FramesetData
object is keyed in session-scope by its action mapping path (up to the last
forward-slash) - which makes it unique for all such pages in our system.

The top-frame's form targets _top and its action performs the search based
on the criteria, so that all form validation errors and errors generated
from the action get put into request scope as well as the criteria and
results (these get keyed with a prefix matching the session key - but only
get stored in request scope here).

Both the top and bottom frames are .do links, and the top frame's action
fetches any drop-down boxes needing populated, fetches the criteria from the
FramesetData object and re-populates the form.  The bottom frame's action is
generalized to simply make a request scoped attribute called results with
the results from the FramesetData object.

Results are stored in session because I wanted to make sure any errors
generated during the creation of those results gets sent to the top frame.
The form submit button forwards back to the searchSetup.do action so both
frames get recreated when the submit button is pressed.  Our application is
not designed for heavy use, and when/if the memory eaten by the results in
session become an issue it will be addressed, but for now its working
nicely.

I'm not sure I've covered all the pieces of the framework I've created,
but hopefully that is enough food for thought.  I'd be interested in hearing
how others have tackled this tricky issue.  I'm not at all a fan of frames,
but this solution made it at least workable to achieve the UI features
desired.  If there are any questions on this I'd be more than happy to
answer them.

Erik



- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, December 21, 2001 7:24 PM
Subject: Form initialization and frames


 We have a jsp called search.jsp that looks something like this

 frameset ...
   frame name=header src=header.jsp noresize scrolling=no/
   frameset ...
 frame name=criteria src=criteria.jsp noresize scrolling
 =no/
 frame name=results src=results.jsp noresize scrolling
 =auto/
   /frameset
 /frameset

 I have a CriteriaForm that I want to prepopulate some data on using an
 Action whenever the user goes to this page. I also want the form stored on
 the request not the session. The problem is that my forward from the
Action
 has to go search.jsp after it populates the form so the form tag on
 criteria.jsp cannot find the form on the request. It just creates a new
 instance of the form.

 I don't want to put it on the session because I don't want to have to
worry
 about cleaning it up off the session.

 This is a small section of a large app ( a few hundred jsp's ) so I have
 simplified things a bit.

 We think we are kind of stuck with frames because as you can probably
guess
 we want the results to show up below the criteria and we want to be able
to
 scroll the results without scrolling the criteria off the screen.

 It is an existing app that we are strutsifying so changing look and feel
is
 not really an option.

 Does anyone have a way to do this?

 Thanks

 2

 Mike Two; Putting the tWo in Thoughrks


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




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




Re: multiple buttons on a form

2001-12-12 Thread Erik Hatcher

Yes.

The nightly builds contain a patch I submitted, called LookupDispatchAction.
It keys off of the use of ApplicationResource messages for button labels and
allows reflection to call a different method for each button pressed.  The
Javadocs explain it in great detail.

Even without that base class action, you'll get the button label as a
request.getParameter(action) if all your buttons have the name action.
But using the button label in an Action greatly munges the View with the
Controller and makes things fragile (Java shouldn't break if a button label
is changed in the JSP).

Erik


- Original Message -
From: Lachlan Holmes [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Wednesday, December 12, 2001 7:25 PM
Subject: multiple buttons on a form


Is there a way to have multiple submit buttons on a form and be able to tell
which button was pressed in the following action?

Regards,
Lachlan



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




Re: Hidden Field in a form. Do I use struts taglib or vanilla html?

2001-11-30 Thread Erik Hatcher

I believe Ted actually means 'reset()' instead of 'init()'.


- Original Message -
From: Ted Husted [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, November 29, 2001 11:15 AM
Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla html?


 In Struts 1.0.1, init() is called if the ActionForm is instantiated by
 the JavaServer Page. In Struts 1.0, this only happens when the
 ActionForm is instantiated by the ActionServlet. Of course, any default
 values assigned to the fields in the ActionForm class itself will be
 available in either case. The recommended control flow is to go through
 an Action first, and populate the ActionForm there. Populating the
 ActionForm from the JSP is a Model 1 strategy.

 -- Ted Husted, Husted dot Com, Fairport NY USA.
 -- Custom Software ~ Technical Services.
 -- Tel +1 716 737-3463
 -- http://www.husted.com/struts/


 David Lauta wrote:
 
  Is there a method in the framework that gets invoked allowing you to
  initialize the ActionForm before the JSP is displayed?
 
  Brett Porter wrote:
 
   That's an interesting design decision. I have always had a form bean
and
   then another bean containing the actual data. The action copies it
across,
   processes it, and stores it.
  
   The reason I'd do it that way is that I imagine the message is a
business
   class, and you don't really want you model polluted by extending an
   ActionForm. Maybe I've been living in OOAD land too long though ;)
  
   This can trip you up though - at least once I have added the form
element,
   added it to the bean, added it to the form bean, and forgetten to do
the
   setter in the action :) The way around that is probably a function in
the
   form bean that says fill my business class and fill from a business
   class. Actually, I might put that in my todo list :D
  
   Cheers,
   Brett
  
   -Original Message-
   From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
   Sent: Thursday, 29 November 2001 12:48 PM
   To: Struts Users Mailing List
   Subject: Re: Hidden Field in a form. Do I use struts taglib or vanilla
   ht ml?
  
   The data I am storing in the bean is logically different from what the
   hidden field value is,  I have a message
  
   message
   {
  string  Recipent
  string  From
  string  MessageBode
   }
  
   And the hidden field is   action=sendMessage and I didn't think that
  
   message
   {
  string  Action
  string  Recipent
  string  From
  string  MessageBode
   }
  
   would be the correct thing to do, but I am open to suggestions.  If it
   works out easier to put this extra field in my message formbean then I
   will do it.  What do you think?
  
   Cheers
  
   Tony
  
   Brett Porter wrote:
  
The question I ask is why you wouldn't put it in your form bean?
   
I prefer form.getAction() over httpServletRequest.getParameter(
action )
any day! :)
   
-Original Message-
From: Yee Keat [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 29 November 2001 12:36 PM
To: Struts Users Mailing List
Subject: Re: Hidden Field in a form. Do I use struts taglib or
vanilla
html?
   
   
Yup, using the taglib makes it compulsory to have that field in your
FormBean
   
On Thursday 29 November 2001 09:25 am, you wrote:
   
   Hi
   
   I want to include a hidden field in a form which I have.  I do not
want
   this information to be included in the formbean which is defined for
   this page.  How can I do this?  Should I just use plain html
   
   INPUT TYPE=hidden NAME=action VALUE=send
   
   without using the html taglib supplied with struts?
   
   Cheers
   
   Tony
   
   
  
   --
   To unsubscribe, e-mail:
   mailto:[EMAIL PROTECTED]
   For additional commands, e-mail:
   mailto:[EMAIL PROTECTED]
 
  --
  Thank you,
  David Lauta
  [EMAIL PROTECTED]
  (561)272-2698
  (561)289-0502 cell
 
  --
  To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
  For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

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




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




Re: Forward session

2001-11-28 Thread Erik Hatcher

Sessions and forwards have nothing to do with one another (unless of course
your in some kind of load balanced server farm and aren't using session
affinity or something like that).

In other words, sessions and forwards work fine together.  Care to share the
error you're getting when using a forward?



- Original Message -
From: Frot [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Wednesday, November 28, 2001 3:29 PM
Subject: Forward  session


Hi,

Small questio : big problem.

In servlets a forward does not seem to work when in a session !?
Is this a correct assumption/observation ??

Currently I have to replace all forwards by redirects, resulting in some
unwanted behaviour when
hitting the back button.

If it is not possible to use forward while in a session : is there a
session-save forward ??? Or do I have to use another method ??

Thanx, Fred


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




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




Re: Hidden Field in a form. Do I use struts taglib or vanilla html?

2001-11-28 Thread Erik Hatcher

Won't hurt.

You'll just have to use request.getParameter(action) in your Action to get
it.


- Original Message -
From: [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Wednesday, November 28, 2001 8:25 PM
Subject: Hidden Field in a form. Do I use struts taglib or vanilla html?


 Hi

 I want to include a hidden field in a form which I have.  I do not want
 this information to be included in the formbean which is defined for
 this page.  How can I do this?  Should I just use plain html

 INPUT TYPE=hidden NAME=action VALUE=send

 without using the html taglib supplied with struts?

 Cheers

 Tony



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




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




Re: dynamic images

2001-11-23 Thread Erik Hatcher

I'd recommend a custom tag for URL's that get pulled from the DB for a
couple of reasons - it probably won't be long before you'll want to offload
them from serving directly from the DB, so the URL could switch, scriptlets
are *bad* (in a Struts environment).  You'll want to direct the URL to a
servlet that reads it from the DB and serves up the proper MIME type.

We did this in my last extensive Struts endeavor and made the URL's part of
a properties file so that for development purposes they could serve straight
from a DB accessing servlet, and in a production environment the URL's
generated were being served directly from Apache and the images got
automatically pulled to static files from the DB when they did not exist in
the cache.

Erik

p.s. And no, you can't nest taglibs like that.  :)


- Original Message -
From: Sean Owen [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, November 23, 2001 3:35 AM
Subject: Re: dynamic images


 I think you will need to do this:

 html:img src=%=card.getImageLink()% ...

 As far as I know you can't nest tags like this. If someone has a better
way
 I'd like to see it!

 Sean


 - Original Message -
 From: Henrick Chua [EMAIL PROTECTED]
 To: Struts Users Mailing List (E-mail) [EMAIL PROTECTED]
 Sent: Thursday, November 22, 2001 6:58 PM
 Subject: dynamic images


  Hi!
 
  how can I display images whose source URL comes from the database? and
how
  can I display it's corresponding alt property?
 
  I keep getting an error message on this code:
 
  html:img src=bean:write name=card property=imageLink
 width=168.5
  height=88 border=1  align=texttop alt =bean:write name=card
  property=imageDescription /
 
  thanx.
 
  h
 
  --
  To unsubscribe, e-mail:
 mailto:[EMAIL PROTECTED]
  For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]


 _
 Do You Yahoo!?
 Get your free @yahoo.com address at http://mail.yahoo.com


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




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




Re: which button pressed?

2001-11-20 Thread Erik Hatcher

Careful with this you're tying your View with your Controller by way of
the button text.  If  your button text changes, so will your Action code.  A
better solution in the case where the button name is the same for all
buttons is to use a solution I proposed on struts-dev recently:

http://marc.theaimsgroup.com/?l=struts-devm=100577282829753w=2

The code posted will work as-is - I just want to split it up some more.

Erik


- Original Message -
From: emmanuel.boudrant [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Tuesday, November 20, 2001 10:20 AM
Subject: Re: which button pressed?



  Hi,

 I suggest you to use : html:submit property=propertyname
value=buttonname/
 ex:
 html:submit property=myAction value=add/
 html:submit property=myAction value=del/
 and in Action class, to determine witch button is pressed:
 String button = request.getParameter(myAction);
 if ( button.equals(add) ) { ... }

 But I don't know if html:submit property=propertyname
value=/bean:message ... // work ?
   Màris Orbidàns [EMAIL PROTECTED] a écrit :
 Hello all

 I have several submit buttons like this:




 key=button.prev/
 key=button.next/
 key=button.save/
 key=button.delete/
 key=button.add/



 The question is: How to determine which one has been pressed ?


 Maris Orbidans



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



 -
 Yahoo! Courrier -- Une adresse @yahoo.fr gratuite et en français !



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




Re: multiple html:submit buttons with different names?

2001-11-14 Thread Erik Hatcher

By the end of the day I'll have a LookupDispatchAction.  I started to call
it MultiButtonDispatchAction, but it really will be more generic such that
it will look up messages from ApplicationResources.properties and return
back the key so that the Action is not tightly coupled with the JSP page
text. (I'm open to suggestions on the class name though).

I'll submit it to the list tonight hopefully, for review.

Ted will have to update his FAQ very soon!  No JavaScript will be used in my
solution.  :)

Erik




- Original Message -
From: Ted Husted [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Tuesday, November 13, 2001 2:33 PM
Subject: Re: multiple html:submit buttons with different names?


 http://jguru.com/faq/view.jsp?EID=543699

 Rob Breeds wrote:
 
  Hi
 
  Is it possible to have multiple html:submit tags in a  html:form
  different only in name such that the action can differentiate between
them.
 
  The docs indicate there is no 'name' attribute for the html:submit tag
  corresponding to the name attribute for a HTML input type=submit tag.
 
  Ultimately I want one form on the page, with several ways of submitting
the
  form depending on which section I'm in, and then have the final submit
  button indicate to the Action class that the form is complete.
 
  Any ideas please?
 
  Thanks
 
  Rob

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




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




Re: multiple html:submit buttons with different names?

2001-11-14 Thread Erik Hatcher

Rob,

See my recent LookupDispatchAction posted.  It currently does the key lookup
using the default locale, so I'm not sure it would cover your requirements -
but I don't think it would be hard to generalize it even more if the current
implementation won't work for you.

I'd be happy to try to accomodate your locale scenario into what I've
developed if you're willing to give it a try!

Erik


- Original Message -
From: Rob Breeds [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Tuesday, November 13, 2001 2:19 PM
Subject: Re: multiple html:submit buttons with different names?



 Brian

 That would work but what if the text on the button was multilingual, ie
 could be any one of 100 languages depending on user locale setting, which
 is what I have to support!

 Rob




 Brian Dainton
 daintons@yaho   To: Struts Users Mailing List
[EMAIL PROTECTED]
 o.com   cc:
  Subject: Re: multiple
html:submit buttons with different names?
 13/11/2001
 19:12
 Please respond

 to Struts
 Users Mailing
 List






 Rob,

 Assuming your FormBean has a getter/setter for action:

 td height=22 align=right
   html:submit  property=action value=Submit/
 /td
 td height=22
   html:submit  property=action value=Close/
 /td

 Within the action,  you could then assign the forward based on the value
of
 'action'

 MyFormBean form1 = (MyFormBean) form;
 String sAction = form1.getAction();

 if (sAction.equals(Submit))

 

 Brian

 --- Rob Breeds [EMAIL PROTECTED] wrote:
  Hi
 
  Is it possible to have multiple html:submit tags in a  html:form
  different only in name such that the action can differentiate between
 them.
 
  The docs indicate there is no 'name' attribute for the html:submit tag
  corresponding to the name attribute for a HTML input type=submit tag.
 
  Ultimately I want one form on the page, with several ways of submitting
 the
  form depending on which section I'm in, and then have the final submit
  button indicate to the Action class that the form is complete.
 
  Any ideas please?
 
  Thanks
 
  Rob
 
 
 
 
  --
  To unsubscribe, e-mail:   
 mailto:[EMAIL PROTECTED]
  For additional commands, e-mail: 
 mailto:[EMAIL PROTECTED]
 


 __
 Do You Yahoo!?
 Find the one for you at Yahoo! Personals
 http://personals.yahoo.com

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





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




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




[SUBMIT] LookupDispatchAction - how to handle multiple html:submit buttons

2001-11-14 Thread Erik Hatcher

As promised earlier today, here is my contribution to the multiple
html:submit button saga (Ted, time to update your FAQ! :)

Here is a breakdown of how to use it:

struts-config.xml segment, note the parameter=action
action path=/test
type=edu.darden.TestAction
name=TestForm
scope=request
input=/test.jsp
validate=true
parameter=action
forward name=success path=/results.jsp/
/action

ApplicationResources.properties segment:
button.add=Add Record
button.delete=Delete Record

TestAction.java (extends LookupDispatchAction) segment, the map is keyed by
ApplicationResources.properties
keys, and the value is the method name you want called (with the same
signature as Action.perform):

protected Map getKeyMethodMap(ActionMapping mapping,
ActionForm form,
HttpServletRequest
request) {
Map map = new HashMap();
map.put(button.add, add);
map.put(button.delete, delete);
return map;
}

public ActionForward add(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
System.out.println( ADD!);
return null;
}

public ActionForward delete(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
System.out.println( DELETE!);
return null;
}

And finally the JSP code segment:
html:form action=/test
html:submit property=action
bean:message key=button.add/
/html:submit
html:submit property=action
bean:message key=button.delete/
/html:submit
/html:form

I recommend the above usage in most cases to cut down on the 'if' statements
and making each unique action clearly defined in separate methods.

But, if there is ever a need to be more general with it, I have provided in
my base class the flexibility to handle dispatching to a single method for
all keys, providing the key to the method. I can only see this being useful
if you have a whole bunch of buttons and there is little difference in the
actions they perform and you only need to do minor logic based on the key.

Here is an example of this, note that if you implement getKeys (and do not
return null) that getKeyMethodMap is not used, so in all but the most crazy
cases would you ever implement both getKeys and getKeyMethodMap. I provided
the mapping, form, and request to these methods just in case someone wanted
to do some dynamic crazy stuff with the array or Map returned from these
methods, but I don't see those parameters being used in most cases.

protected String[] getKeys(ActionMapping mapping,
ActionForm form,
HttpServletRequest request) {
return new String[] {button.add, button.delete };
}

protected ActionForward perform(String key,
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
System.out.println( key =  + key);
return null;
}

I am out of town for a long weekend tomorrow, so I wanted to get this done
today and get it out to struts-dev for feedback.  I plan on providing Cactus
or Deryl's mock test cases for this (but if anyone wants to beat me to
generating those, feel free!) - for this I really just want to verify that
the correct methods get dispatched with the proper key and that error
handling is dealt with appropriately so Cactus isn't necessary.  I based it
loosely off of DispatchAction.  It would be nice if my invokeMethod was
actually pushed up to DispatchAction to avoid duplicate code and
DispatchAction refactored to use this helper method.

I believe I might have made this class a little too feature-rich and perhaps
it should be broken into two base classes - one to dispatch via reflection
to a Map specified mapping between key and method, and another to do the
dispatching to an enhanced perform method taking the key.  With two separate
base classes the getKeys, getKeyMethodMap and perform could all be made
abstract and remove some likely usage confusion.

My Javadoc comments need some work to encompass both ways of using my base
class, but both methods are documented in this message for now.

I welcome feedback and suggestions on this.

Erik






Re: Capturing an outgoing response.

2001-11-02 Thread Erik Hatcher

Are you running a Servlet 2.3 compliant app. server?  If so, Filters are
what you are looking for.  If not, you could add some scriptlet to the end
of each JSP (perhaps?) that could post-process the response before it is
finalized.

Erik


- Original Message -
From: Brandon Goodin [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Thursday, November 01, 2001 9:34 PM
Subject: Capturing an outgoing response.


 Is it possible to capture the html page that is generated by a jsp page
 before it is sent to the client who requested it?

 Brandon Goodin
 Phase Communications
 P (406)862-2245
 F (406)862-0354
 http://www.phase.ws




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




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




Re: Duplication of Template Files Solution

2001-11-01 Thread Erik Hatcher

This was intended to work this way and, like you, did not see it as a
possibility in the documentation.  Not satisfied with putting things into
separate files I searched the e-mail list for template:put and saw an
example someone had posted using it in-line and have used that method ever
since.

Erik

- Original Message -
From: Darryl Pentz [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, November 01, 2001 4:53 AM
Subject: Duplication of Template Files Solution


 I've discovered quite by accident that the Struts templating framework
 allows me to eliminate duplication of my JSP pages by simply including the
 body page inline to the template definition page. By this I mean I combine
 both pages into one as follows:

 template:insert ...
 template:put name=header ... /
 template:put name=nav ... /
 template:put name=body ... /

 ... BODY HTML GOES HERE ...

 /template:put
 /template:insert

 I'd previously enquired on this list how I could eliminate the duplication
 of the pages where the main body HTML exists in a separate JSP page that
is
 simply referred to from the definition file i.e. template:put name=body
 content=/blah/blah/body.jsp/. Strangely nobody responded with the above
 solution so I'm wondering is this simply a side-effect of the PutTag class
 or Craig, did you intend for it to work this way? I'm quite surprised I
 haven't seen this technique used in any of the examples. Rather, the
 duplication is suggested. The new Tiles extension allows the above which
 prompted me to try it with the Struts template tag library just for grins,
 and it worked!

 Is there a problem with doing it inline like I illustrate above? I looked
at
 the source code and I see the PutTag class does extend BodyTagSupport so
 everything should work fine. So far, the stuff I've played around with
seems
 to work fine with no problems.

 Any feedback would be appreciated.

 thanks,
 Darryl Pentz


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




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




Re: This list NEEDS a FAQ

2001-10-26 Thread Erik Hatcher

http://www.jguru.com/faq/Struts


- Original Message -
From: Mindaugas Idzelis [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, October 25, 2001 5:32 PM
Subject: This list NEEDS a FAQ


 Subscribers,

 This list NEEDS a FAQ badly. There are many many many questions that are
 asked repeatedly. It would be nice to refer them to a FAQ. I'd be willing
to
 put together a small FAQ. Please send me questions (and answers!! -- if
you
 have them) to [EMAIL PROTECTED] Please include FAQ in the subject. Thanks.

 Mindaugas Idzelis







Re: Real time web page?

2001-10-26 Thread Erik Hatcher

Also, the remote scripting API that I created has the capability of
short-circuiting responses in a similar manner.  Its application-dependent
how that logic works, either by message ID or by a date stamp or other
mechanism, as its just another parameter being passed from the client to the
server.

Erik

- Original Message -
From: Nathan Anderson [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, October 25, 2001 1:11 PM
Subject: RE: Real time web page?


 Dave,

 There is a sample servlet created by Marty Hall in his book Core Servlets
 and JavaServer Pages [ISBN: 0-13-089340-4].  In this sample he does just
 what Robert suggested, setting the refresh interval in the HTTP response.
 But the one twist that makes me mention this is he had a variable of the
 last time the data had changed.  So he compared this timestamp with the
last
 update sent to the http client.  If there was no change, then he sent a
 message to the client that no change has been made.  This can reduce the
 network traffic significantly [if your data doesn't change as frequently
as
 your refresh interval].

 He has made is code available to the public at the books website
 [http://www.coreservlets.com/].  To get more info on what/how he did it,
 you'll probably need the book [which IMO is a good one to have anyway].

 Nathan Anderson

 -Original Message-
 From: Robert Parker [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, October 24, 2001 7:32 PM
 To: [EMAIL PROTECTED]
 Subject: Re: Real time web page?


 Hmmm - http is typically connectionless, however there are a few tricks to
 give the impression of what you require...

 You can get the server to serve a multipart response and hence give a
 sequence of snapshots.
 You can set a refresh interval in the response header so that the browser
 requests the page again.

 Note that this essentially gives you a sequence of snapshots, rather than

 any 'real-time' updates...

 As an alternative - have you considered using a 'fat client' ie java
 application downloaded using jumpstart?

 regards

 Rob
 - Original Message -
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, October 25, 2001 2:16 AM
 Subject: Real time web page?


 
 
  Hi everyone.  We are starting a new project and have a requirement for
 real-time
  updates in a web browser.  Does anyone know of any tools that allow for
 this,
  apart from applets?
 
  Cheers,
 
  Dave
 
 
 
 







Re: Real time web page?

2001-10-25 Thread Erik Hatcher

Sure... Remote Scripting.

Check out a few articles I've written about it (which includes a couple of
servlet base classes to kick start the process):

Remote Scripting Using a Servlet
http://www.ibm.com/developerworks/library/wa-resc/

Pushing Messages to a Browser Using Remote Scripting
http://www.webreview.com/2001/05_04/developers/index01.shtml

Sending rich messages between client and server using asynchronous messaging
http://www.ibm.com/developerworks/library/wa-rich/

There are the usual browser issues to deal with in attempting to update the
UI dynamically without refreshing the page completely - but it can be done
in the latest browsers reasonably well.  The last article listed is probably
the best one to base an implementation off of, as its a rich API for
asynchronous messaging.

Erik


- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, October 24, 2001 12:16 PM
Subject: Real time web page?




 Hi everyone.  We are starting a new project and have a requirement for
real-time
 updates in a web browser.  Does anyone know of any tools that allow for
this,
 apart from applets?

 Cheers,

 Dave









Re: multibox and reset() ERIK

2001-10-02 Thread Erik Hatcher

Jeff,

No, my patch did not fix this particular case.   Here is what is happening
in your scenario: checkboxes do not submit a value if they are unchecked,
therefore Struts has no way of knowing of their existence on the original
HTML form and thus does not call any setters.  The reset method is where you
implement setting all your checkboxes (and likely other HTML field types) to
their default (false, in your case) value.

My patch was for the case where the ActionForm bean was created by a JSP
page rather than ActionServlet, and reset was not called at that point.   In
your case, the ActionForm bean is being created (in the last request you
speak of) by ActionServlet, so reset should be called - this is all assuming
you are going through a Struts action for that request.

My patch has been committed to Struts CVS, so its available in the nightly
builds (I presume, unless those builds are running on a different branch or
something).

Erik

- Original Message -
From: Krueger, Jeff [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, October 02, 2001 7:07 AM
Subject: RE: multibox and reset() ERIK


 Erik,

 I believe your patch will solve my problem but I'm not sure.  I have
 a page with many multibox tags on it.  When I select several of them my
form
 bean is correctly populated with a string array.  If I come back to the
page
 all the correct boxes are checked.  If I remove all the checks and click
 submit then my string array is left to what it was before.  I assume this
is
 because there is no mutliboxes being submitted to the server, therefore
the
 setMethod is never getting called.  Is that what you patch fixed, if so do
 you know the status of that making it into a build?

 Thanks

 Jeff


 -Original Message-
 From: Erik Hatcher [mailto:[EMAIL PROTECTED]]
 Sent: Friday, September 14, 2001 8:24 PM
 To: [EMAIL PROTECTED]
 Subject: Re: multibox and reset()


 reset is currently not called if html:form creates the form bean, which
 happens if you go to the JSP page directly without hitting ActionServlet
 first.

 I've submitted a patch to fix this, but it has not been committed yet.

 Erik


 - Original Message -
 From: Renaud Waldura [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Sent: Friday, September 14, 2001 10:12 AM
 Subject: Re: multibox and reset()


  The signature for reset() is the following:
 
  void reset(ActionMapping, HttpServletRequest)
 
  I don't know whether setting the array reference is null is enough, or
you
  truly need to create a zero-length array like in your example below.
 
  I set mine to null, it seemed to work.
 
 
 
 
  - Original Message -
  From: Dirk Jaeckel [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Friday, September 14, 2001 6:26 AM
  Subject: multibox and reset()
 
 
   Hi!
  
  
   I am having trouble resetting a StringArray that is connected to a
  html:multibox-tag.
  
   HTML-Example:
  
   html:form action=/map method=GET
   html:multibox value=parking property=layer/
   html:multibox value=petrol property=layer/
  
   html:image property=layers page=/img/update.gif/
  
   /html:form
  
  
   Corresponding ActionForm:
  
   public class MapForm extends ActionForm {
  
   private String[] _on = new String[0];
  
   public void reset() {
   _on = new String[0];
   }
  
   public void setLayer(String in) {
   _on = in;
   }
  
   public String[] getLayer() {
   return _on;
  
   }
   }
  
   The Manual told me to use the reset()-method to set The Array to the
  length 0, but reset() is never called.
  
  
   Dirk
  
  
 
 





Re: multibox and reset() ERIK

2001-10-02 Thread Erik Hatcher

The better way is just what was mentioned set your values to null
(false?) in the reset method.   But if you are using Struts 1.0 and not a
more recent build, also setting them in the constructor or initial values
when defined is a good idea to default them in the case you are navigating
directly to the JSP page rather than going through a Struts action to get to
the JSP page.

So more succintly, initialize values in reset and that should fix the issue
you described.   Did you try that?

Erik


- Original Message -
From: Krueger, Jeff [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, October 02, 2001 7:49 AM
Subject: RE: multibox and reset() ERIK


 Thanks Erik for the extra info.  I was thinking that was the problem I was
 having.  One idea that I had was to check in my action class to see if any
 check boxes were on the request and if not then call the set method myself
 setting it to null.  Does anyone know of a better way to do this.

 Thanks

 Jeff


 -Original Message-
 From: Erik Hatcher [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, October 02, 2001 8:49 AM
 To: [EMAIL PROTECTED]
 Subject: Re: multibox and reset() ERIK


 Jeff,

 No, my patch did not fix this particular case.   Here is what is happening
 in your scenario: checkboxes do not submit a value if they are unchecked,
 therefore Struts has no way of knowing of their existence on the original
 HTML form and thus does not call any setters.  The reset method is where
you
 implement setting all your checkboxes (and likely other HTML field types)
to
 their default (false, in your case) value.

 My patch was for the case where the ActionForm bean was created by a JSP
 page rather than ActionServlet, and reset was not called at that point.
In
 your case, the ActionForm bean is being created (in the last request you
 speak of) by ActionServlet, so reset should be called - this is all
assuming
 you are going through a Struts action for that request.

 My patch has been committed to Struts CVS, so its available in the nightly
 builds (I presume, unless those builds are running on a different branch
or
 something).

 Erik

 - Original Message -
 From: Krueger, Jeff [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, October 02, 2001 7:07 AM
 Subject: RE: multibox and reset() ERIK


  Erik,
 
  I believe your patch will solve my problem but I'm not sure.  I have
  a page with many multibox tags on it.  When I select several of them my
 form
  bean is correctly populated with a string array.  If I come back to the
 page
  all the correct boxes are checked.  If I remove all the checks and click
  submit then my string array is left to what it was before.  I assume
this
 is
  because there is no mutliboxes being submitted to the server, therefore
 the
  setMethod is never getting called.  Is that what you patch fixed, if so
do
  you know the status of that making it into a build?
 
  Thanks
 
  Jeff
 
 
  -Original Message-
  From: Erik Hatcher [mailto:[EMAIL PROTECTED]]
  Sent: Friday, September 14, 2001 8:24 PM
  To: [EMAIL PROTECTED]
  Subject: Re: multibox and reset()
 
 
  reset is currently not called if html:form creates the form bean,
which
  happens if you go to the JSP page directly without hitting ActionServlet
  first.
 
  I've submitted a patch to fix this, but it has not been committed yet.
 
  Erik
 
 
  - Original Message -
  From: Renaud Waldura [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Sent: Friday, September 14, 2001 10:12 AM
  Subject: Re: multibox and reset()
 
 
   The signature for reset() is the following:
  
   void reset(ActionMapping, HttpServletRequest)
  
   I don't know whether setting the array reference is null is enough, or
 you
   truly need to create a zero-length array like in your example below.
  
   I set mine to null, it seemed to work.
  
  
  
  
   - Original Message -
   From: Dirk Jaeckel [EMAIL PROTECTED]
   To: [EMAIL PROTECTED]
   Sent: Friday, September 14, 2001 6:26 AM
   Subject: multibox and reset()
  
  
Hi!
   
   
I am having trouble resetting a StringArray that is connected to a
   html:multibox-tag.
   
HTML-Example:
   
html:form action=/map method=GET
html:multibox value=parking property=layer/
html:multibox value=petrol property=layer/
   
html:image property=layers page=/img/update.gif/
   
/html:form
   
   
Corresponding ActionForm:
   
public class MapForm extends ActionForm {
   
private String[] _on = new String[0];
   
public void reset() {
_on = new String[0];
}
   
public void setLayer(String in) {
_on = in;
}
   
public String[] getLayer() {
return _on;
   
}
}
   
The Manual told me to use the reset()-method to set The Array to the
   length 0, but reset() is never called.
   
   
Dirk
   
   
  
  
 





Re: dealing with HashMaps instead of beans

2001-09-20 Thread Erik Hatcher

I'm almost certain that syntax won't work with Struts 1.0 but mapped
properties support has been added to the BeanUtils project and seems likely
that it would work with a nightly build of Struts using the latest
BeanUtils.   Anyone know for sure?   I'm sure I'll be in a position to try
it out first hand in the very near future though.

Erik


- Original Message -
From: Paul King [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, September 20, 2001 9:21 AM
Subject: Re: dealing with HashMaps instead of beans


 For HashMaps, would a property reference look like the following?

 bean:write name=product property=(productName)/

 My understanding is that this would translate to
product.get(productName).
 That would be fine for extracting data, which is the primary issue.

 paul

 Erik Hatcher wrote:

  Check out BeanUtils:
 
 
http://cvs.apache.org/viewcvs/jakarta-commons/beanutils/src/java/org/apache/
  commons/beanutils/BeanUtils.java?annotate=1.6
 
  around line 330 I think this is what you'd need, and its something
that
  the Struts tags would need to start using.  It might even be sort of
already
  in the works by others.  Anyone??
 
  Erik
 
  - Original Message -
  From: Paul King [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Wednesday, September 19, 2001 11:29 PM
  Subject: Re: dealing with HashMaps instead of beans
 
   Thanks Erik.  I'm looking for a general solution, so possible changes
to
  the
   Commons code could give me some hope.  This would be similar to
behavior
  NeXT
   used to implement to allow generic data bearing objects like HashMaps
to
  work
   interchangeably within their frameworks that managed bean-like
objects.
  
   In addition to bean:write, I want to be able to use other std tags
that
  expect
   beans (e.g., html:options). Also, there are lots of tables loaded into
  HashMaps
   in these apps. So... I don't think custom taglibs would be a good fit.
  
   paul
  
   Erik Hatcher wrote:
  
It'd only be a few line custom Taglib to write a tag that does a
HashMap
  key
lookup.   It's not possible with bean:write in its current form,
  although
I believe the Commons BeanUtils code has recently been updated to
  include
this kind of lookup, but its not necessary in order to write a
simple
  custom
tag.
   
Erik
   
- Original Message -
From: Paul King [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, September 19, 2001 4:45 PM
Subject: dealing with HashMaps instead of beans
   
 I've encountered 2 jsp apps recently that are passing data around
in
 HashMaps instead of java classes with getters and setters.
Without
 re-writing everything, I'm trying to use struts to re-write the
  display
 and controller code of these apps, but I haven't found a good way
to
 deal with these non-bean HashMaps.  I really want to avoid
changing
  all
 the model code that deals with HashMaps, but I'd like to use the
 bean-oriented taglibs that struts offers.

 Here's an example.  The model api provides a getProducts method,
which
 returns a List of HashMaps that contain product-related keys
  (productID,
 productName, productDescription, ...).  Ideally, I could do
something
 like this:

 logic:iterate id=product name=products
 productID is bean:write name=product property=productID/
 productName is bean:write name=product property=productName/
 productDescription is bean:write name=product
 property=productDescription/
 /logic:iterate

 So, is there some trick or workaround to get HashMaps to work in
this
 and other cases where beans are expected?  I've seen previous
threads
 that demonstrate how individual map entries can be accessed as
valid
 beans, but that's not the issue here.

 Thanks,

 paul



  
  






Re: dealing with HashMaps instead of beans

2001-09-19 Thread Erik Hatcher

It'd only be a few line custom Taglib to write a tag that does a HashMap key
lookup.   It's not possible with bean:write in its current form, although
I believe the Commons BeanUtils code has recently been updated to include
this kind of lookup, but its not necessary in order to write a simple custom
tag.

Erik


- Original Message -
From: Paul King [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, September 19, 2001 4:45 PM
Subject: dealing with HashMaps instead of beans


 I've encountered 2 jsp apps recently that are passing data around in
 HashMaps instead of java classes with getters and setters.  Without
 re-writing everything, I'm trying to use struts to re-write the display
 and controller code of these apps, but I haven't found a good way to
 deal with these non-bean HashMaps.  I really want to avoid changing all
 the model code that deals with HashMaps, but I'd like to use the
 bean-oriented taglibs that struts offers.

 Here's an example.  The model api provides a getProducts method, which
 returns a List of HashMaps that contain product-related keys (productID,
 productName, productDescription, ...).  Ideally, I could do something
 like this:

 logic:iterate id=product name=products
 productID is bean:write name=product property=productID/
 productName is bean:write name=product property=productName/
 productDescription is bean:write name=product
 property=productDescription/
 /logic:iterate

 So, is there some trick or workaround to get HashMaps to work in this
 and other cases where beans are expected?  I've seen previous threads
 that demonstrate how individual map entries can be accessed as valid
 beans, but that's not the issue here.

 Thanks,

 paul







Re: html:select and remembering selection

2001-09-19 Thread Erik Hatcher

Do you have a getCurrentSelection() method in your form bean?and are you
saving it with a setCurrentSelection?

Have your Action class grab the selection from the session and call
setCurrentSelection before returning from the perform method.   That should
do the trick.

Erik

- Original Message -
From: Paradis, André [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, September 19, 2001 9:05 AM
Subject: html:select and remembering selection


Hi guys,

Here is a simple form:

html:form action=/selectTest
html:select property=currentSelection
 html:options collection=aList
  property=key
  labelProperty=label/
  /html:select
/html:form

This works great for populating the list, but how do i specify that an
option should be selected? (the key of the selected option is in a bean)

What i want to do is proces the form, store the choosen key in a bean in
session scope so that every time the form is redisplayed, the previsouly
choosen key is marked as selected.

The form bean asssociated with this form is currently stored in request
scope.

Any inputs appreciated

Andre Paradis





Re: dealing with HashMaps instead of beans

2001-09-19 Thread Erik Hatcher

Check out BeanUtils:

http://cvs.apache.org/viewcvs/jakarta-commons/beanutils/src/java/org/apache/
commons/beanutils/BeanUtils.java?annotate=1.6

around line 330 I think this is what you'd need, and its something that
the Struts tags would need to start using.  It might even be sort of already
in the works by others.  Anyone??

Erik


- Original Message -
From: Paul King [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, September 19, 2001 11:29 PM
Subject: Re: dealing with HashMaps instead of beans


 Thanks Erik.  I'm looking for a general solution, so possible changes to
the
 Commons code could give me some hope.  This would be similar to behavior
NeXT
 used to implement to allow generic data bearing objects like HashMaps to
work
 interchangeably within their frameworks that managed bean-like objects.

 In addition to bean:write, I want to be able to use other std tags that
expect
 beans (e.g., html:options). Also, there are lots of tables loaded into
HashMaps
 in these apps. So... I don't think custom taglibs would be a good fit.

 paul

 Erik Hatcher wrote:

  It'd only be a few line custom Taglib to write a tag that does a HashMap
key
  lookup.   It's not possible with bean:write in its current form,
although
  I believe the Commons BeanUtils code has recently been updated to
include
  this kind of lookup, but its not necessary in order to write a simple
custom
  tag.
 
  Erik
 
  - Original Message -
  From: Paul King [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Wednesday, September 19, 2001 4:45 PM
  Subject: dealing with HashMaps instead of beans
 
   I've encountered 2 jsp apps recently that are passing data around in
   HashMaps instead of java classes with getters and setters.  Without
   re-writing everything, I'm trying to use struts to re-write the
display
   and controller code of these apps, but I haven't found a good way to
   deal with these non-bean HashMaps.  I really want to avoid changing
all
   the model code that deals with HashMaps, but I'd like to use the
   bean-oriented taglibs that struts offers.
  
   Here's an example.  The model api provides a getProducts method, which
   returns a List of HashMaps that contain product-related keys
(productID,
   productName, productDescription, ...).  Ideally, I could do something
   like this:
  
   logic:iterate id=product name=products
   productID is bean:write name=product property=productID/
   productName is bean:write name=product property=productName/
   productDescription is bean:write name=product
   property=productDescription/
   /logic:iterate
  
   So, is there some trick or workaround to get HashMaps to work in this
   and other cases where beans are expected?  I've seen previous threads
   that demonstrate how individual map entries can be accessed as valid
   beans, but that's not the issue here.
  
   Thanks,
  
   paul
  
  
  






Re: struts-config.xml : input attribute ?

2001-09-17 Thread Erik Hatcher

input defines where control will return if validation errors are
generated.

For complete documentation on struts-config.xml, check out the comments in
the DTD.You can view it here:

http://cvs.apache.org/viewcvs/jakarta-struts/conf/share/struts-config_1_0.dt
d?annotate=1.5


- Original Message -
From: emmanuel.boudrant [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, September 17, 2001 3:01 AM
Subject: struts-config.xml : input attribute ?


 Hello,

 How works the input attribute in struts-config.xml ?

action path=/logon
 type=com.meeschaert.struts.logon.LogonAction
   name=logonForm
input=/logon/logon.jsp 
forward name=success path=/logon/success.jsp
 /
forward name=failure path=/logon/failure.jsp
 /
/action

 When a request /logon.do, the /logon/logon.jsp page
 doesn't displayed.

 Thanx



 ___
 Do You Yahoo!? -- Un e-mail gratuit @yahoo.fr !
 Yahoo! Courrier : http://fr.mail.yahoo.com





Re: populate form using parameters instead of form

2001-09-16 Thread Erik Hatcher

What is your complete struts-config.xml?   Also, what is the HTML hyperlink
to that action like?

If you've got the form-bean and action set up appropriately there is no
problem with making a hyperlink directly to an action without using a form.

Erik


- Original Message -
From: Brian K. Buckley [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, September 16, 2001 4:52 PM
Subject: populate form using parameters instead of form


 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 action name=myForm ... 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: Question about getting Struts bean property value into a jsp var

2001-09-15 Thread Erik Hatcher

bean:define will do this for you.   Also, in the example you show below,
you could use the bean:write tag where you have %=email% anyway, so you
wouldn't need a scripting variable for your specific example.

Erik


- Original Message -
From: Voss, Greg [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, September 15, 2001 11:27 AM
Subject: Question about getting Struts bean property value into a jsp var


 Hi,
 How can I get values out of a session bean and into a jsp variable?

 This is what I have that does not work.

 struts_bean:write name=user property=email
 filter=no/
   IFRAME name=float
 src=http://localhost/db/app/pages/MyPage.html?email=%=email% width=720
 height=350
   /IFRAME
 TIA.
 Greg Voss
 Manager, Web Development
 Silverstream Software Inc.






Re: html:img question

2001-09-14 Thread Erik Hatcher

I've subclassed the ImgTag from Struts and created my own custom tag for
doing this kind of thing.   I gave some code examples of it in a past
message to this list that you could find in the archives.

Erik


- Original Message -
From: Thierry Cools [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, September 14, 2001 6:38 AM
Subject: html:img question


Hi, after a long absence, I'm back again in the struts world ;-)

I have the following problem, I'd like to add an image on my page, where the
name of this image is stored in the database ( not the image itself, just
the pathlocation and the name);
So I've a form bean with a 'getImagePath()' method that returns a String.

But the name  property attributes in the img tag are already reserved for
multiple parameters,
so, the question is, how can I get my Image coming from my get method,
without using scriptlets and all that stuff ?

Thanks for your help,
Thierry







Re: html:img question

2001-09-14 Thread Erik Hatcher

I've subclassed the ImgTag from Struts and created my own custom tag for
doing this kind of thing.   I gave some code examples of it in a past
message to this list that you could find in the archives.

Erik


- Original Message -
From: Thierry Cools [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, September 14, 2001 6:38 AM
Subject: html:img question


Hi, after a long absence, I'm back again in the struts world ;-)

I have the following problem, I'd like to add an image on my page, where the
name of this image is stored in the database ( not the image itself, just
the pathlocation and the name);
So I've a form bean with a 'getImagePath()' method that returns a String.

But the name  property attributes in the img tag are already reserved for
multiple parameters,
so, the question is, how can I get my Image coming from my get method,
without using scriptlets and all that stuff ?

Thanks for your help,
Thierry







Re: multibox and reset()

2001-09-14 Thread Erik Hatcher

reset is currently not called if html:form creates the form bean, which
happens if you go to the JSP page directly without hitting ActionServlet
first.

I've submitted a patch to fix this, but it has not been committed yet.

Erik


- Original Message -
From: Renaud Waldura [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, September 14, 2001 10:12 AM
Subject: Re: multibox and reset()


 The signature for reset() is the following:

 void reset(ActionMapping, HttpServletRequest)

 I don't know whether setting the array reference is null is enough, or you
 truly need to create a zero-length array like in your example below.

 I set mine to null, it seemed to work.




 - Original Message -
 From: Dirk Jaeckel [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Friday, September 14, 2001 6:26 AM
 Subject: multibox and reset()


  Hi!
 
 
  I am having trouble resetting a StringArray that is connected to a
 html:multibox-tag.
 
  HTML-Example:
 
  html:form action=/map method=GET
  html:multibox value=parking property=layer/
  html:multibox value=petrol property=layer/
 
  html:image property=layers page=/img/update.gif/
 
  /html:form
 
 
  Corresponding ActionForm:
 
  public class MapForm extends ActionForm {
 
  private String[] _on = new String[0];
 
  public void reset() {
  _on = new String[0];
  }
 
  public void setLayer(String in) {
  _on = in;
  }
 
  public String[] getLayer() {
  return _on;
 
  }
  }
 
  The Manual told me to use the reset()-method to set The Array to the
 length 0, but reset() is never called.
 
 
  Dirk
 
 






Re: Serializing form beans

2001-09-14 Thread Erik Hatcher

Just out of curiosity, what is the purpose of serializing and encoding the
form bean?


- Original Message -
From: Renaud Waldura [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, September 14, 2001 2:28 PM
Subject: Re: Serializing form beans


 Take that back. There's still an issue with the encoding. My guess is that
 URLEncoder and/or String() constructor don't convert full bytes. Grr.

 At this point I think I'm going to write my own encoding...





Re: template, bean tag question

2001-09-13 Thread Erik Hatcher


template:put name=titlebean:message
key=main.title//template:put


- Original Message -
From: _ _ [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, September 13, 2001 6:40 PM
Subject: template, bean tag question


Hi everybody, I want to do something like this:

 template:put name=title content=bean:message key=main.title/
 direct=true/

I intend to take the value of main.title and use that value as the
 value for title for that template. It doesn't work because of the nested
 tag but I couldn't figure out a work-around to accomplish this. I tried
 looking for info online but to no avail. I appreciate anyone's help on
this.
 Thank you.


 _
 Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp






Re: Getting the value of a selected option into bean:write

2001-09-12 Thread Erik Hatcher

Just make a getter in your form bean that does that looks up 'status' in the
collection that your form bean is supplying to the html:options tag and
return the display value.

Then use bean:write to access that attribute of your form bean.

Erik

- Original Message -
From: Matt Raible [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, September 12, 2001 10:48 AM
Subject: Getting the value of a selected option into bean:write


 I have the following code to display a drop-down list:

 strutshtml:select property=status styleClass=selectNormal
 strutshtml:options collection=status property=key
 labelProperty=value/
 /strutshtml:select

 I would like to display the labelProperty to the user after they've used
this
 drop-down for a search criteria.  So in a formbean, I have a status
 getter/setter and use the following code to write it out.

 strutsbean:write name=formbean property=status /

 However, what I really want to display is the labelProperty, rather than
the
 value.

 Any ideas?  I know I could use javascript to populate a hidden field (with
the
 selected.text) when they submit it - but I want to use this same logic to
 display a read-only view of a page.  My read only page will display plain
HTML
 text instead of select fields, so I need to to display the value (rather
than
 the key).  Our UI Standards do not allow us to use the disabled
attribute on
 input fields to accomplish this.

 Thanks,

 Matt

 __
 Do You Yahoo!?
 Get email alerts  NEW webcam video instant messaging with Yahoo!
Messenger
 http://im.yahoo.com





Re: specifying multiple=true in html:select

2001-09-10 Thread Erik Hatcher

Yes, it is correct.   Its irrelevant what the value of the MULTIPLE
attribute is, and its not well-formed XML to have an attribute without a
value.   This is addressed in XHTML in Section 4.5 here:
http://www.w3.org/TR/xhtml1/#diffs

Erik


- Original Message -
From: Campesato, Oswald [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, September 10, 2001 8:41 PM
Subject: specifying multiple=true in html:select


 Specifying multiple=true in this tag generates multiple=multiple in
 the HTML code.  Checking my HTML book shows multiple selects
 in a select box with just the word MULTIPLE.  Is this the correct
 behavior?

 Cordially,

 Oswald






Re: Does anyone know how to get the parents BeanInfo ?

2001-09-08 Thread Erik Hatcher

Have a look at BeanUtils (from Jakarta Commons) and use the
BeanUtils.describe to get all the read capable properties.   I'm assuming
that it would give you the read capable properties of any parent class of
that bean as well (although I don't know that for certain).   Please correct
me if I've misspoken about this - I'm attempting an answer in order for me
to learn more about BeanUtils!  :)

Erik


- Original Message -
From: Trieu, Danny [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, September 07, 2001 9:09 PM
Subject: Does anyone know how to get the parents BeanInfo ?


 I know this a litle out of scope, but I need this info to extend the
Struts
 existing tag.  That is I want to write a tag that will print out all of
the
 given bean properties as hidden tags inside a from.  These properties
 includes the properties of its parent classes.

 appreciate your helps ...





Re: re-Logon after session timeout

2001-09-06 Thread Erik Hatcher

I'm accomplishing this very thing using Resin's Servlet 2.3 Filter support.
The filter determines the user is not logged in, saves the requesting URI in
a session attribute, and forwards to the login page.   The login action
checks for the existence of the session attribute with the saved URI and
forwards to that upon a successful login.

I'm sure it could be done in a Servlet 2.2 environment also, but would
require more effort.

Erik


- Original Message -
From: Ralph vd Houdt [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, September 06, 2001 12:09 AM
Subject: re-Logon after session timeout


 Hi All,

 I developed a struts application and re-used the checkLogon tag from the
 login example from Ted Husted. It works quite well but when a client loses
 the session in case of a session timeout and a new request is done the
 Action is cancelled because the User object isn't in the session anymore.
Is
 there a possibility to:

 - route the user to the logonform. (And re-add the User object)
 - after logon, repost the initial request.
 - continue based on the initial request

 Greetings Ralph.






Re: newbie question - confused

2001-09-06 Thread Erik Hatcher

Look at the generated HTML of logon.jsp you'll see that it submits to
logon.do.  html:form looks up the action mapping to determine which form
bean to use and generates the form tag with the appropriate action .do
extension automatically.

Erik


- Original Message -
From: Jose Correia [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, September 06, 2001 7:22 AM
Subject: newbie question - confused


 Hi all

 I'm a bit confused with the Struts example (the one that comes with
 struts1.0.jar). I'm trying to determine at which point does the .do come
 in to being.

 Facts first:
 1. index.jsp shows:

 html:link page=/logon.jspbean:message
 key=index.logon//html:link/li

 i.e calls the file logon.jsp

 2. logon.jsp defines an action form:
 html:form action=/logon focus=username

 3. struts-config.xml defines an action mapping:
 actionpath=/logon
type=org.apache.struts.webapp.example.LogonAction
name=logonForm
   scope=request
   input=/logon.jsp
 /action

 Now the tour guide under the heading LogonAction.java says:
 The initial JSP submits its form to logon.do. If you check the servlet
 mappings in the example's web.xml you will see that requests for *.do
 files are directed to the Struts action servlet (an instance of
 ActionServlet). In the example, the ActionServlet refers to
 struts-config.xml for its own mappings  (among other things), which is
 where we find the reference to logon.do:

 To my knowledge the initial jsp (logon.jsp right?) is submitting a form
 to the action servlet which matches the action value in html:form
 action=/logon ... to the action mapping path actionpath=/logon
 ... correct? i.e. /logon matches /logon.

 I am aware that web.xml defines a servlet-mapping for *.do but thats
 only if the user or the system makes a request for a .do file right? Now
 in the above case a request is being sent first to logon.jsp from
 index.jsp. Then the action form in logon.jsp if there are errors it
 calls: return (new ActionForward(mapping.getInput()));  where the input
 is /logon.jsp as defined above in the action mapping. Otherwise it
 forwards it to mainmenu.jsp.

 Now where does the .do come in? Is it internal to struts?

 Thanks in advance
 Jose Correia



 Now following the struts example guide tour

 --

 \=/, _-===-_-===-_-===-_-===-_-==-_
 |  @___oo  (   )_
   /\  /\   / (___,,,}_--=)
  ) /^\) ^\/ _)=_Positive thinking - a great way  )
  )   /^\/   _) (_to face life )
  )   _ /  / _)  (Jose Correia)
  /\  )/\/ ||  | )_)  (_[EMAIL PROTECTED])
 |(,,) )__)   (   [EMAIL PROTECTED])
  ||  /\)___)\   (__)
  | \(  )___) )___  -==-___-=-___==
   \__(___;;; __;;;






Re: bean:define, bean:write

2001-09-06 Thread Erik Hatcher

Matt,

My implementation is pretty domain specific though (our image tag requires a
parent tag to set up some context), so my actual code is not generalizable,
but here's the essence of it (cutting and pasting, and trimming down to the
essentials):

import org.apache.struts.taglib.html.ImgTag;
public class ImageImgTag extends ImgTag {

protected String src() throws JspException {

String path = lookupPath(pageContext.getRequest(), src);

return path;
}
}

The implementation of lookupPath is, of course, left as an exercise to the
reader, but in our case it looks up a URI (or URL fragment) from a
properties file, and using java.text.MessageFormat replaces the appropriate
pieces in that string and returns it.   The reason the request is passed in
is so that the URL can be relatively specified to the app. context(i.e.
prefixed with request.getContextPath()) or absolutely specified (depending
on whether it starts with a forward-slash or not.   In our case we aren't
using the ImgTag provided src variable, I just faked that for the above
example, but that would be one way to pass in the image filename (with no
path, I presume) and have that appended to a looked-up URL prefix.   We use
this feature to serve images from our application server (which gets them
from the DB as BLOB's) or from statically generated files using Apache
directly, and at configuration time we can specify where images get served
from.

Erik

- Original Message -
From: Matt Raible [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, September 06, 2001 1:56 PM
Subject: Re: bean:define, bean:write


 Would you mind sharing this?

 --- Erik Hatcher [EMAIL PROTECTED] wrote:
  My approach to externalizing image paths was to extend
  org.apache.struts.taglib.html.ImgTag and use a custom tag to define
image
  URL's using the existing pieces ImgTag provides.   Overriding src() is
used
  to look up the look up the image URL base path from a properties file.
 
  I've similarly created a custom tag that outputs the image URL as a
string,
  so that it can be used in JavaScript or in other ways if necessary, and
it
  relies on a common utility method to retrieve the image URL path that is
  shared with the ImgTag subclassed tag.
 
  Erik
 
 
  - Original Message -
  From: Matt Raible [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Thursday, September 06, 2001 12:33 PM
  Subject: Re: bean:define, bean:write
 
 
   I don't think there's such a thing as jsp:define is there?
  
   I have a similar question - I'd like to use bean:define at the top
of my
   page, but it is not used if one already exists...
  
   What I'm trying to do is set a path to all my images that lives on the
   webserver.  I'd like to externalize this value into the web.xml - is
this
   possible.  If so, how do I retrieve it in my page.
  
   Currently, I'm doing this:
  
   %
   String imagePath = /blah/image;
   %
   image path is %=imagePath%
  
   I was thinking of using bean:define to get rid of the scriptlet, but
now
  I'm
   thinking it would be better to put in a config file.
  
   Also, I've used my ApplicationResource.properties as a place to store
  default
   values for populating a form - does anyone recommend a better way?
  
   Thanks,
  
   Matt
   --- Keith Bacon [EMAIL PROTECTED] wrote:
My guess is that jsp:define creates it if not there
but struts bean:define doesn't.
   
   
--- David Corbin [EMAIL PROTECTED] wrote:
 I thought that bean:define takes care of that
 - Original Message -
 From: Keith Bacon [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, September 06, 2001 11:18 AM
 Subject: Re: bean:define, bean:write


  Is it because you haven't done a
 
  request.putAttribute(pageTitle, yourObject);
 
  in your ActionForm?
 
  Keith.
 
 
  --- David Corbin [EMAIL PROTECTED] wrote:
   Why does this jsp fragment generate an exception
  
   javax.servlet.jsp.JspException: Cannot find bean pageTitle in
 scope
   request
  
   --cut--
   %@ taglib uri=/WEB-INF/struts-bean.tld prefix=bean %
   bean:define id=pageTitle value=foobar scope=request/
  
   HTML
   HEAD
TITLEbean:write name=pageTitle
   scope=request//TITLE
   /HEAD
   . . .
  
   --cut--
  
   Thanks
   David Corbin
  
 
 
  __
  Do You Yahoo!?
  Get email alerts  NEW webcam video instant messaging with
Yahoo!
 Messenger
  http://im.yahoo.com
 
 

   
   
__
Do You Yahoo!?
Get email alerts  NEW webcam video instant messaging with Yahoo!
  Messenger
http://im.yahoo.com
  
  
   __
   Do You Yahoo!?
   Get email alerts  NEW webcam video instant messaging

Re: what are different scope(s) available to define for a beaninstr uts-config.xml

2001-09-05 Thread Erik Hatcher

If you are referring to form beans, they can only be in session or
request scope.

Erik


- Original Message -
From: Jonathan M Crater [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, September 05, 2001 4:24 AM
Subject: Re: what are different scope(s) available to define for a beaninstr
uts-config.xml


 http://jakarta.apache.org/struts/userGuide/building_model.html#javabeans

 Venkat Jonnalagadda wrote:

  what are different scope(s) available to define for a bean in
  struts-config.xml and how do it define themany examples...please...
 
  --Venkat.






Re: Concurrency and Custom JSP tags

2001-09-05 Thread Erik Hatcher

Quoting from Geary's Advanced JavaServer Pages book, p. 14:

Because servlet containers can reuse tag handlers, you must be diligent
about implementing the release method and careful about instantiating
resources in doStartTag [rather in the tags constructor]

So the 'release' method is the key.   You'll notice that the Struts tags use
the release method to clear their resources.   Tag instances are not used
simultaneously, but released for re-use after they are done, so member
variables are ok, but care must be taken not to allow them to carry over to
future uses.

I highly recommend Geary's book for all Struts power users and developers,
especially in regards to custom tag development.

Erik


- Original Message -
From: Bill Clinton [EMAIL PROTECTED]
To: struts [EMAIL PROTECTED]
Sent: Wednesday, September 05, 2001 3:42 PM
Subject: Concurrency and Custom JSP tags


 Hello,
  I have been writing my own custom jsp tags, and have recently
 noticed that member properties of tags seem to be retained after the tag
 is complete.

  For example, lets say you have a tag that has an optional attribute
 called message, and the tag is designed to print this attribute if it
 is passed.  If you call this tag and pass hello as the attribute
 message on one page, then call this tag on another page without passing
 the attribute, it will still be set to hello.

  This functions much like a servlet, which is multi-threaded but
 retains the values for member variables across different requests.  I
 think most servlet programmers realize this and stay away from using
 non-static member variables.  But it seems to me that custom JSP tag
 design encourages the use of attributes, which seems to be potentially
 very dangerous in an environment with a high volume of requests.

  I would like to know if anyone knows of any good links where
 concurrency issues in custom jsp tags are discussed more in depth.
  Also, I am curious to know if anyone has encountered any problems like
 this with the Struts tags.  For example, if I set an onmouseover for a
 html:checkbox tag, do I have to worry about this attribute showing up
 in a html:checkbox  tag called from a different page if both pages are
 loaded by different users at the same time?

 Thanks in advance for any info,
 Bill





Re: onClick Link Submitting

2001-09-04 Thread Erik Hatcher

you probably need to say document.form[0].submit()


- Original Message - 
From: Steven Leija [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, September 04, 2001 2:53 PM
Subject: onClick Link Submitting


 I'm trying to submit a form through a hyperlink, can anyone see what my
 error is in my code?
  
 html:link href= onClick=javascript:form[0].submit();
 styleClass=vfsButtonSubmit Changes/html:link
  
 I'm getting an error saying that my form is null or not an object.
 
 Have a good one, 
 
 Steven 
 
  
 




Re: How does bean:define work?

2001-08-30 Thread Erik Hatcher

You need to use the TEI (tag extra info) mechanism and in your TLD do like
bean:define does:

teiclassorg.apache.struts.taglib.bean.DefineTei/teiclass

And then look at the DefineTei class for more insight.

Geary's Advanced JavaServer Pages book has lots of great information with
this kind of stuff.

Erik

- Original Message -
From: Wittwer Markus [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, August 30, 2001 4:35 AM
Subject: How does bean:define work?


 Hi!

 The bean:define tag simply exposes a bean as a scripting variable by
adding
 it to the page context:

 // from DefineTag.java
 pageContext.setAttribute(id, value, inScope);

 Now one can access the bean by
 bean:define id=title value=test/
 Value of title: %= title %

 I did the same within a custom tag I wrote but I cannot directly access
the
 bean as a scripting variable:
 x:mytag id=title key=test // the tag retrieves some key and stores
it
 in the bean title

 Value of title: %= title %
 causes an Variable title not defined exception,

 but

 Value of title: %= pageContext.findAttribute(title).toString() %
 works fine.

 Before anyone asks: I have to use scriptlets, because I want to nest the
 output within another struts tag.


 Thanks for your help,

 Markus Wittwer





Re: FAQ?

2001-08-28 Thread Erik Hatcher

http://www.jguru.com/faq/home.jsp?topic=Struts


- Original Message - 
From: Gary Kephart [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, August 28, 2001 6:50 PM
Subject: FAQ?


 I've just downloaded, installed and tried to run Struts this week. Of
 course, as a newbie, I hit some snags. Got past most of them, but then
 went looking for a FAQ list for Struts, but to no avail. Is there one?
 If so, where?
 
 BTW, the problem I'm trying to solve is this message in the log file:
 
 javax.servlet.jsp.JspException: Cannot find ActionMappings or
 ActionFormBeans collection
 
 I can't tell if I'm missing a jar file or some xml file needs to be
 modified.
 
 Thanks,
   Gary
 --
 Gary Kephart   | Basis 100
 Software Engineer  | 4 Park Plaza, Suite 800
 [EMAIL PROTECTED]  | Irvine, CA 92614
 (949) 852-8600x262 | http://www.basis100.com
 
 This communication is intended only for the use of the individual or
 entity to whom/which it is addressed, and information contained in this
 communication is privileged and confidential.  If the receiver of this
 message is not the intended recipient, you are hereby notified that any
 dissemination, distribution or copying of this communication is strictly
 
 prohibited.  If you have received this communication in error, please
 notify us at the above telephone number (so that we may correct our
 internal records) and delete this communication without making a copy of
 
 it.  Thank you.
 




ImgTag, encodeURL, and jsessionid

2001-08-28 Thread Erik Hatcher

I hadn't gotten any response on struts-dev yet, so I thought I'd try
struts-user out after seeing a related message about URL rewriting..

I have a custom subclass of ImgTag that overrides the src() method to
provide a custom URL depending on some flags in our system (in order to
offload image serving from the application server by hosting them off Apache
directly).In development environments the URL's returned are within the
application context.  In production environments, the URL's returned are
absolute http://; and not within the application context.

All URL's end up getting rewritten with the ;jsessionid initially, but it
doesn't make sense to have URL's outside the app. context rewritten that
way.

Has anyone encountered this problem and resolved it?In ImgTag the
HttpServletRequest.encodeURL method is called which where that is happening,
but why?Does it blindly rewrite all URL's?Or should it only rewrite
URL's within its own application context as seems logical to me?   Is it my
app. server (Resin 2.0) that is doing the wrong thing?

And if encodeURL is supposed to blindly rewrite all URL's, shouldn't we make
some kind of switch to either turn on/off the URL rewriting in ImgTag?

For now we are handling it by having Apache strip off the ;jsessionid
before those requests for images in our image cache.

Thanks,
Erik






Re: default action and templates

2001-08-23 Thread Erik Hatcher


- Original Message -
From: Marcelo Vanzin [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, August 23, 2001 8:04 AM
Subject: Re: default action and templates


 Erik Hatcher wrote:

  Why not use the Action to populate request scoped variables that you
then
  bean:write inside template:put tags?


 This was actually my other question from yesterday. I could not find a
 way to do that, not with bean:write at least.

This should work


request.setAttribute(name,this is a test); // in your Action

!-- in your template-using JSP page --
template:put name=contentbean:write name=name/ /template:put

!-- in your template definition JSP page --
template:get name=content/

  Or have a look at the source code to the template:put tag and

  reverse-engineer it!  :)

 Hehehe, I tried that, really. :-) But it seems that the values used by
 template:get are stored in a stack in the ContentMapStack class, and
 the map key is the PageContext. If only I could find a way to access
 the PageContext from inside the Action class...

But the template stuff gets put into request scope, so you don't need page
context specifically.

Erik





Re: automatically calling an Action

2001-08-22 Thread Erik Hatcher

Use a Filter part of Servlet 2.3.   I assume you could map all requests
to a custom ActionServlet also, but ultimately a Filter is the way to go.
I'm using Resin 2.0 which supports Servlet 2.3 and filters are working
great.

Erik


- Original Message -
From: Calvin Lau [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, August 22, 2001 6:10 PM
Subject: automatically calling an Action


 I have an ActionServlet that needs to be run everytime
 a user makes any http request to my site.  How and
 where should I tell the controller to do this?





Re: default action and templates

2001-08-22 Thread Erik Hatcher

Why not use the Action to populate request scoped variables that you then
bean:write inside template:put tags?

Or have a look at the source code to the template:put tag and
reverse-engineer it!  :)

Erik


- Original Message -
From: Marcelo Vanzin [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, August 20, 2001 12:12 PM
Subject: Re: default action and templates



 Hi guys, me again.

 Marcelo Vanzin wrote:
  2) I actually had some doubts with the templates, but while writing them
  down I kind of saw some ways of doing what I wanted, so I'll try it and
  later if I'm still stuck I'll cry for help. :-)


 So it came to be that what I had in mind did not work. :-) At least not
 the way I tried, but I could not find anything in the docs...

 Is there a way to do something similar to a template:put ... you would
 use in a JSP file, but inside an Action class?

 If that is possible, I'm done. :-) I tried request.setAttribute(), but
 when I call template:get ... in the main template, it raises an
 exception (empty stack), and all the examples I found were only JSP,
 not one using an Action class.

 --
 []'s
 Marcelo Vanzin
 Touch Tecnologia
 [EMAIL PROTECTED]
 We're an underground revolution working overtime





Re: TextArea Wrapping using Form Tags

2001-08-19 Thread Erik Hatcher

Ted,

Your example says this:

To seed the textarea from the form bean, you could code something like:
  textarea name=article rows=15 cols=60 wrap=soft/textarea

But there is something additional to set the initial value from the form
bean, correct?

textarea name=article rows=15 cols=60 wrap=softbean:write
name=formName property=article//textarea

Erik


- Original Message -
From: Ted Husted [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, August 19, 2001 7:02 AM
Subject: Re: TextArea Wrapping using Form Tags


 See Wrapping a text area at

 http://husted.com/about/struts/FAQ/view-html.htm

 Calvin Lau wrote:
 
  Is there any way to set the wrapping in a text area
  when using the struts form tags?  In HTML you can set
  virtual, physical, or none.  Netscape doesn't do any
  wrapping by default so large portions of text are lost
  when I grab information to display in a textarea to be
  modified.
 
  Any ideas?





Re: default action and templates

2001-08-17 Thread Erik Hatcher

Your default action could be implemented by either extending
ActionServlet, or using a Filter (part of Servlet 2.3, not Struts-related),
so Struts can handle your requirements nicely I suspect.

Erik


- Original Message -
From: Marcelo Vanzin [EMAIL PROTECTED]
To: Struts Users [EMAIL PROTECTED]
Sent: Friday, August 17, 2001 3:41 PM
Subject: default action and templates



 Hi there,

 We're working around here to implement Struts as the definitive framework
 for our web applications, and I'm beggining to study it. Comparing it to
 our current in-house system, I have come to two problems I could not
 find answers.

 1) A default action. This is not a default action as, for example,
 putting unknown=true in the config file, but rather and Action that is
 performed in *every* page that goes through the ActionServlet.

 We have some business logic that is performed in every page we have in
 the site, so having some default action would fix that just fine.

 Also, with the approach suggested in an earlier post of implementing an
 prePerform method in the Action class, this could be done also.

 2) I actually had some doubts with the templates, but while writing them
 down I kind of saw some ways of doing what I wanted, so I'll try it and
 later if I'm still stuck I'll cry for help. :-)

 --
 []'s
 Marcelo Vanzin
 Touch Tecnologia
 [EMAIL PROTECTED]
 We're an underground revolution working overtime





Re: message problems in templates

2001-08-16 Thread Erik Hatcher

Can you elaborate on does not work?

Do you have the taglib definition direction in both JSP's?   Or just the
template one?

Erik

- Original Message -
From: Dave Van Even [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, August 15, 2001 7:49 PM
Subject: message problems in templates


hi,

I'm using struts templates to generate my pages.
How comes the message tag

bean:message key=blablabla /

DOES render when I put it directly in the template,
but it DOES NOT work when I put it in a page that
the template includes ???

could someone point me to the solution, please ?

thanks alot!!!

Dave Van Even
[EMAIL PROTECTED]





Re: Templates Images

2001-08-15 Thread Erik Hatcher

I'm sure there is a way to get at the hashtable used by the templates though
and lookup the value.   I'm not sure how this would work with an html:img
tag without using scriptlets, but you could at least get at them using
scriptlets as a first pass.

Check out the diagram at:
http://www.javaworld.com/javaworld/jw-09-2000/images/jw-0915-jspweb4.gif for
information on how the template architecture works.

Erik


- Original Message -
From: James Maggs [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, August 15, 2001 7:53 AM
Subject: Re: Templates  Images


 I am using the direct='true' attribute to write the String
 'images/example.gif' to the template file. The trouble is that in the
 template file, you cannot embed the template:get tag within the
 html:img page attribute.

 I think I'm going to end up with lots of tiny jsp pages containing only
 image tags!

 Thanks ayway,

 -James

 - Original Message -
 From: Aaron Ravenberg [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]; 'James Maggs'
 [EMAIL PROTECTED]
 Sent: Wednesday, August 15, 2001 3:37 PM
 Subject: RE: Templates  Images


  Using template:put tag show below is trying to put an image file as
  include into the JSP.template, then asking the JSP.template to compile.
  What you really want to display is the String '/images/example.gif'.  So
 you
  have to specify a my.JSP that contained the text '/images/example.gif',
  therefore you would need to use a html img src=template:get  or
have
  the my.JSP file contain the html:img tag.
 
  If you only have a few images that can be displayed and depending on
what
  you use to determine to display them, wrapping the img tags in
  logic:present tags might be a solution.
 
  -Aaron
 
  -Original Message-
  From: James Maggs [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, August 15, 2001 10:00 AM
  To: [EMAIL PROTECTED]
  Subject: Templates  Images
 
 
  Hi There,
 
  I'm working on a Struts powered site right now and have come up against
a
  bit of a problem. I'm using the templating tags to give my pages a
uniform
  look and feel. However I'd like to be able to insert images into my
  template. I figured the best way would be as follows:
 
  template:insert template='/template.jsp'
template:put name='image' content='/images/example.gif' direct='true'
 /
  /template:insert
 
  But this begs the question, how do you insert the content into the src
  attribute of the image tag? I suppose I could put the whole image tag
into
  the template but I'd rather avoid embedding content in the above code.
 
  Can anyone suggest a best way forward?
 
  Many thanks,
 
  -James
 
 





Re: html:form scripting variable

2001-07-24 Thread Erik Hatcher

It does set a page scoped attribute (keyed by the form name from the
mapping) that contains the form object.

Erik


- Original Message -
From: Gregor Rayman [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, July 24, 2001 9:50 AM
Subject: html:form  scripting variable


 Hi,

 why does html:form generate no scripting variable? Would be nice, if
 it did.

 --
 gR





Re: html:form scripting variable

2001-07-24 Thread Erik Hatcher

 Perhaps. But sometimes I just want to use the form in a scriplet.

Perhaps?   Well, it DOES create a page scoped attribute - no perhaps about
it! :)   I checked the source, FormTag.java.

 Now I have to either covert the attribute to local variable or
 use bean:define. Why not just create the variable like bean:define
 does?

But one of the main purposes of Struts is to get away from using scriptlets.


- Original Message -
From: Erik Hatcher [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, July 24, 2001 7:25 PM
Subject: Re: html:form  scripting variable


 It does set a page scoped attribute (keyed by the form name from the
 mapping) that contains the form object.

 Erik


 - Original Message -
 From: Gregor Rayman [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, July 24, 2001 9:50 AM
 Subject: html:form  scripting variable


  Hi,
 
  why does html:form generate no scripting variable? Would be nice, if
  it did.
 
  --
  gR
 






Re: Access to HttpServletRequest within ActionForm

2001-07-18 Thread Erik Hatcher

Look at the ActionForm's reset method.   That gives you the request and is
called when its instantiated by the ActionServlet prior to population from
the request.

One note - reset is not currently called when instantiated from the
html:form tag unfortunately, but apparently this will be alleviated in the
near future.   I'll submit a patch for this eventually if Craig doesn't get
to it first.

Erik


- Original Message -
From: Holger Wiechert [EMAIL PROTECTED]
To: User-Struts (E-Mail) [EMAIL PROTECTED]
Sent: Wednesday, July 18, 2001 10:44 AM
Subject: Access to HttpServletRequest within ActionForm


Hi,

is there a way of getting access within an ActionForm to the request that
caused the ActionServlet using this ActionForm?

Something like:

public class MyActionForm extends ActionForm
{
public MyActionForm
{
super();
HttpServletRequest request = getItSomeHow();
...
}
...
}

When the ActionForm is getting created, I need access to some objects that
are placed within the current session.
Depending on those values, the ActionForm shall be set up differently.

Thanks in advance,
Holger





Re: How to turn off validation momentarily

2001-07-18 Thread Erik Hatcher

In struts-config you can specify that validation won't occur on a per-action
basis like this:

action path=/someaction
type=com.whatever.SomeAction
scope=request
name=SomeForm
input=some.jsp
validate=false
  forward name=receiptpath=another.jsp /
/action

Does that help?

Erik

- Original Message -
From: Tom Miller [EMAIL PROTECTED]
To: struts-user [EMAIL PROTECTED]
Sent: Wednesday, July 18, 2001 8:24 PM
Subject: How to turn off validation momentarily


 Hello

 Is there a way to turn off form validation momentarily, say for just one
 action.perform() invocation? I've tried placing a
 mapping.setValidation(false) in various places in my edit and save
 actions (a la struts-example). Basically, I do not want to validate a
 record that I'm presenting to the user in order to confirm a delete, but
 the form is set up for validation, so that gets executed too. But we're
 deleting, so why bother?

 Thanks in advance for any tips.

 --
 Tom Miller
 Miller Associates, Inc.
 [EMAIL PROTECTED]
 641.469.3535 Phone
 413.581.6326 FAX