Multiple checkboxes with the same name -- possible with Struts?

2002-02-28 Thread Kevin J. Turner

Is it possible, using the Struts framework, to have multiple checkboxes
that are named the same but have different values?

First, a little background on this:

Say you have the following four fruity checkboxes on a form, with Apple
and Mango checked:
[x] Apple
[ ] Kiwi
[x] Mango
[ ] Banana

Each checkbox has the same html *name* property of "fruit", but they all
have different html "value" properties (Apple, Kiwi, etc).

In order to get those from the request you would need to do something
like this:

String[] fruit = request.getParameterValues("fruit");

If you just do a request.getParameter("fruit") with the above scenario,
then you'll only get one string back, "Apple" (because its the first one
selected).

So the problem is, where Struts is concerned, is this: Request-scoped
Form beans, behind the scenes, do a request.getParameter() to set the
bean values, correct? But when there are multiple form fields with the
same name, the getParameter() won't do, Struts needs to call
request.getParameterValues(). I'm assuming its not smart enough to do
this? (Or is it doing this and I'm just doing something wrong?)

To counter this problem, in my Action classes associated with the form
bean, I grab values from the request object using getParameterValues(),
and store them into a String array. Then I call my setter method,
passing in the array. In other words, I call the setter manually, not
automatically by Struts.

Is there another workaround for this or is this my only option?


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




RE: Multiple checkboxes with the same name -- possible with Struts?

2002-02-28 Thread Kevin J. Turner

Alas, that deoesn't solve the problem.

> Look at the  tag. 



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




RE: Multiple checkboxes with the same name -- possible with Struts?

2002-02-28 Thread Kevin J. Turner

It does seem really similar. When you view the html source, does each
checkbox have the same "name" property? Also, to add to the complexity,
in my particular case, the list of checkboxes is dynamically generated
via the logic:iterate tag. It is not kwown ahead of time how many
checkboxes there will be.


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, February 28, 2002 1:02 PM
To: [EMAIL PROTECTED]
Subject: RE: Multiple checkboxes with the same name -- possible with
Struts?


I am not sure to understand your problem then.

In my case we have roles instead of fruit.  We have an activity that
have
more then one participant and each participant can have more then one
role.


[X]Organizer
[ ]Speaker
[ ]Attendee
[ ]Sponsor
... etc

My ActionForm contains a participant bean that has a role property
define as
String[] role;

The array of string gets populated properly with the option checked.  

Sorry if this is not what you are looking for, it just seems really
similar.


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




Multiple checkboxes with the same name -- possible with Struts?

2002-02-28 Thread Kevin J. Turner

Is it possible, using the Struts framework, to have multiple checkboxes
that are named the same but have different values?
 
First, a little background on this:

Say you have the following four fruity checkboxes on a form, with Apple
and Mango checked:
 
[x] Apple
[ ] Kiwi
[x] Mango
[ ] Banana
 
Each checkbox has the same html *name* property of "fruit", but they all
have different html "value" properties (Apple, Kiwi, etc).
 
In order to get those from the request you would need to do something
like this:
 
String[] fruit = request.getParameterValues("fruit");
 
If you just do a request.getParameter("fruit") with the above scenario,
then you'll only get one string back, "Apple" (because its the first one
selected).
 
So the problem is, where Struts is concerned, is this: Request-scoped
Form beans, behind the scenes, do a request.getParameter() to set the
bean values, correct? But when there are multiple form fields with the
same name, the getParameter() won't do, Struts needs to call
request.getParameterValues(). I'm assuming its not smart enough to do
this? (Or is it doing this and I'm just doing something wrong?)
 
To counter this problem, in my Action classes associated with the form
bean, I grab values from the request object using getParameterValues(),
and store them into a String array. Then I call my setter method,
passing in the array. In other words, I call the setter manually, not
automatically by Struts.
 
Is there another workaround for this or is this my only option?


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




RE: Multiple checkboxes with the same name -- possible with Struts?

2002-02-28 Thread Kevin J. Turner

I will try again.. there must be something I'm not doing right

Thx.

-Original Message-
From: Jonathan James [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, February 28, 2002 2:16 PM
To: Struts Users Mailing List; [EMAIL PROTECTED]
Subject: Re: Multiple checkboxes with the same name -- possible with
Struts?


>  I'm assuming its not smart enough to do
> this?

Nope. Struts is smart enough to do this. If you use the multibox tag as
David Gaulin
suggested and your bean looks like

public void setFruit( String[] fruits ) {...}
public String[] getFruit() {...}

Then all your multiboxes look like


and so on.

Your bean will be automatically populated with an array of all the
selected
fruits. So in your example

> [x] Apple
> [ ] Kiwi
> [x] Mango
> [ ] Banana

getFruit() in your action would return an array containg the strings
"Apple"
& "Mango"

Are you trying this and it's not working?

-Jonathan


--
To unsubscribe, e-mail:

For additional commands, e-mail:




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




"parameter" attribute in the action-mapping... what is it?

2002-03-05 Thread Kevin J. Turner

Could someone please explain the purpose and usage of the "parameter"
attribute for the action-mapping tag in the struts-config.xml file? 

Thanks in advance.



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




Where do I start to solve this error message: 'Cannot retrieve definition for form bean '

2002-03-08 Thread Kevin J. Turner

I have encountered the following error message in my Struts
application:

"Cannot retrieve definition for form bean "

Where do I start to look for a solution to this one? I'm stuck.


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




Re: Struts resources

2002-03-09 Thread Kevin J. Turner

On Fri, 8 Mar 2002 07:01:20 -0500, Andrew H. Peterson wrote:
--snip--
>Can anyone recommend some good resources for coming up to speed on
--snip--

Here's some usefull sites:
1) http://www.husted.com/struts -- Ted Husted's site, lots of stuff
there
2) http://stealthis.athensgroup.com/presentations/ -- a white paper
on Struts, assembled by Larry Maturo
3) The book, "Professional JSP : 2nd Edition" (Wrox Press, ISBN
1861004958), has an excellent chapter devoted entirely on Struts

Hope this helps.

--
Kevin J. Turner / dot com Entertainment Group
150 Randall Street, Oakville, Ontario L6J 1P4
telephone: 905.337.8524 fax: 905.337.8630



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




I'm bagging my head on the keyboard on this one: Cannot retrieve definition for form bean PlayerMessageForm

2002-03-10 Thread Kevin J. Turner

I'm getting this error message:

Cannot retrieve definition for form bean PlayerMessageForm

(PlayerMessageForm is a form bean in my project)

Here is that path I am following (struts-config entries to follow:
1) (other actions.. omitted for brevity)
2) /messageTypePRE.do, which forwards to...
3) /messaging/start.jsp, which submits to
4) /messageTypePOST.do, which forwards to...
5) /playerListPRE.do, which forwards to...
6) /messaging/playerList.jsp, where I get the error message

I know for a fact that the action playerListPRE.do does complete its
processing. I verified this with the debugger and also with
System.out statements. Its when it tries to load the JSP page,
player_list.jsp. that it craps out. Even with the following bare-
bones version of player_list.jsp:

-- snip --
  
  

  
  
-- snip --

I have the following mappings (among others) in my struts-config.xml
file:

-- snip --
..

  

..

  
  
  



   


-- snip --


So what is causing "Cannot retrieve definition for form bean
PlayerMessageForm" error??? Anyone?

--
Kevin J. Turner / dot com Entertainment Group
150 Randall Street, Oakville, Ontario L6J 1P4
telephone: 905.337.8524 fax: 905.337.8630




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




RE: I'm bagging my head on the keyboard on this one: Cannot retrieve definition for form bean PlayerMessageForm

2002-03-10 Thread Kevin J. Turner

On Sun, 10 Mar 2002 13:29:01 -0600, Chris Means wrote:
>Is this a typo or maybe the problem:
>
>-- snip --
>..
>
>ype="com.dceg.webapps.messaging.PlayerMessageForm" />
>
>..
>
>You'll notice that you have "ype" not "type".
>
>My names' not "Syntax Error" for nothing!

No that was just from evidently bad cutting-n-pasting.

It *does* have "type"

:P





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




are there any good tag usage examples anywhere online?

2002-03-11 Thread Kevin J. Turner

Does anyone know of any good web sites that show *examples* of all
the different Struts tags? The user guide is extremely ineffective in
that capactity.


--
Kevin J. Turner / dot com Entertainment Group
150 Randall Street, Oakville, Ontario L6J 1P4
telephone: 905.337.8524 fax: 905.337.8630



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




form bean roperties and ArrayLists

2002-03-15 Thread Kevin J. Turner

Can form bean properties be of type ArrayList?

And if yes, are there any special considerations when doing so, with
regards to the getter and setter methods?

I am using an ArrayList in a form bean as follows:

--- snip ---
...
private ArrayList recipients;
...
(in the constructor)
recipients = new ArrayList();
...

public void setRecipients(ArrayList recipients) {
  this.recipients = recipients;
}

public ArrayList getRecipients() {
  return this.recipients;
}

--- snip ---

I am getting the following error:

exception
javax.servlet.ServletException: BeanUtils.populate
...
root cause
java.lang.IllegalArgumentException: argument type mismatch

. and I suspect it has something to do with the ArrayList usage.


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




Re: form bean roperties and ArrayLists

2002-03-15 Thread Kevin J. Turner

On Fri, 15 Mar 2002 13:35:03 -0600, Robert Williams wrote:

>Data coming from a browser that is used to populate a form bean is
>basically
>of type String or String[].  I think if you change the ArrayList to
>a string
>array you will have better luck.  I haven't tried this yet but it
>has a
>better chance of working than the ArrayList declaration.
>

Oddly enough, I was originally using String arrays but I decided to
change to ArrayList instead!  Anyways, I found the solution to my
troubles, from the www.keyboardmonkey.com/struts sample application
(StrutMonkey.war, specifically in MonkeyTeamBean.java).

Here's what I did, in case anyone is interested. Quite a simple
solution actually.. I only had to change the getter and setter
methods:

-- snip--

public void setRecipients(Object[] newRecipients) {
recipients = new ArrayList();
for(int x=0; x < newRecipients.length; x++) {
recipients.add(newRecipients[x]);
}
}

public Object[] getRecipients() {
return this.recipients.toArray();
}

-- snip--




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




Netsted beans question...

2002-03-18 Thread Kevin J. Turner

Consider the following Nested beans scenario:

You have a message queue; the message queue maintains a list of
messages; each message maintains a list of one or more recipients.

The beans involved are :

MessageQueue --> MessageQueueItem --> MessageRecipients

(A MessageQueue has a HashMap of MessageQueueItems; each
MessageQueueItem has a HashMap of MessageRecipients)

If I want to use nested beans and Nested Bean tags on a JSP to
represent my message queue, do I have to make the root bean of
structure my ActionForm bean in order for it to work? Or can I simply
create an instance of my MessageQueue in an ActionClass and pop it
into the request or session scope? If the latter is possible, then
how do instruct the  tag to look in the request or
session for my instance of the MessageQueue?

Does this make sense?



--
Kevin J. Turner / dot com Entertainment Group
150 Randall Street, Oakville, Ontario L6J 1P4
telephone: 905.337.8524 fax: 905.337.8630



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




Form beans in session scope

2002-03-19 Thread Kevin J. Turner

I have configured my struts-config file to keep my form bean in
session scope. I don't know if this is good practice, but I wasn't
having much luck with the request scope.

In many of my action classes, if have to get a reference to my form
bean to do some business logic processing. I do so by doing the
following:

   MyFormBean mfb =3D (MyFormBean) form

Then I call some methods

   mfb.setAlpha("beta");
   mfb.setGamma("delta");
   etc..

At this point do I need to explicitly re-add/reset the form bean by
doing something like this:

   session.setAttribute(mapping.getAttribute(), mfb);

Or does calling the methods automatically update the form bean thats
in the session?




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




action class to action class interaction

2002-03-19 Thread Kevin J. Turner

I have many action classes that share a particular form bean. I would
like to use the session sparingly, therefore I would like to use
request scope for my form bean.

In some situations, a path similar to the following, is followed:

actionClass1 --> JSP1 --> actionClass2 --> actionClass3 --> JSP2

If all three classes share my request-scoped form bean, then how does
the form data get retained from actionClass1 to actionClass3? Does
actionClass2 need forward the request data along explicitly, i.e.
request.setAttribute() ? I guess I'm just not understanding how to
properly use request scope beans.

I tried using session-scoped system state beans to store the data
between requests but that just seemed like twice the work. The system
state beans had nearly the same data as the form beans. It seemed
redundant.


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




Re: are there any good tag usage examples anywhere online?

2002-04-02 Thread Kevin J. Turner

This never got answered.. anyone?

- Original Message - 
Subject: are there any good tag usage examples anywhere online?


Does anyone know of any good web sites that show *examples* of all 
the different Struts tags? The user guide is extremely ineffective in 
that capactity.

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




Struts Documentation

2002-04-09 Thread Kevin J Turner

Are the people who are responsible for the User Guide ever going to put
out documentation with *examples*. It would make life so much easier.




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




Re: Struts Tutorial

2002-04-09 Thread Kevin J Turner

On Tue, 9 Apr 2002, Stephan Wiesner wrote:

> Hi, I'm writing a Struts tutorial. The actual version (30 pages at the
> moment) can be found
> at:
> http://rzserv2.fhnon.de/~lg002556/struts/
>
> It is written in englisch. And intended as an easy, step by step
> introduction.
>
> Stephan
>

Pretty good tutorial. You may want to make the font size of the sample
code a bit bigger... I found it hard to read. Other than that, I got more
out of that than the Struts user guide.

Cheers

---
Kevin J Turner
dot com Entertainment Group, 150 Randall Street, Oakville, ON L6J 1P4
email: [EMAIL PROTECTED]  phone: 905.338.8524  fax: 905.337.8630


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




a nice to have feature...

2002-04-09 Thread Kevin J Turner

Maybe this is a message better suited for the struts-dev group... ah well,
here goes...

It would be a *really* useful feature if Struts would just ignore any tag
attributes that it doesn't know how to process, and simply pass them on
through, as is.

For example, there is handy attribute of the FORM tag (actually, the
text box supports this attribute as well) that turns off the (annoying)
form-field autocomplete feature in Internet Explorer: autocomplete="off".

e.g. 

This will prevent the form fields from displaying a drop-down list of
previously entered values. I would like to be able to use this feature
in my Struts pages, with something like:



... then when Struts encounters a name="value" pair that it doesn't know
how to process, like the autocomplete="off", it just displays the nvp
as-is. This would be very useful since the Struts tag library does not
cover all tag attributes.

I guess this is something I could do myself, by extending the appropriate
classes, yes? But that sounds like something best left for the pros.  ;)

Regards,

Kevin

---
Kevin J Turner
dot com Entertainment Group, 150 Randall Street, Oakville, ON L6J 1P4
email: [EMAIL PROTECTED]  phone: 905.338.8524  fax: 905.337.8630


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




Country List

2001-12-19 Thread Kevin J. Turner

I am involved in converting a large Active Server Pages (ASP)
application to a JSP/Servlets solution, using the Struts framework. I am
new to Struts and I have a relatively okay grasp of JSP/Servlets/Struts.
 
A few of the pages in the current project use an ASP include file that
creates an HTML SELECT object of Country names and their corresponding
2-digit ISO codes.. The code is encapsulated in a function call, with
the country code to be selected passed in as a parameter, as follows:
 
--- snip ---
<%
Call CountryList("country", "CA")
%>
--- snip ---
 
which produces HTML similar to the following:
 
--- snip ---

  Canada
  United States
  France
  Fiji
  Finland
  ...
  etc

--- snip ---
 
I would like to duplicate this functionality using
JSP/Struts/JavaBeans.. whatever.. but I'm not sure the best way to do
it. Could some offer advice on what the most elegant approach to this
would be? The obvious goal would be to have a reusable component/module
that produces the necessary HTML based on a static list of country names
and codes, and to be able to pre-select a country.
 
Any advice is appreciated.
 
Regards,
 
Kevin J. Turner



Building struts-example in JBuilder

2001-12-20 Thread Kevin J. Turner

I am trying to run the struts-example in JBuilder and not having any
luck. Here are the steps I took to set it up:
 
- First I deployed struts-example.war to my standalone Tomcat 3.2.4
server in order to expand the files (is there another way to expand a
WAR file?)
- created an empty JBuilder project and added a web application to the
project, called struts-example
- moved all the source files from the
\webapps\struts-example\WEB-INF\src folder to the \src folder in
the JBuilder project
- copied all the necessary *.xml, *.tld, *html and *.gif files to their
appropriate places under the struts-example root folder
- created a project library called "Struts 1.0" (in JBuilder --> Tools >
Configure Libraries) which consists only of struts.jar
- selected project Properties > Paths > Required Libraries and added the
following libraries:
- Struts 1.0 (struts.jar)
- Tomcat 3.2 Servlet (existing JBuilder library)
- JAXP (existing JBuilder library, required by Struts)
- selected the web application Properties > Classes and selected "Always
include all classes and resources", then under the Dependencies tab I
selected "Always include all classes and resources" for the "Struts 1.0"
library (so struts.jar) will be placed in the /lib folder of the web
application when deployed); and I selected "Never include any classes or
resources" for the other two libraries: "JAXP" and "Tomcat Servlet 3.2".
 
When I rebuild the project, it does so successfully, however I get nine
"class has been deprecated" warnings, for example:
 
"SaveRegistrationAction.java": Warning #: 368 : class
org.apache.struts.util.PropertyUtils in package org.apache.struts.util
has been deprecated at line 83, column 31"
 
... and:
 
"DatabaseServlet.java": Warning #: 368 : class
org.apache.struts.util.BeanUtils in package org.apache.struts.util has
been deprecated at line 83, column 31"
 
If I tried to run the project from within JBuilder anyways, and I got
the following error message (some of the message omitted for brevity):
 
--- snip ---
Error: 500 Location: /struts-example/index.jspInternal Servlet
Error:javax.servlet.ServletException: Missing message for key
index.title
 at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContex
tImpl.java:459)
 at
_0002findex_0002ejspindex_jsp_0._jspService(_0002findex_0002ejspindex_js
p_0.java:444)
 ... 

 Root cause: javax.servlet.jsp.JspException: Missing message for key
index.title
 at
org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:242)
 at
_0002findex_0002ejspindex_jsp_0._jspService(_0002findex_0002ejspindex_js
p_0.java:90)
 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
  ...
--- snip ---
 
I can run the application when I run it under my stand-alone Tomcat
3.2.4 Server but not when I run it under JBuilder (which uses v3.2.1).
 
Any suggestions? Any JBuilder users out there experiencing similar
problems? I'm relatively new to Struts and developing with JBuilder so
any help would be greatly appreciated. Thanks!
 
- Kevin J. Turner



New to Struts and stuck already...

2002-01-09 Thread Kevin J. Turner

I am trying to build a simple Struts app to play around with it and i'm
stuck on the following error message:
 
javax.servlet.ServletException: No bean found under attribute key
registrationForm
 
I have the following in my struts-config.xml file:
 

  ...
  

  
  ...

 
Any suggestions anyone?
 
Kevin J Turner



Need help with html:link and passing parameters on the querystring

2002-01-30 Thread Kevin J. Turner

I am trying to use the Struts tag, html:link, but I don't think I
understand its usage. Basically all I want to do is create a link to a
page in my application and one or more dynamic parameters in the query
string.
 
The non-Struts JSP link went something like this:
 
Service
 
I am trying to figure out the Struts equivalent but I am not having any
luck. I tried something like this:
 
">Service
 
... but it doesn't like the usage of the request.getParameter(). Can
anyone help?
 
I read the Struts documentation and browsed the struts-example app code
but I'm still not getting this.
 
K.



Examples needed

2002-01-30 Thread Kevin J. Turner

It would be nice if the Struts online documentation included examples
for all their tag libraries.
 
Hint. Hint.