RE: How to embed bean:message within a template

2001-04-30 Thread Niall Pemberton



template:put name="title" 
direct="true"
 bean:message 
key="index.title"/

/template:put

  -Original Message-From: Jeff Trent 
  [mailto:[EMAIL PROTECTED]]Sent: 30 April 2001 
  20:10To: [EMAIL PROTECTED]Subject: How to 
  embed bean:message within a template
  Newbie here. Just wondering how to 
  accomplish this using templates. 
  
   template:put name='title' 
  content='bean:message key="app.title"/' direct='true' 
  /
  Can't seem get the bean to evaluate the message 
  text... Suggestions? I tried direct on  off but no 
  luck.
  
  Thanks,
  Jeff
  
  


RE: Creating html:hidden ... dynamically

2001-04-30 Thread Niall Pemberton

 We plan to store bean data has hidden form objects , so that it could be
 passed to the subsequent pages, without having to make the scope of the
 beans to be session. We do not know how many attributes the bean objects
 can have, and plan to store it in an array of hidden form objects like
 this.

How about using a Tag to generate the hidden fields for each of the beans
properties.

I have written the following StoreBeanTag which does this.

Niall


 Start of StoreBeanTag---
package mytaglib;

import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;

import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspException;

import org.apache.struts.util.PropertyUtils;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.ResponseUtils;

/**
 *
 * This tag takes a Bean and stores all its properties/values
 * as hidden input type html tags.
 *
 * @author Niall Pemberton
 * @version 1.0
 */

public class StoreBeanTag extends TagSupport {

public static String QUOTE = \;

protected String name = null;
protected String property = null;
protected String scope = null;

/** Get the name */
public String getName() {
return (this.name);
}

/** Set the name */
public void setName(String name) {
this.name = name;
}

/** Get the property  */
public String getProperty() {
return (this.property);
}

/** Set the property */
public void setProperty(String property) {
this.property = property;
}

/** Get the scope of the property */
public String getScope() {
return (this.scope);
}

/** Set the scope of the property */
public void setScope(String scope) {
this.scope = scope;
}

/**
 * Process the tag
 */
public int doStartTag() throws JspException {

  StringBuffer buffer = new StringBuffer();

  // Find the specified Bean
  Object bean = null;
  if (property == null) {
bean = RequestUtils.lookup(pageContext, name, scope);
  } else {
bean = RequestUtils.lookup(pageContext, name, property, scope);
  }

  if (bean == null) {
// return (SKIP_BODY);
 JspException e = new JspException(StoreBeanTag: Missing bean  +
name+ +property);
 RequestUtils.saveException(pageContext, e);
 throw e;
  }

  // Get the beans properties
  PropertyDescriptor[] descriptors =
PropertyUtils.getPropertyDescriptors(bean);
  for (int i = 0; i  descriptors.length; i++) {
  String name = descriptors[i].getName();
  if (!(name.equals(class))) {
try {
  Object value = PropertyUtils.getSimpleProperty(bean, name);
  name = property == null ? name : property+.+name;
  buffer.append(createHiddenField(name, value));
}
catch (NoSuchMethodException ex) {}
catch (InvocationTargetException ex) {}
catch (IllegalAccessException ex) {}
  }
  }

  // Print the created message to our output writer
  ResponseUtils.write(pageContext, buffer.toString());

  // Continue processing this page
  return (SKIP_BODY);
}


/**
 * Create a hidden field for the property
 */
protected String createHiddenField(String property, Object obj) {

  if (obj == null)
return ;

  String value = obj.toString();
  if (value == null  || value.equals())
return ;

  return input type=+QUOTE+hidden+QUOTE+
name=+QUOTE+property+QUOTE+
   value=+QUOTE+value+QUOTE+/\r\n;

}
/**
 * Release all allocated resources.
 */
public void release() {

super.release();

name = null;
property = null;
scope = null;
}

}
 End of StoreBeanTag---




RE: Suggestion/Idea for iterate tag: Iterate ResultSets

2001-05-07 Thread Niall Pemberton

I haven't used it, but this looks similar to whats been developed in the
jakarta taglibs project - see JDBC taglib.

   http://jakarta.apache.org/taglibs/doc/jdbc-doc/intro.html

Niall

 -Original Message-
 From: Mindaugas Idzelis [mailto:[EMAIL PROTECTED]]
 Sent: 07 May 2001 15:06
 To: [EMAIL PROTECTED]; Jonathan Asbell
 Subject: RE: Suggestion/Idea for iterate tag: Iterate ResultSets


 I just thought of another option: If resultsets are tied to a
 connection and
 a statement, then specify the sql query within the iterator:

 Hypothetical taglibs:
 sql:query id=myQuery
   SELECT col1, col2
   FROM table
   WHERE id  1
   !-- even use bean:write in here to dynamically
 make queries --
 /sql:query
 logic:iterate id=row query=myQuery
   bean:write name=row property=col1/
   bean:write name=row property=col2/
   br
 /logic:iterate

 Where sql:query would only be evauluated once per iteration. Would this be
 possible to create? I have never authored a taglib, so any feedback from
 taglib veterans is greatly appreciated. I think this would be a great
 addition to the taglibs framework.

 --min

 -Original Message-
 From: Jonathan Asbell [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, May 06, 2001 11:47 PM
 To: [EMAIL PROTECTED]
 Subject: Re: Suggestion/Idea for iterate tag: Iterate ResultSets


 Result sets ARE tied to the connection in a way.  Some DB drivers throw
 exceptions when you try to manipulate data while you still have a
 pointer to
 rows.  At work we were trying to manipulate a stream which was pointing to
 an output parameter in a stored proc while the connection was open.  The
 result was that we had to convert the stream into another object
 (String in
 our case) and close the connection just to manipulate the data.

 - Original Message -
 From: Mindaugas Idzelis [EMAIL PROTECTED]
 To: struts [EMAIL PROTECTED]
 Sent: Sunday, May 06, 2001 9:33 PM
 Subject: Suggestion/Idea for iterate tag: Iterate ResultSets


  I just thought up of an excellent idea (although, I wasn't the
 only one).
  Use the iterate tag to iterate over the rows of a resultset. The column
 meta
  data could be exposed as beans named as the column name. A bean:write
  operation would display the data in the column.
 
  I did a search about this topic in the mailing list archive, and I found
  this message:
 
  http://marc.theaimsgroup.com/?l=struts-userm=98269295229785w=2
 
  It talk about ResultSets being tied to connections. This is not
 the case.
  ResultSets are tied to the statements that produced them, and
 as far as I
  can tell, statements are not closed when the connection is closed.
 
  Other than that, It should be easy to change the iterate tag to support
  resultsets. If anyone is interested in helping me extend or
 develop a tag
  for this purpose, please message me.
 
  --min
 






RE: Application Scoped Object Initialization

2001-05-08 Thread Niall Pemberton

Sub-class ActionServlet and override the init() method.

Also a good idea to override the destroy() method to clean up allocated
resources. Additionally the reload() method does the destroy and init
actions to re-load the servlet.


  public void init() throws ServletException {
 super.init();
 initMyClass();
  }

  public void initMyClass() throws ServletException {
 MyClass myClass = new MyClass();
 getServletContext().setAttribute(myPackage.MyClass, myClass);
  }

  public void destroy() throws ServletException {
 super.destroy();
 destroyMyClass();
  }

  public void destroyMyClass() {
 // clean up allocated resources here
  }

  public void reload() throws IOException, ServletException {

 super.reload();

 // Shut down
 destroyMyClass();

 // Restart
 initMyClass();
  }



-Original Message-
From: Jeff Trent [mailto:[EMAIL PROTECTED]]
Sent: 08 May 2001 15:52
To: [EMAIL PROTECTED]
Subject: Application Scoped Object Initialization


What is the suggested method for singleton, application scoped object
initialization?  Where  how does it happen?

I want to create a singleton containing shared cached lists to be used in
populating html:options with.

Thanks.




RE: textarea and wrap

2001-05-09 Thread Niall Pemberton

I have had other similar issues and I think a very useful enhancement to all
Struts tags would be to make them more granular so that they could be easily
sub-classed and modified. Currently methods such as doStartTag() tend to
have one big lump of code which means if you want to change it behaviour you
have to override it and then duplicate much of the code in the original
method. An example of the kind of structure I'm looking for is below:

From the CheckboxTag:

  public int doStartTag() throws JspException {

StringBuffer results = new StringBuffer(input type=\checkbox\);

  results.append(prepareName());
  results.append(prepareAccessKey());
  results.append(prepareTabindex());
  results.append(prepareValue());
results.append(prepareEventHandlers());
results.append(prepareStyles());
results.append();

// Print this field to our output writer
JspWriter writer = pageContext.getOut();
try {
writer.print(results.toString());
} catch (IOException e) {
throw new JspException
(messages.getMessage(common.io, e.toString()));
}

// Continue processing this page
return (EVAL_BODY_TAG);
  }
  protected String prepareName() {
  return  name=\+this.property+\;
  }

  etc. etc.



 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of
 Matthias Bauer
 Sent: 09 May 2001 11:38
 To: [EMAIL PROTECTED]
 Subject: Re: textarea and wrap


 I posted a bug report and sent a patch for struts on this one. I
 think this was
 last week. The committers decided not to include it, because the
 wrap attribute
 is not in the HTML spec. This is really unfortunate, escpecially
 because the
 little patch I already provided is just a minor change and would
 be useful for
 pretty many developers, I think.

 So what I am doing: I am patching struts locally. You should be
 able to find my
 mail with the patch in the mail-archive.

 --- Matthias



 William Jaynes wrote:
 
  I usually need 'wrap=virtual' as an attribute for my textareas. It
  isn't part of the HTML spec, but it's supported in both Netscape and IE,
  and it's pretty useful. I wonder how people are dealing with the lack of
  a wrap attribute in the struts textarea tag.
  --
  William Jaynes | University of Michigan Medical School
  [EMAIL PROTECTED] | 734-763-6751




RE: Posting Collections

2001-05-09 Thread Niall Pemberton

The problem is the CheckBox tag currently sets the HTML name attribute to
the property, so your JSP will produced something like this:

input type=checkbox name=delete

So all the checkbox fields will have the same name.

In order for Struts to populate your Retailer bean with the delete values
you need the generated HTML to look like this:

input type=checkbox name=retailer[0].delete
input type=checkbox name=retailer[1].delete etc etc.

Struts would then use getRetailer(0).setDelete(boolean) to set the delete
attributes correctly.

Unfortunately there is no easy solution - many people resort to scriptlets
to generate the name properly and there are quite a few messages in the
archive about this.

I created my own versions of Struts tags and changed them to generate the
name correctly - I like that much better - no java in the view.

Niall

 -Original Message-
 From: Tony Karas [mailto:[EMAIL PROTECTED]]
 Sent: 09 May 2001 17:50
 To: [EMAIL PROTECTED]
 Subject: Posting Collections


 Briefly, this is what I am trying to achieve:

 - Retrieve a list of items from a database
 - Display each item with a corresponding checkbox
 - Display a Delete button - which when pressed deletes all
 checked items.

 Unfortunately, although I have managed to display the items correctly and
 set the checkbox value using boolean values, when I do the form
 submit - my
 ActionForm properties do not get filled in.

 This is the code I have:

 My ActionForm looks like this:

 public class RetailerForm extends ActionForm
 {
 protected Vector retailer;

 /*
  * On construction, fill the form with all the retailers
  */
 public RetailerForm() throws SQLException
 {
  //here i have some code to generate my vector
  //which is comprised of Retailer beans.
 }

 public Retailer getRetailer( int index )
 {
 return (Retailer)retailer.elementAt( index );
 }

 public Vector getRetailer()
 {
 return retailer;
 }

 public void setRetailer( Vector value )
 {
 retailer = value;
 }
 }

 My Retailer bean has get and set elements for properties called
 delete
 and name.

 My struts code looks like this (obviously within html:form tags):

 logic:iterate id=retailer name=retailerForm property=retailer
   tr
   tdhtml:checkbox name=retailer property=delete//td
   tdbean:write name=retailer property=name//td
   /tr
 /logic:iterate

 And this all works ok for displaying the data.  However, when I do the
 submit my delete property for each bean is not set and I have added
 debugging code to the set method and this is not called by struts.  I
 don't get error messages - it just doesn't happen.

 I know other people have had this problem, but I am struggling to find a
 solution.

 Can anyone help me?  Is there a better way of achieving what I am
 trying to
 achieve?  If I am doing the correct thing, what's the reason it's not
 working.

 All help appreciated.

 Cheers
 Tony
 _
 Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.






RE: ConnectionPooling in struts

2001-05-09 Thread Niall Pemberton

I'm using MySQL rather than Oracle...

--Struts-congif.xml-
struts-config
  data-sources
data-source description=MySQL-test
 driverClass=org.gjt.mm.mysql.Driver
url=jdbc:mysql://localhost/test
   password=
   user=
 autoCommit=true
   maxCount=4
   minCount=2 /
/data-sources
/struts-config

--Action---

  public ActionForward perform(ActionMapping mapping,
   ActionForm form,
   HttpServletRequest request,
   HttpServletResponse response) {

nextAction = success;

// Create Database connection
Connection connection = null;

// Insert Build Program Items
try {
  DataSource dataSource =
(DataSource)servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY)
;
  connection = dataSource.getConnection();

  Statement statement = connection.createStatement();
  ResultSet result = statement.executeQuery(SELECT * FROM orders);

  }
}
catch (SQLException sqle) {
  // Log exception and post error message
  servlet.log(ActionDB-SQL Exception: , sqle);
  nextAction = error;
}
finally {
  try {
if (connection != null) {
  connection.close();
}
  }
  catch (SQLException sqle) {
servlet.log(ActionDB-SQL Exception Closing Connection: , sqle );
  }
  // Forward control to the specifiedURI
  return (mapping.findForward(nextAction));
}
  }



-Original Message-
From: Dinu Jose [mailto:[EMAIL PROTECTED]]
Sent: 09 May 2001 19:38
To: '[EMAIL PROTECTED]'
Subject: ConnectionPooling in struts


Hi All,
Could somebody help me in solving this issue.
I need  an  example of connection pooling in struts.
I had to use the oracle thin driver
The files needed are:
i) struts-config.xml
ii) java class
I want to know how I must write the datasource part in
struts-config.xml.
and the java class which extends the Action class.
I have tried the example given in the struts site ,but didn't
succeed.
and it is not fully given.
Waiting for your help.
thanks in advance
Dinu




RE: Posting Collections

2001-05-09 Thread Niall Pemberton

The problem is the CheckBox tag currently sets the HTML name attribute to
the property, so your JSP will produced something like this:

input type=checkbox name=delete

So all the checkbox fields will have the same name.

In order for Struts to populate your Retailer bean with the delete values
you need the generated HTML to look like this:

input type=checkbox name=retailer[0].delete
input type=checkbox name=retailer[1].delete etc etc.

Struts would then use getRetailer(0).setDelete(boolean) to set the delete
attributes correctly.

Unfortunately there is no easy solution - many people resort to scriptlets
to generate the name properly and there are quite a few messages in the
archive about this.

I created my own versions of Struts tags and changed them to generate the
name correctly - I like that much better - no java in the view.

Niall

 -Original Message-
 From: Tony Karas [mailto:[EMAIL PROTECTED]]
 Sent: 09 May 2001 17:50
 To: [EMAIL PROTECTED]
 Subject: Posting Collections


 Briefly, this is what I am trying to achieve:

 - Retrieve a list of items from a database
 - Display each item with a corresponding checkbox
 - Display a Delete button - which when pressed deletes all
 checked items.

 Unfortunately, although I have managed to display the items correctly and
 set the checkbox value using boolean values, when I do the form
 submit - my
 ActionForm properties do not get filled in.

 This is the code I have:

 My ActionForm looks like this:

 public class RetailerForm extends ActionForm
 {
 protected Vector retailer;

 /*
  * On construction, fill the form with all the retailers
  */
 public RetailerForm() throws SQLException
 {
  //here i have some code to generate my vector
  //which is comprised of Retailer beans.
 }

 public Retailer getRetailer( int index )
 {
 return (Retailer)retailer.elementAt( index );
 }

 public Vector getRetailer()
 {
 return retailer;
 }

 public void setRetailer( Vector value )
 {
 retailer = value;
 }
 }

 My Retailer bean has get and set elements for properties called
 delete
 and name.

 My struts code looks like this (obviously within html:form tags):

 logic:iterate id=retailer name=retailerForm property=retailer
   tr
   tdhtml:checkbox name=retailer property=delete//td
   tdbean:write name=retailer property=name//td
   /tr
 /logic:iterate

 And this all works ok for displaying the data.  However, when I do the
 submit my delete property for each bean is not set and I have added
 debugging code to the set method and this is not called by struts.  I
 don't get error messages - it just doesn't happen.

 I know other people have had this problem, but I am struggling to find a
 solution.

 Can anyone help me?  Is there a better way of achieving what I am
 trying to
 achieve?  If I am doing the correct thing, what's the reason it's not
 working.

 All help appreciated.

 Cheers
 Tony
 _
 Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.






RE: Posting Collections

2001-05-10 Thread Niall Pemberton

This issue applies to all form field tags, not just checkboxes.

Modifying struts tags is currently a pain, but I just subimitted a bugzilla
enhancement to re-factor the tags so that they are more granualar and make
it easier to override descrete bits such as generating the name attribute.
In principle the enhacement has been accepted and I hope to submit a patch
in the next few days. If it is accepted I will have a set of custom versions
of these tags for this behviour very soon and you won't have to start
hacking around with the code every time a new version comes out and anyone
will be welcome to them.

Addtionally this issue is all on the ToDo list for 1.1 and I'm sure it
will be sorted then.

I think struts is excellent, and I love open source because you can always
look inside to see what they've done. Of course it doesn't do everything yet
;-) but I can't see it getting anything but better. We have done quite a bit
of work customizing the ActionServlet and the way its been built is
excellent, making it really easy to add addtional behaviour (hopefully)
without having to hack around every time a new version comes out.

Niall

 -Original Message-
 From: Tony Karas [mailto:[EMAIL PROTECTED]]
 Sent: 10 May 2001 10:34
 To: [EMAIL PROTECTED]
 Subject: RE: Posting Collections


 Many thanks Niall, that clears things up for me.  Do you know if
 there is a
 reason why this is the behaviour for checkboxes?  Is this just with
 checkboxes or other tags as well?

 I don't really like the idea of modifying the struts code - the
 whole point
 of deciding to use it is for code reuse - I don't want to start hacking
 around with the code every time a new version comes out.

 Do you have an opinion on using Struts?  I've been using it for a
 couple of
 weeks now and have been struggling because of basic lack of
 information.  I
 get most of my training from this news group!  I'm wondering whether I
 should just jack it in and use something else.

 Cheers
 Tony


 From: Niall Pemberton [EMAIL PROTECTED]
 Reply-To: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: RE: Posting Collections
 Date: Wed, 9 May 2001 20:51:00 +0100
 
 The problem is the CheckBox tag currently sets the HTML name attribute to
 the property, so your JSP will produced something like this:
 
  input type=checkbox name=delete
 
 So all the checkbox fields will have the same name.
 
 In order for Struts to populate your Retailer bean with the delete values
 you need the generated HTML to look like this:
 
  input type=checkbox name=retailer[0].delete
  input type=checkbox name=retailer[1].delete etc etc.
 
 Struts would then use getRetailer(0).setDelete(boolean) to set the delete
 attributes correctly.
 
 Unfortunately there is no easy solution - many people resort to
 scriptlets
 to generate the name properly and there are quite a few messages in the
 archive about this.
 
 I created my own versions of Struts tags and changed them to generate the
 name correctly - I like that much better - no java in the view.
 
 Niall
 
   -Original Message-
   From: Tony Karas [mailto:[EMAIL PROTECTED]]
   Sent: 09 May 2001 17:50
   To: [EMAIL PROTECTED]
   Subject: Posting Collections
  
  
   Briefly, this is what I am trying to achieve:
  
   - Retrieve a list of items from a database
   - Display each item with a corresponding checkbox
   - Display a Delete button - which when pressed deletes all
   checked items.
  
   Unfortunately, although I have managed to display the items correctly
 and
   set the checkbox value using boolean values, when I do the form
   submit - my
   ActionForm properties do not get filled in.
  
   This is the code I have:
  
   My ActionForm looks like this:
  
   public class RetailerForm extends ActionForm
   {
   protected Vector retailer;
  
   /*
* On construction, fill the form with all the retailers
*/
   public RetailerForm() throws SQLException
   {
//here i have some code to generate my vector
//which is comprised of Retailer beans.
   }
  
   public Retailer getRetailer( int index )
   {
   return (Retailer)retailer.elementAt( index );
   }
  
   public Vector getRetailer()
   {
   return retailer;
   }
  
   public void setRetailer( Vector value )
   {
   retailer = value;
   }
   }
  
   My Retailer bean has get and set elements for properties called
   delete
   and name.
  
   My struts code looks like this (obviously within html:form tags):
  
   logic:iterate id=retailer name=retailerForm property=retailer
 tr
 tdhtml:checkbox name=retailer property=delete//td
 tdbean:write name=retailer property=name//td
 /tr
   /logic:iterate
  
   And this all works ok for displaying the data.  However, when I do the
   submit my delete property for each bean is not set and I have added
   debugging code to the set method and this is not called

RE: How can I use set-property property=foo value=123 / in struts-config.xml

2001-05-11 Thread Niall Pemberton

I think you got the wrong end of the stick. The action elements in
struts-config relate to ActionMapping classes, not the Action class.

You need to sub-class the ActionMapping class and add your properties and
getters/setters to that class.

Then you need to add a init-param element for the ActionSrvlet to the
web.xml to tell it to use your custom ActionMapping class as follows:

  init-param
 param-namemapping/param-name
 param-valuecom.myPackage.myActionMapping/param-value
  /init-param

Then in your action class you need to cast the mapping object to your custom
class and then call the getter to retrieve the property values.

Niall

 -Original Message-
 From: David Holland [mailto:[EMAIL PROTECTED]]
 Sent: 11 May 2001 18:08
 To: '[EMAIL PROTECTED]'
 Subject: How can I use set-property property=foo value=123 / in
 struts-config.xml


 How can I use set-property property=foo value=123 / in
 struts-config.xml ?

 I want to use it in place of forward to store Action configuration info
 (set-property is
 specified in the dtd).

 Tried to add getter  setter to Action descendant - but assignment by
 introspection
 didn't seem to work.

 Looked at the source for ActionServlet, and the digester class does appear
 to be doing something
 with this property, although it looks like it is only looking for a single
 instance in an action.

 As far as I can tell, either it is not intended for general use or it is
 broken.

 Any thoughts?

 David Holland
 [EMAIL PROTECTED]






RE: Determining odd-even table rows

2001-05-11 Thread Niall Pemberton

I have a RowTag that does this, it generates tr elements and you can
specify either oddColor/evenColor attributes to generate bgcolor= attributes
or oddStyle/evenStyle parameters to generate class= attributes for CSS.

So the jsp looks like this:

  table
logic:iterate id=.. name=.. property=..
   util:row oddColor=#C0C0C0 evenColor=#FF
td./td
td./td
   /util:row
/logic:iterate
  /table

You can either specify both odd and even or just one of them.

I'll send it if you're interested.

Niall


 -Original Message-
 From: Bill Pfeiffer [mailto:[EMAIL PROTECTED]]
 Sent: 11 May 2001 20:08
 To: Struts-User
 Subject: Determining odd-even table rows


 I'm trying to figure out how to do a green-bar effect (different backround
 colors for every other row of a table) with struts/jsp.  I am using a
 tagified javax.sql.Rowset.  I can iterate through the rowset via my tags
 (reworked jakarta DBTags).  The problem, more of a mental block,
 is how do I
 alternate the backround colors of the html rows I am writing WITHOUT
 resorting to scriptlets.  I have just added a tag to get the
 current row, so
 I have that returing, but what do I do with it?

 The logic tags in struts deal only with comparisons to constants.
  I need to
 do some math to determine whether the current row is odd/even so I can set
 the backround.

 Is it easier than this and I'm missing it?

 My goal here is not to do any scriplets.  I'm putting together a
 set of tags
 to help our web guy build pages using only tags.

 Thanks for any help,

 Bill Pfeiffer






RE: FW: Determining odd-even table rows

2001-05-13 Thread Niall Pemberton

Fine by me. Great job on the web site by the way.

Niall

 -Original Message-
 From: Ted Husted [mailto:[EMAIL PROTECTED]]
 Sent: 13 May 2001 11:48
 To: [EMAIL PROTECTED]
 Subject: Re: FW: Determining odd-even table rows
 
 
 Cool. I've made it available for download on my Struts page, if that's
 all right. 
 
  http://husted.com/about/struts/ 
 
 
 Niall Pemberton wrote:
  OK, its attached.
 



RE: Iterate index property example?

2001-05-13 Thread Niall Pemberton

The RowTag I wrote uses it - up until 28/04/2001 you couldn't access it
(thats afte 1.0-b1), after that Craig added a getIndex() method.

You can download my RowTag from Ted Husted's site at:

http://husted.com/about/struts/

Niall

 -Original Message-
 From: David Lieberman [mailto:[EMAIL PROTECTED]]
 Sent: 13 May 2001 13:56
 To: [EMAIL PROTECTED]
 Subject: Iterate index property example?


 Can anyone send me an example for accessing the index property of the
 iterate tag?

 Thanks!

 --

 ___

 David Lieberman
 Software Engineer, Multimedia Group, ITG
 Harvard Business School
 Cotting House 317
 Boston, MA 02163
 617.495.6389
 ___







RE: Editing tabular data

2001-05-14 Thread Niall Pemberton

There are quite a few messages in the archive about this:

   http://www.mail-archive.com/struts-user%40jakarta.apache.org/

A couple of messages from a recent thread:

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

Niall

 -Original Message-
 From: James Howe [mailto:[EMAIL PROTECTED]]
 Sent: 14 May 2001 21:17
 To: [EMAIL PROTECTED]
 Subject: Editing tabular data


 I'm currently in the process of coding a Struts-based JSP page which will
 let my user edit a table of values.  I started out by creating a
 read-only
 display of values  using the logic:iterate tag and bean:write tags.  The
 object associated with the iterate tag answers a collection of
 beans and I
 have several bean:write tags which are used to display the properties of
 the bean.  It looks something like this:

 logic:iterate id=bean name=beanCollector property=beanCollection
 tr
   td width=70bean:write name=bean property=prop1
 filter=false//td
   td width=70bean:write name=bean property=prop2
 filter=false//td
   [ more attributes ...]
 /tr
 /logic:iterate

 I'm now somewhat at a loss as to how to construct a screen which will let
 the user update any and all fields in the table and save them.
 Can anybody
 provide and example of how I might go about building a page which
 can edit
 a table of information?

 Thanks.






RE: is it a bug of CheckboxTag

2001-05-14 Thread Niall Pemberton

This is an HTML issue.

Lots of discussion in the archives about this:

A recent one:

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

Niall

 -Original Message-
 From: JeanX [mailto:[EMAIL PROTECTED]]
 Sent: 15 May 2001 04:00
 To: struts-user
 Subject: is it a bug of CheckboxTag
 
 
 Hi struts-user,
 
 If I uncheck a checkbox, there is no corresponding parameter pair 
 in request.
 So I can not get the right status of certain form.
 How to resolve it ?
 
 
 :=)
 Best regards,
 JeanX
 pacificnet.com(GZ)
 
 



IF / ELSE and SWITCH/CASE Tags

2001-05-14 Thread Niall Pemberton

Attached are tags to do If/Else and Switch/Case logic, based on existing
Struts logic tag classes - the key classes inherit from the Struts
CompareTagBase.

1) IF/ELSE: (IfTag, ThenTag, ElseTag)

The IfTag provides the same functionality as the Equal, NotEqual, LessEqual,
LessThan, GreaterThan, GreaterEqual, Match, NoMatch, Present, NotPresent
tags by specifying that in the op attribute.

Example Usage:

  logic:if op=GreaterThan name=testbean property=doubleProperty
value=400
  logic:then
Property Greater Than Value
  /logic:then
  logic:else
Property Not Greater Than Value
  /logic:else
  /logic:if


2) SWITCH/CASE: (SwitchTag, CaseTag, DefaultTag)

Example Usage:

  logic:switch name=testbean property=doubleProperty
logic:case value =11 matched/logic:case
logic:case value =321321 matched 1st/logic:case
logic:case value =321321 matched 2nd/logic:case
logic:case value =55 matched/logic:case
logic:defaultNo values matched - default processing/logic:default
  /logic:switch

[[ LOGIC.ZIP : 1544 in winmail.dat ]]

 winmail.dat


RE: Suggestion:Taking the Servlet out of Action and ActionForm

2001-05-17 Thread Niall Pemberton

I don't agree - Actions are part of the controller in MVC and need access to
the servlet API to do thing such as retrieving and storing objects under the
appropriate context. Sounds to me like 1) Your using the wrong tool and 2)
You've put your Model in the Actions.

1) Cactus is a simple test framework for unit testing server-side java code.
It uses JUnit and extends it. It's primary goal is to be able to unit test
server side java methods which use Servlet objects such as
HttpServletRequest, HttpServletResponse, HttpSession etc.
   http://jakarta.apache.org/commons/cactus/

HttpUnit is a Java library for the automatic stimulation and testing of web
applications - which is supposed to be complimentary to Cactus.
   http://sourceforge.net/projects/httpunit

I haven't used these tools, but I'm about to download them and try them out.
Also I know Struts is in the process of setting up Cactus test suites so it
sounds like is more appropriate than JUnit for this environment.


2) If you succeed in separating your Model from the controller then you
should end up with a set of small Action classes. Testing your model outside
of the servlet enviornment should then be pretty straight forward. This is
what we've done and it works well.

Niall


 -Original Message-
 From: Mikkel Bruun [mailto:[EMAIL PROTECTED]]
 Sent: 17 May 2001 10:02
 To: '[EMAIL PROTECTED]'
 Subject: Suggestion:Taking the Servlet out of Action and ActionForm


 Hi guys,

 Here's a little design suggestion. I don't know if you have already
 discussed this.

 As we all know Action and ActionForm makes use of parts of the Servlet API
 (HttpRequest).
 This ties the execution of Action and ActionForm to a servlet enviroment.
 This is not bad, but (imho) it isn't good either...

 * We are not able to test our Actions in other enviroments (JUNIT for
 instance)
 * It's not possible to port our Action and ActionForm implementations to
 other types of applications (applet,  console)

 A couple of month ago I implemented my own Model2 framework that
 worked with
 a socalled RequestContext.
 The RequestContext contained three HashSet's, representing
 request-, session
 and applicationattributes
 In the Servlet's service (post/get) method we would populate the
 RequestContext with all request, session and applications attributes and
 pass it along the our viewvalidator (in this case an ActionForm object),
 that would extract the needed parameters and react to them (this
 could still
 be done with reflection as in struts).
 Any output from the validation would then be placed in the
 RequestContext's
 Collection (as a proxy to the *real* HttpRequest, HttpSession, etc,
 objects).
 If the validation was succesful the Servlet would then pass the
 RequestContext to a Command (or Action). The command would then extract it
 needed parameters and work on them.
 Once again, output would be place in the RequestContext's
 representation of
 Request, Session and Application.
 When the Command (or Action) was completed, the Servlet would iterate
 through the RequestContext and place all the attributes into their
 respective scope.

 The important point here is that the RequestContext wasn't tied to the
 Servlet API, although it could be initialized with HTTPRequest as
 parameter.

 By doing the above we were able to create validations and actions that we
 could easily test and reuse.
 What we usually did was that we created JUNIT testcases where we created
 instances of RequestContext and passed it to our Actions and eveluated the
 return values...These JUNIT cases could then be run from anywhere.
 We actually had our deployment done by Ant, and our deployment
 scripts would
 run all our testcases before deploying...
 We could actually test all of our application from the commandline...

 Just my two cents...

 Mikkel Bruun






RE: Problem with dynamic form elements

2001-05-17 Thread Niall Pemberton

There are quite a few messages in the archive about this:

   http://www.mail-archive.com/struts-user%40jakarta.apache.org/

A couple of messages from a recent thread:

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

Niall

 -Original Message-
 From: Prior, Simon [mailto:[EMAIL PROTECTED]]
 Sent: 17 May 2001 12:50
 To: '[EMAIL PROTECTED]'
 Subject: Problem with dynamic form elements
 Importance: High


 Hi Guys,

 I have a question about dynamic form elements that I was hoping someone
 could answer.

 Basically, I have a page I populate with elements from a database
 where the
 number of entries is unknown.

 For each of the rows retrieved, I extract some information and create an
 entry in a table on the page.  Each of the rows has a text box associated
 with it - also generated dynamically.  An Iterator tag is used to
 create the
 rows in the table and hence an index for each of the text box elements.

 My question is this, when I enter information into the text boxes, I would
 like this reflected onto my actionform automatically by Struts.  However,
 because I don't know how many text boxes will be present on the page, I
 can't provide set methods for each one.

 So how is it done?

 Thanks in advance,

 Simon.





RE: html:image bug?

2001-05-17 Thread Niall Pemberton

You can look at the history of changes to Struts throug CVS Web, for
ImageTag:

http://jakarta.apache.org/cvsweb/index.cgi/jakarta-struts/src/share/org/apac
he/struts/taglib/html/ImageTag.java

According to the entries this bug was fixed on 27/02/2001, so you need a
nightly build after that to correct your problem.

Niall

 -Original Message-
 From: Nathan Coast [mailto:[EMAIL PROTECTED]]
 Sent: 17 May 2001 15:03
 To: struts-user
 Subject: html:image bug?


 Hi

 %@ taglib uri=/WEB-INF/tld/struts-html.tld prefix=html %
 html:image alt=submit style=cursor:hand src=/img/but_submit.gif /

 results in this html being generated:

 input type=image name= src=/img/but_submit.gifalt=submit
 style=cursor:hand

 obvious problems with name= and src=/img/but_submit.gifalt=submit

 Can anyone confirm if this is a bug? had a look at bugzilla but
 couldn't find
 any matching bugs.

 Cheers
 Nathan








Form Processing

2001-05-17 Thread Niall Pemberton

Perhaps there are some ideas here that could be used in Struts?

Facilitate form processing with the Form Processing API:

   http://www.javaworld.com/jjw/javtut_nl/jw-04-2001/jw-0427-forms.html

Opinions?

Niall

 winmail.dat


RE: Suggestion:Taking the Servlet out of Action and ActionForm

2001-05-17 Thread Niall Pemberton

Mikkel

OK I agree, its never so black  white and your user example looks fine to
me.

I'm wondering about your inner controller - sounds like some great
integrated framework, in which case I agree its probably a level of
abstraction I wouldn't want to go to. But what about lots of small
controllers which tie together your logic outside the action.

Anyway, I was probably misleading in saying thats what we've done. What I
have actually done is this:

We have sub-classed Action and created some abstract standard classes, our
database action does something like this:

1) Get a database connection
2) Create a Transport object and store the ActionMapping,
HttpServletRequest, HttpServletResponse  Connection.
3) Set the default nextAction to success

4) call a processForm(ActionForm, Transport) method (implemented as an
abstract method) catching and handling exceptions.

5) Check the Transport object for error messages. If there are errors create
ActionErrors and save and if a nextAction returned by the Transport object
use it otherwise set the nextAction to failure.
6) Close the Connection
7) Find the mapping for nextAction and forward to it.

All out actions then inherit from this ActionFramework class overriding the
processForm(ActionForm, Transport) method. This means that our Action
classes have no references to the servlet world, meaning we can test them
independantly.

Now I know straight away you are going to say that I am storing the
ActionMapping, HttpServletRequest  HttpServletResponse in my Transport
object - so far I haven't used them anywhere, it was just in case I ever
needed to. Also if I ever do I will try to hide this in a new method in the
Transport object.

What do you think?

Niall

 -Original Message-
 From: Mikkel Bruun [mailto:[EMAIL PROTECTED]]
 Sent: 17 May 2001 20:58
 To: 'Niall Pemberton '; '[EMAIL PROTECTED] '
 Subject: RE: Suggestion:Taking the Servlet out of Action and ActionForm


 Hi Niall,

  I not sure I agree with you, although you have som good points.

 When looking at the MVC pattern we can easily identify two of the
 elements,
 namely the view (jsp) and the model (usually persistent object)...
 However, where is our controller??? As you point out, in the
 struts context
 the controller would be (partly) the Action, and probably some kind of
 Facade pattern towards the Model...

 However, in the classic sense of the MVC, the Controller should
 be reusable
 between many applications, and the Action dependence to the Servlet API
 doesn't (strictly speaking) make this possible.

 The solution to this is ofcourse to build a inner Controller, with close
 ties to the Model, such as an Facade or a (none Servlet specific) Command.
 However, I Feel that this just introduces another level of
 abstraction, and
 this abstraction should/could be made by the Action

 To give you a clue of the granularity of my Actions I give you
 the following
 example, please comment and tell if you think I have to much Model in it,
 and if, how to avoid it.
 This is probably not the best example, but here it comes...

 My Current Project deals with financing...Users has to LogOn to the System

 Model : User
 Controller: LogOnAction

 The Action makes use of an UserModelFacade. The UserModelFacade has a
 getUser(String uname, String pw) method...

 Pseudocode:

 User theUser= UserModelFacade.getInstance().getUser(name,pw);
 if(theUser==null)
 return(mappings.findMapping(failure)
 request.getSession().setAttrubute(myUser, theUser);
 return(mappings.findMapping(succes)

 This is the basic architecture and strategy we will be using in the
 development.
 When I said that this was a bad example, its because it only access the
 Model once...
 But some of our processes is more complicated than that...
 Sometimes we need to

 get the CurrentUser
 get other possible customers in the household
 get number of cars in the household
 get the new car
 make a finance calculation based on the above

 The following will result is 20-30 lines of code in the Action. LOC's I
 would like to be able to reuse...

 I haven't heard of Cactus or HttpUnit before this thread, and I
 will surely
 look into them (souds like great tools)

 nice thread btw ;-)

 regards Mikkel









 -Original Message-
 From: Niall Pemberton
 To: [EMAIL PROTECTED]
 Sent: 17-05-2001 17:11
 Subject: RE: Suggestion:Taking the Servlet out of Action and ActionForm

 I don't agree - Actions are part of the controller in MVC and need
 access to
 the servlet API to do thing such as retrieving and storing objects under
 the
 appropriate context. Sounds to me like 1) Your using the wrong tool and
 2)
 You've put your Model in the Actions.

 1) Cactus is a simple test framework for unit testing server-side java
 code.
 It uses JUnit and extends it. It's primary goal is to be able to unit
 test
 server side java methods which use Servlet objects such as
 HttpServletRequest, HttpServletResponse, HttpSession etc.
http

RE: Can an Action forward to another Action?

2001-05-17 Thread Niall Pemberton

I don't think its a new feature we do this, just specifiy
path=something.do in the forward for your action.

Niall

 -Original Message-
 From: Seth Ladd [mailto:[EMAIL PROTECTED]]
 Sent: 17 May 2001 22:07
 To: [EMAIL PROTECTED]
 Subject: Can an Action forward to another Action?


 Hello,

 I thought I saw this functionality added into Struts recently, and went to
 search the mailing list archives, but couldn't find it.  I'm not sure if I
 made this up or not. :)

 Can an Action forward right to another action?  If not, is there
 a good way
 to accomplish this?

 Thanks for your hints and tips,
 Seth






RE: Suggestion:Taking the Servlet out of Action and ActionForm

2001-05-23 Thread Niall Pemberton

Michael,

First thing to say is we are only just starting to devlop our first Struts
app after first prototyping vanilla Struts and then trying out various
customizations to create a more productive environment.

I try to answer your points in the message below.

 -Original Message-
 From: Michael Binette [mailto:[EMAIL PROTECTED]]
 Sent: 19 May 2001 20:18
 To: [EMAIL PROTECTED]
 Subject: RE: Suggestion:Taking the Servlet out of Action and ActionForm


 Niall (and anyone else who has done something similar),

 I have been looking into doing a similar thing as you have done,
 sub-classing Action and creating an abstract execute method or as you have
 done, an abstract processForm method.  The main reason was to
 eliminate the
 handling of HttpServletRequest, HttpServletResponse, current action, next
 action, etc.

 What types of things are you using the Transport object for?  Do you have
 one generic Transport object for your entire app?  You mention that your
 Action classes do not reference any Servlet methods.  How do you handle
 putting or getting things from request scope or session scope such as a
 logged in user object?

So far we have one Transport object for the entire app (although most of it
isn't yet written!). It contains mechanism for getting a Connections object,
storing error messages and altering the control flow (if success and
failure are not enough). Addtionally I have also provided getters/setters
for HttpServletRequest, HttpServletResponse  ActionMapping in case I meet a
scenario I have to access them - although I may hide these by adding
appropriate methods in the future e.g. getUser() could access the
HttpServletRequest to pass back a User object.

Currently the only thing we plan to store in session scope is a User object
and currently we have a separate logon action that doesn't inherit from our
standard action - we haven't finished developing it yet and I think I'm
going to do what I said in the previous paragraph and put a
setUser()/getUser methods in the Transport object. Besides the User, the
only other things we plan for are Connections and the ActionForm.
Connections are being handled by a generic Action and the Transport object.

I have two generic actions - one that requires a Database connection, one
that doesn't.

 When you have a form that takes user input, do you use the same
 Action class
 for setting up that form as well as for the submit action of that
 form?  We
 have run into a lot of cases where I have one action class to
 setup a form,
 such as a User Edit Profile screen.  Then, I use a second action class to
 save the User.  This gives me something like EditUser.do and SaveUser.do,
 both going to separate Action classes.

Yes.

 It seems like there are a lot of cases where you have two actions
 view and
 submit.  I was thinking about handling those two scenarios in my
 sub-classed Action class, calling processView or processSubmit
 automatically.  Have you done anything like that or does it sound
 reasonable?

Yes, but I think its more complex. If you just consider database update I
see (so far) the following scenarios:

  - Query a single row
  - Query a list of rows
  - Master Detail Query

  - Create a single row
  - Create children for a parent
  - Update a single row
  - Update a Master Detail
  - Delete a single row
  - Delete a Master Detail

On the query side you need to specify the query and criteria, map from the
DB to the view and forward to the correct JSP.
On the update side you need validation, mapping to the database and
forwarding to the correct query action when successful.

Probably there are more but I hope this will cater for most.

 --
 Thanks,
 Michael Binette


 -Original Message-
 From: Niall Pemberton [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, May 17, 2001 6:06 PM
 To: [EMAIL PROTECTED]
 Subject: RE: Suggestion:Taking the Servlet out of Action and ActionForm


 Mikkel

 OK I agree, its never so black  white and your user example looks fine to
 me.

 I'm wondering about your inner controller - sounds like some great
 integrated framework, in which case I agree its probably a level of
 abstraction I wouldn't want to go to. But what about lots of small
 controllers which tie together your logic outside the action.

 Anyway, I was probably misleading in saying thats what we've
 done. What I
 have actually done is this:

 We have sub-classed Action and created some abstract standard classes, our
 database action does something like this:

 1) Get a database connection
 2) Create a Transport object and store the ActionMapping,
 HttpServletRequest, HttpServletResponse  Connection.
 3) Set the default nextAction to success

 4) call a processForm(ActionForm, Transport) method (implemented as an
 abstract method) catching and handling exceptions.

 5) Check the Transport object for error messages. If there are
 errors create
 ActionErrors and save and if a nextAction returned by the
 Transport object
 use it otherwise set

RE: Suggestion:Taking the Servlet out of Action and ActionForm

2001-05-23 Thread Niall Pemberton

Good point, were still developing our first Struts system. The Transport
object could just store the DataSource, retrieved from the servlet context
and let the actions get and close connections from the Transport object, if
thats an issue for you.

With the number of users we are planning for and the processing most of our
actions do, I don't think this will be an issue - we certainly won't have
any 3 hour reports. If we do though they would probably deserve some
individual coding.

Niall

 -Original Message-
 From: Hicks, James [mailto:[EMAIL PROTECTED]]
 Sent: 19 May 2001 21:14
 To: '[EMAIL PROTECTED]'
 Subject: RE: Suggestion:Taking the Servlet out of Action and ActionForm


 I see one problem with Niall's Transport object.  The Transport has a
 reference to a Connection object.  This could cause severe scalability
 issues in the future.  Let's say for instance you are using a connection
 pool with an initial 5 connections and a max of 20.  If your
 Action.perform
 method does a lot of processing and you have a high traffic sight
 you could
 run out of connections very fast.

 The way I would recommend is using a Singleton to get a database
 Connection
 from the pool, this way you could release it when you don't need it.

 For example, your Action.perform(..) is responsible for getting
 info from a
 database, and drawing a graph to visually display the data.
 Let's say there
 are 5 million records returned from the query.  The records hold data to
 determine how many hours an employee has worked this month.  You want to
 create comparison reports for each employee, department and location.  For
 the purpose of the example, the reports would take over 3 hours.  With
 Niall's implementation, you would have to keep that database connection
 around for the entire time.  If you had direct access to the
 pool, you could
 release the connection after the query was finished.  This would allow
 someone else to use the connection.

 Now in real life, you probably wouldn't grab all 5 million
 records at once.
 Even if you did do over 100 queries on the database, if you were releasing
 the Connection when it wasn't used and getting another when needed, the
 overall application speed would be a lot faster than if you were
 to keep the
 connection around.

 Just My Opinion
 James Hicks

 -Original Message-
 From: Michael Binette [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, May 19, 2001 2:18 PM
 To: [EMAIL PROTECTED]
 Subject: RE: Suggestion:Taking the Servlet out of Action and ActionForm


 Niall (and anyone else who has done something similar),

 I have been looking into doing a similar thing as you have done,
 sub-classing Action and creating an abstract execute method or as you have
 done, an abstract processForm method.  The main reason was to
 eliminate the
 handling of HttpServletRequest, HttpServletResponse, current action, next
 action, etc.

 What types of things are you using the Transport object for?  Do you have
 one generic Transport object for your entire app?  You mention that your
 Action classes do not reference any Servlet methods.  How do you handle
 putting or getting things from request scope or session scope such as a
 logged in user object?

 When you have a form that takes user input, do you use the same
 Action class
 for setting up that form as well as for the submit action of that
 form?  We
 have run into a lot of cases where I have one action class to
 setup a form,
 such as a User Edit Profile screen.  Then, I use a second action class to
 save the User.  This gives me something like EditUser.do and SaveUser.do,
 both going to separate Action classes.

 It seems like there are a lot of cases where you have two actions
 view and
 submit.  I was thinking about handling those two scenarios in my
 sub-classed Action class, calling processView or processSubmit
 automatically.  Have you done anything like that or does it sound
 reasonable?

 --
 Thanks,
 Michael Binette


 -Original Message-
 From: Niall Pemberton [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, May 17, 2001 6:06 PM
 To: [EMAIL PROTECTED]
 Subject: RE: Suggestion:Taking the Servlet out of Action and ActionForm


 Mikkel

 OK I agree, its never so black  white and your user example looks fine to
 me.

 I'm wondering about your inner controller - sounds like some great
 integrated framework, in which case I agree its probably a level of
 abstraction I wouldn't want to go to. But what about lots of small
 controllers which tie together your logic outside the action.

 Anyway, I was probably misleading in saying thats what we've
 done. What I
 have actually done is this:

 We have sub-classed Action and created some abstract standard classes, our
 database action does something like this:

 1) Get a database connection
 2) Create a Transport object and store the ActionMapping,
 HttpServletRequest, HttpServletResponse  Connection.
 3) Set the default nextAction to success

 4) call a processForm(ActionForm

RE: New ActionMapping Class

2001-05-23 Thread Niall Pemberton

Michael

You need to use a set-property tag is Struts-config.xml

For example:

action path=/this name=myForm type =myPackage.myAction
  forward name=success path=/next.jsp/
  forward name=fail path=/prev.jsp/
  set-property property=processAction value=whatever/
/action

Niall

 -Original Message-
 From: Michael Binette [mailto:[EMAIL PROTECTED]]
 Sent: 22 May 2001 23:53
 To: Struts-User
 Subject: New ActionMapping Class


 I created a new GenericActionMapping class that extends ActionMapping.  I
 added one property, processAction with public getter and setter
 methods for
 it.

 I then set the mapping property in web.xml for the struts Action
 servlet to
 my new GenericActionMapping class.  The log when I run TomCat correctly
 shows it using my new GenericActionMapping class.

 But, if I add processAction=whatever to my struts-config.xml, within the
 action element, I get a SAXParseException, Attribute processAction is
 not declared for element action.

 How do I get this to work?

 --
 Thanks,
 Michael Binette






RE: template and I18N

2001-05-30 Thread Niall Pemberton


1. This was answered before. See following message:

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

2. IMHO avoid scriptlets.

Niall

 -Original Message-
 From: Gregor Rayman [mailto:[EMAIL PROTECTED]]
 Sent: 30 May 2001 13:12
 To: [EMAIL PROTECTED]
 Subject: template and I18N
 
 
 Hi all, 
 
 I've just started to use Struts and I have some questions:
 
 
 1. How can I use the I18N features in the template tags?
 
 In my template.jsp I've got the following tag:
 
 titletemplate:get name='title'//title
 
 In the page using this teplate the following:
 
 template:put name='title' content='Kalkulation' direct='true'/
 
 I'd like to replace the German text 'Kalkulation' with its
 key e.g. 'app.title.calculation' Is there a nice way to do this?
 
 
 
 2. How can I use use the I18N features in Struts directly
 in Java Scriplets? 
 
 Sometimes I need the translated texts in scriplets. What is 
 the best way to access them?
 
 Now I am using this aproach:
 
 %
 
   MessageResources resources =
 (MessageResources) pageContext.getAttribute(
 Action.MESSAGES_KEY, PageContext.APPLICATION_SCOPE);
 
   Locale locale = 
 (Locale) pageContext.getAttribute(
Action.LOCALE_KEY, PageContext.SESSION_SCOPE);
 
   if (null == locale) {
 locale = request.getLocale();
   }
 
   String myText = resources.getMessage(locale, app.the.text,key);
 
 %
 
 Thanks for an answer
 
 --
 gR
 
 
 
 
 
 



RE: Help me defend Struts taglibs!!!

2001-05-30 Thread Niall Pemberton

I submitted an if/else and switch/case set of tags a couple of weeks ago
under the Struts developer list.

   http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg01372.html

It uses three tags If, Then  Else (based on existing Struts CompareTagBase
logic)

  logic:if op=GreaterThan name=testbean property=doubleProperty
value=400
  logic:then
Property Greater Than Value
  /logic:then
  logic:else
Property Not Greater Than Value
  /logic:else
  /logic:if


Does this come under the really ugly category or will you consider it for
Struts?

Niall

 -Original Message-
 From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
 Sent: 31 May 2001 04:18
 To: '[EMAIL PROTECTED]'
 Subject: RE: Help me defend Struts taglibs!!!




 On Thu, 26 Apr 2001, Scott Cressler wrote:

  One thing this argument might come down to is why custom tags,
 especially
  for if...else stuff (which, BTW, IMHO is not handled real well by the
  struts tags...would be nicer to have more flexibility in the
 conditions you
  can check and to have the ability to do else, rather than
  logic:equal.../logic:equallogic:notEqual.../logic:notEqual...but
  that's another discussion :-).  In other words, if it is so easy to just
  slap some Java in their to do some conditional stuff, why use a
 clumsy tag.
 

 It turns out to be surprisingly difficult to come up with syntax for an
 else construct that is legal XML syntax and isn't really ugly.

 There's currently work going on in the JSP Standard Tag Library effort
 (JSR-052) to create tags that will eventually be known to all containters
 in the same way that tags like jsp:useBean are -- which will also deal
 with a lot of the performance related concerns.  It looks like there will
 be reasonable ways to do switch and if-else type processing with them.

 In the mean time, we can reconsider adding an else capability in Struts
 1.1, if someone can come up with a good syntax.

 Craig






RE: Why does struts-documentation have to be deployed?

2001-05-31 Thread Niall Pemberton



I 
believe It's calling init() twice because you have two Struts Applications in 
your webapps directory - the Struts Example and Admin - both initializing their 
own ActionServlet. I went to have a look at Admin because, I only glanced at it 
a while back - but couldn't find it so I must have deleted it - but thats what 
it looks like.

I 
don't really understand your point about the output -I don't get the 
method names output 
(i.e.##org.apache.struts.action.ActionServlet initApplication()) but 
it looks OK to me - init() calls the following methods which are in your output, 
except the first three:

initActions()
initInternal()
initDebug()
initApplication()
initMapping()
initUpload()
initDataSources()
initOther()
initServlet()
-Original Message-From: 
Jonathan [mailto:[EMAIL PROTECTED]]Sent: 31 May 2001 
22:57To: [EMAIL PROTECTED]Subject: Why does 
struts-documentation have to be deployed?

  I have the strus classes already in the classpath 
  with out the struts.jar I shouldnt need the struts-documentation.war 
  file
  I ask this because I cant figure out what struts 
  is doing when the ActionServlet is loaded. Below is my own printout 
  using weblogic. Notice how it calls init() twice ??!! Also notice 
  that the first method called is initApplication() ? Anyone know 
  why?
  
  
  
  log file: 
  C:\bea\wlserver6.0sp1\.\config\mydomain\logs\weblogic.logMay 31, 2001 
  5:45:44 PM EDT Info Logging Only log messages of 
  severity "Error" or worse will be displayed in this window. This can be 
  changed at Admin Console mydomain Servers myserver 
  Logging General Stdout severity 
  threshold##org.apache.struts.action.ActionServlet 
  initApplication()##org.apache.struts.action.ActionServlet 
  initMapping()##org.apache.struts.action.ActionServlet 
  initDigester()resolveEntity('-//Apache Software Foundation//DTD Struts 
  Configuration 1.0//EN', 
  'http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd')Not 
  registered, use system identifierresolveEntity('-//Apache Software 
  Foundation//DTD Struts Configuration 1.0//EN', 
  'http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd')Not 
  registered, use system identifierNew 
  org.apache.struts.action.ActionFormBeanSet 
  org.apache.struts.action.ActionFormBean propertiesCall 
  org.apache.struts.action.ActionServlet.addFormBean(ActionFormBean[logonForm])##org.apache.struts.action.ActionServlet 
  addFormBean()Pop org.apache.struts.action.ActionFormBeanNew 
  org.apache.struts.action.ActionMappingSet 
  org.apache.struts.action.ActionMapping propertiesNew 
  org.apache.struts.action.ActionForwardSet 
  org.apache.struts.action.ActionForward propertiesCall 
  org.apache.struts.action.ActionMapping.addForward(ActionForward[success])Pop 
  org.apache.struts.action.ActionForwardCall 
  org.apache.struts.action.ActionServlet.addMapping(ActionMapping[path=/logon, 
  type=com.vnu.common_beans.LogonAction])##org.apache.struts.action.ActionServlet 
  addMapping()Pop org.apache.struts.action.ActionMappingNew 
  org.apache.struts.action.ActionMappingSet 
  org.apache.struts.action.ActionMapping propertiesCall 
  org.apache.struts.action.ActionServlet.addMapping(ActionMapping[path=/admin/addFormBean, 
  type=org.apache.struts.actions.AddFormBeanAction])##org.apache.struts.action.ActionServlet 
  addMapping()Pop org.apache.struts.action.ActionMappingNew 
  org.apache.struts.action.ActionMappingSet 
  org.apache.struts.action.ActionMapping propertiesCall 
  org.apache.struts.action.ActionServlet.addMapping(ActionMapping[path=/admin/addForward, 
  type=org.apache.struts.actions.AddForwardAction])##org.apache.struts.action.ActionServlet 
  addMapping()Pop org.apache.struts.action.ActionMappingNew 
  org.apache.struts.action.ActionMappingSet 
  org.apache.struts.action.ActionMapping propertiesCall 
  org.apache.struts.action.ActionServlet.addMapping(ActionMapping[path=/admin/addMapping, 
  type=org.apache.struts.actions.AddMappingAction])##org.apache.struts.action.ActionServlet 
  addMapping()Pop org.apache.struts.action.ActionMappingNew 
  org.apache.struts.action.ActionMappingSet 
  org.apache.struts.action.ActionMapping propertiesCall 
  org.apache.struts.action.ActionServlet.addMapping(ActionMapping[path=/admin/reload, 
  type=org.apache.struts.actions.ReloadAction])##org.apache.struts.action.ActionServlet 
  addMapping()Pop org.apache.struts.action.ActionMappingNew 
  org.apache.struts.action.ActionMappingSet 
  org.apache.struts.action.ActionMapping propertiesCall 
  org.apache.struts.action.ActionServlet.addMapping(ActionMapping[path=/admin/removeFormBean, 
  type=org.apache.struts.actions.RemoveFormBeanAction])##org.apache.struts.action.ActionServlet 
  addMapping()Pop org.apache.struts.action.ActionMappingNew 
  org.apache.struts.action.ActionMappingSet 
  org.apache.struts.action.ActionMapping propertiesCall 
  org.apache.struts.action.ActionServlet.addMapping(ActionMapping[path=/admin/removeForward, 
  

RE: Multipage forms and validation

2001-06-01 Thread Niall Pemberton

David,

I see your on the 1.1 ToDo list as a volunteer for Standard Validations
and Client Side Validations - is it likely your validation framework is
going to be adopted for Struts - and if so how close is what you're offering
now to what Struts will have in 1.1?

I'm just wondering whether to plough on with what we've got or wait for what
might be coming in Struts.

Niall


 -Original Message-
 From: David Winterfeldt [mailto:[EMAIL PROTECTED]]
 Sent: 31 May 2001 23:32
 To: [EMAIL PROTECTED]
 Subject: Re: Multipage forms and validation


 I've done some work on a validation framework for
 Struts that is based on defining rules in an xml file.
  Right now it depends on associating a field with a
 page and setting a variable in the JSP page to set
 what page you are on.  I had a long discussion with
 someone on how to make it not depend on associating
 fields with a page so it was separated from the view,
 but I haven't had time to finish doing that.  The
 biggest problem is that if you have a session scope
 bean then you still absolutely have to know if there
 is a checkbox field on the page so you can reset it.
 The best idea to get away from page numbers was to
 have a custom ActionForward for each page and pass in
 the checkbox fields to be reset along with the action.

 Here is the url for what I currenty have working.
 There is a multi-page example in the validator.war and
 jdbc-validator.war in the webapps directory.

 http://home.earthlink.net/~dwinterfeldt

 David Winterfeldt

 --- Lukasz Kowalczyk [EMAIL PROTECTED] wrote:
  Hi.
 
  I'm trying to employ Struts to help me build
  multi-page forms.
  Those forms consist of all kinds of inputs,
  including multipart.
 
  The questions are as follows:
 
  1. How can I validate forms which I know will never
  set all of the
  required elements at a time since the required
  elements can span multiple
  pages? I could check which submit was clicked and
  then validate just a
  subset of form elements but I think it's not very
  Struts-oriented, and
  secondly this makes validate() method dependent on
  specific placement of
  form inputs (when I decide to move some field to
  another page I have to
  modify validate()).
 
  2. Can I use the same Action class to handle
  multipart and non-multipart
  request? Will performance hurt because of this?
 
  --
  £ukasz Kowalczyk
 


 __
 Do You Yahoo!?
 Get personalized email addresses from Yahoo! Mail - only $35
 a year!  http://personal.mail.yahoo.com/





RE: Multiple Forwards

2001-06-14 Thread Niall Pemberton

Hans,

Comments in the text below.

Niall

 -Original Message-
 From: Hans Bure [mailto:[EMAIL PROTECTED]]
 Sent: 14 June 2001 17:40
 To: [EMAIL PROTECTED]
 Subject: Multiple Forwards


 Hi all,

 I am a relatively new struts user, so if the question I'm asking has been
 answered before, I appologize ahead of time.

 What I'm trying to do, is create a framework integrated with struts that,
 among other things, allows users to set up multiple forwards dependent on
 the broswer type.  This could be Netscape, IE, WAP browser, or others.

 What I would like to do is something like the following in the
 struts-config.xml file:

 ...
 action name=test
   ...
   forward name=success browser=IE path=/ie/test.jsp/
   forward name=success browser=NS path=/ns/test.jsp/
   forward name=success browser=WAP path=/wap/test.jsp/
   ...
 /action
 ...

You can't have multiple forwards with the same name because they are stored
in a HashMap which uses the name as the key - so they will just overwrite
each other.



 The reasoning behind this, would be to create an additional
 attribute that
 could be used by my framework internals that determines the browser and
 calls the correct JSP for the user automatically.

 Something like:

   ...
   return myMapping.findForward(success);
   ...

 Which calls into a wrapper class that I create and determines the
 browser,
 then calling the appropriate JSP as defined in the config file.
 This makes
 it very simple for the user, as he only needs to define a series of
 'success's, and the Action code is simple as defined above.

 Now, obviously, adding an additional attribute to the forward
 above is not trivial.

Creating your own custom ActionForward is straight forward, but I don't
think it gives you much benefit.

Extend ActionForward and add the addtional properties you require.


/* CustomActionForward Class ** START **/
public Class CustomActionForward extends ActionForward {

  private String browser;

  public void setBrowser(String browser){
this.browser = browser;
  }

  public String getBrowser(){
return browser;
  }
}
/* CustomActionForward Class ** END **/

Then you need to tell Struts to use your CustomActionForward.

In the servlet entry in the web.xml file add the following init-param

  init-param
param-nameforward/param-name
param-valuemyPackage.CustomActionForward/param-name
  /init-param

Then in your struts-config.xml file use set-property to initialise your
addtional properties:

  action 
forward name=ie_success path=/ie/test.jsp
  set-property property=browser value=ie/
/forward
forward name=ns_success path=/ns/test.jsp
  set-property property=browser value=ns/
/forward
forward name=wap_success path=/wap/test.jsp
  set-property property=browser value=wap/
/forward
  /action

Obviously this is not very elegant and I you probably won't want to do this.

 So my question, is has anyone seen anything like this, and is
 there a way I haven't thought of to do this within the current struts
 framework?

 One thought I've had would be to do the following:

   forward name=ie_success path=/ie/test.jsp/
   forward name=ns_success path=/ns/test.jsp/
   forward name=wap_success path=/wap/test.jsp/

 This would work and not require many changes to the framework,
 but I would
 rather not do this, as it would make things very difficult for my
 users to create their own actions.

Personally this doesn't look any more difficult for you user than what you
are proposing below.


 Another possibility is the following:

   forward name=success path=test.jsp /
   browserforward name=success browser=ie path=/ie/test.jsp /
   browserforward name=success browser=ns path=/ns/test.jsp /
   browserforward name=success broswer=wap path=/wap/test.jsp /

 In this case, I would need to create another XML entry that kept
 all of the
 'success' forwards for each action in its own little HashTable, much like
 the normal forwards, except keyed by a combination of the name and the
 browser attributes.

 I honestly don't know how difficult this would be, but it seems like the
 best solution I've come up with so far.  One obvious drawback to
 this one is
 that the struts DTD would need to be altered to include the
 'browserforward'
 element.  I am not sure of the implications of this.

It would be a pain every time you took a new release of Struts - I wouldn't
do this.


 Any thoughts?

If you don't mind the constraints it imposes how about this for a solution:


For forwards which are browser specific create your entries in
struts-config.xml as follows:

   forward name=success path=/$browser$/test.jsp/

Then in your action you need to do something along the following lines:

  // Determine the Browser being used
  String browser = ?

  // Get the ActionForward
  ActionForward origForward = mapping.findForward(success);

  // replace /$browser$ in the path with the browser
  String 

RE: need some help.......

2001-06-14 Thread Niall Pemberton
Title: need some help...



M...the iterator doesn't appear to becreating 
your "jas" bean from the elements of your array - the question is 
why?

1) 
Have you defined the logic taglib at the top of your jsp?
 %@ taglib 
uri="/WEB-INF/struts-logic.tld" prefix="logic" %

2) 
Does the array returned by your getMbeanOper() method contain any 
nulls?

Also...I've just noticed...are you saying the getAttr() 
method returns a String array - meaning you have a grid situation? If so you 
need an iterate within an iterate. Haven't done that but there are messages in 
the archive which talk about it.

Niall


  -Original Message-From: Jiten Mohanty 
  [mailto:[EMAIL PROTECTED]]Sent: 15 June 2001 
  00:30To: [EMAIL PROTECTED]Subject: RE: need 
  some help...
  Niall
  Thanks for a quick response.I tried but got the 
  following error.
  
  javax.servlet.ServletException: Cannot find bean jas 
  in scope null
  Jiten
  
-----Original Message-From: Niall Pemberton 
[mailto:[EMAIL PROTECTED]]Sent: Wednesday, June 13, 
2001 5:18 PMTo: [EMAIL PROTECTED]Subject: 
RE: need some help...
"jas" is not in "session" scope - the iterator is 
creating it for each iteration (must be page scope?) - try it without the 
"scope":

bean:write name="jas" 
property="attr"/

Niall

-Original 
Message-From: Jiten Mohanty 
[mailto:[EMAIL PROTECTED]]Sent: 14 June 2001 
23:57To: [EMAIL PROTECTED]Subject: need 
some help...

  Hi folks 
  I am trying to iterate through a array of 
  objects.Here is the code.. 
  logic:iterate id="jas" name="countBeanForm" 
  property="mbeanOper" type="Ipseal.JbossOperationForm" 
  scope="session"  
   td align="center" 
   
 
   bean:write name="jas" 
  property="attr" scope="session"/  

   /td /logic:iterate 
  property "mbeanOper" : returns 
  array[objects] 
  Each Object has a property called 
  Attr[String](set  get).I want to display the each String in Attr[ 
  ].Whe I run the code, i get the following error..
  Error: 500 
  Location: 
  /ipseal_demo/bean_count.jsp Internal Servlet Error: javax.servlet.ServletException: Cannot find bean 
  jas in scope session  
  at 
  org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:459) 
   at 
  _0002fbean_0005fcount_0002ejspbean_0005fcount_jsp_44._jspService(_0002fbean_0005fcount_0002ejspbean_0005fcount_jsp_44.java:299)
   at 
  org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119) 
  and on.. 
  Can some body help on this. 
  
  Jiten Software Enginer 
  


RE: need some help.......

2001-06-14 Thread Niall Pemberton
Title: need some help...



"jas" 
is not in "session" scope - the iterator is creating it for each iteration (must 
be page scope?) - try it without the "scope":

bean:write name="jas" 
property="attr"/

Niall

-Original Message-From: 
Jiten Mohanty [mailto:[EMAIL PROTECTED]]Sent: 14 June 2001 
23:57To: [EMAIL PROTECTED]Subject: need some 
help...

  Hi folks 
  I am trying to iterate through a array of 
  objects.Here is the code.. 
  logic:iterate id="jas" name="countBeanForm" 
  property="mbeanOper" type="Ipseal.JbossOperationForm" 
  scope="session"  
   td align="center" 
   
 
   bean:write name="jas" 
  property="attr" scope="session"/  

   /td /logic:iterate 
  property "mbeanOper" : returns 
  array[objects] 
  Each Object has a property called Attr[String](set 
   get).I want to display the each String in Attr[ ].Whe I run the code, i 
  get the following error..
  Error: 500 Location: /ipseal_demo/bean_count.jsp 
  Internal Servlet Error: 
  javax.servlet.ServletException: Cannot 
  find bean jas in scope session 
   at 
  org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:459) 
   at 
  _0002fbean_0005fcount_0002ejspbean_0005fcount_jsp_44._jspService(_0002fbean_0005fcount_0002ejspbean_0005fcount_jsp_44.java:299)
   at 
  org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119) 
  and on.. 
  Can some body help on this. 
  Jiten Software Enginer 


RE: dynamic links in struts....

2001-06-18 Thread Niall Pemberton

Rather than storing the message key in a bean, can't you convert the key to
a message and store the message in the bean - then you cna just do a
bean:write.

If thats not appropriate - write your own tag to do it.

Niall

 -Original Message-
 From: Torsten Terp [mailto:[EMAIL PROTECTED]]
 Sent: 18 June 2001 11:19
 To: [EMAIL PROTECTED]
 Subject: RE: dynamic links in struts


 Hi,

 You did understand me correctly, infact the code below was exactly what i
 wanted to avoid :-) I just thought that there were some other way
 of doing
 it that i might have overlooked (it has happend before :-)

 ...anyways, thanks for the response!

 ^terp

  -Original Message-
  From: Jon.Ridgway [mailto:[EMAIL PROTECTED]]
  Sent: Monday, June 18, 2001 12:09 PM
  To: [EMAIL PROTECTED]
  Subject: RE: dynamic links in struts
 
 
  Hi,
 
  If I understand the question correctly, then you would have to put your
  dynamic message key into a scripting variable and use a
 scriplet. This isn't
  very nice, as the point of struts it to remove scriplets from our jsps,
  but...
 
  bean:define id='key' name='bean name' property='method name'/
  html:link page=/donor/Select.do paramName=row paramId=key
  paramProperty=donor
  bean:message key=%=key%/
  /html:link
 
  Jon.
 
  -Original Message-
  From: Torsten Terp [mailto:[EMAIL PROTECTED]]
  Sent: 18 June 2001 10:47
  To: [EMAIL PROTECTED]
  Subject: RE: dynamic links in struts
 
  ahh of course thats how to play it thank you!!!
 
  Another problem now occurs. If I need to use the bean:message in name
  of the link, i.e.,
 
  html:link page=/donor/Select.do paramName=row paramId=key
  paramProperty=donor
  bean:message key=whatever/
  /html:link
 
  and this key value should be dynamic too, how do I accomplish this??
 
  ^torsten
 
   -Original Message-
   From: Jon.Ridgway [mailto:[EMAIL PROTECTED]]
   Sent: Monday, June 18, 2001 11:06 AM
   To: [EMAIL PROTECTED]
   Subject: RE: dynamic links in struts
  
  
   Hi,
  
   Have a look at this snip provided by Ted Husted a couple of
 days ago. Note
   the use of the html:link tag.
  
   'Here's a reference snippet from a working page. The bean result has
   accessors for donor, sortName, email, and website, where
 donor is a unique
   key. Here the key is also used as the link text, but any
 other value from
   the bean could have been linked instead. This snippet
 generates links in
  the
   form:'
  
   /donor/Select.do?key=1234
  
   where result.rows.getDonor() returns 1234
  
   logic:iterate name=result property=rows id=row
   td align=left
 html:link page=/donor/Select.do paramName=row paramId=key
   paramProperty=donor
   bean:write name=row property=donor filter=true/
 /html:link
   /td
   td align=left
   bean:write name=row property=sortName filter=true/
   /td
   td align=left nowrap
 bean:write name=row property=telephone filter=true/
   /td
   td align=left nowrap
  font size=1a href=mailto:bean:write name=row
   property=email/bean:write name=row property=email
   filter=true//a/font
   /td
   td align=left
  font size=1a href=http://bean:write name=row
   property=website/ target=_blankbean:write name=row
   property=website filter=true//a/font
   /td
 /tr
   /logic:iterate
  
  
   Jon.
  
  
 
 





RE: alternate color support in iterate or subtag

2001-06-18 Thread Niall Pemberton
Title: alternate color support in iterate or subtag



I 
wrote a tag to do this - you can dowload it from Ted Husted's site 


 http://www.husted.com/about/struts/resources.htm#contributions

Niall

  -Original Message-From: Steve Salkin 
  [mailto:[EMAIL PROTECTED]]Sent: 18 June 2001 
  20:35To: '[EMAIL PROTECTED]'Subject: 
  alternate color support in iterate or subtag
  Hi- 
  I've been thinking about how best to handle alternate colors 
  for tables. One approach is simple but ugly: 
  table etc...  % 
  String alternatingColor = "firstColor"; %  
  logic:iterate name="resultSet" id="element"  tr  td 
  class="%=alternatingColor%"  bean:write 
  name="element" property="name"/  /td  /tr  % if (alternatingColor.equals("firstColor") 
  {  
  alternatingColor = "secondColor";  } else {  alternatingColor = 
  "secondColor;  
  }  %  /logic:iterate 
  Now it seems to me that this sort of progression, especially 
  mod 2 (alternation) must be pretty common. However, 
  it's not clear how best to handle it in a general way. 
  For example, some people might want to alternate or progressively move 
  through icons or something else. 
  So, rather then write and submit an extension to iterate that 
  supports something like logic:iterate 
  name="results" id="element" altClass="firstColor, secondColor" 
  I wonder instead if perhaps a subtag might be a better design. 
  Maybe like the following: 
  logic:iterate name="results" id="element" 
   logic:progression name="alternatingClass" 
  value="firstClass, secondClass, thirdClass"/ 
   In this case, code within the iterate would be able to 
  access the name "alternatingClass" which would evaluate to "firstClass" for i 
  % 3 == 0, "secondClass" for i % 3 == 1, and so forth. 
  Even this is sort of ugly though, maybe overdesigned. So if 
  anyone has some feedback about this, if we can sort out a clean design I'll be 
  happy to write it. 
  S- 


RE: Contribution: 1) IF, AND, OR, THEN, ELSE, ELSEIF tags 2) SWITCH, CASE, DEFAULT tags

2001-06-25 Thread Niall Pemberton

None taken.

I dont have a feel for the overhead - could you expand more.

Niall

 -Original Message-
 From: Wong Kok Wai [mailto:[EMAIL PROTECTED]]
 Sent: 25 June 2001 06:41
 To: [EMAIL PROTECTED]
 Subject: Re: Contribution: 1) IF, AND, OR, THEN, ELSE, ELSEIF tags 2)
 SWITCH, CASE, DEFAULT tags
 
 
 No offense, but I feel it is much better in
 performance to use Java scriptlets for these cases.
 The overhead of the tags is just too high to justify
 using them.
 
 
 
 __
 Do You Yahoo!?
 Get personalized email addresses from Yahoo! Mail
 http://personal.mail.yahoo.com/
 



RE: Generic handling of properties

2001-06-28 Thread Niall Pemberton

Wait for dynamic properties to arrive in Struts (might be a while) or do it
yourself.

There are messages in the archive discussing how people have done this.


Niall

 -Original Message-
 From: Gangadharappa, Kiran [mailto:[EMAIL PROTECTED]]
 Sent: 28 June 2001 00:52
 To: '[EMAIL PROTECTED]'
 Subject: Generic handling of properties


 hi,
 In my application contents of the Form are database driven. Is there
 anyway I could use Struts here?
 What I mean is I can not pre-define a custom Form class since getter and
 setters are not completely known initially.
 Any ideas?
 Regards
 Kiran





RE: Is struts really loading the resources?

2001-06-28 Thread Niall Pemberton

ActionServlet does not actually load the messages when it starts up. It just
uses whatever MessageResources factory it is configured for to create a
MessageResources - Struts have provided default concrete implementations of
these classes (PropertyMessageResources and PropertyMessageResourcesFactory)
and PropertyMessageResources does not actually load the messages until the
first getMessage() is issued.

You could create your own version of PropertyMessageResources with debugging
messages and configure Struts to use it (add a factory parameter to the
web.xml file pointing to your MessageResourcesFactory).

Also, your properties file should be in your test\WEB-INF\classes
directory (or sub-directory depending on the package name)


hope this helps

Niall


 -Original Message-
 From: Bob Byron [mailto:[EMAIL PROTECTED]]
 Sent: 27 June 2001 18:43
 To: [EMAIL PROTECTED]
 Subject: RE: Is struts really loading the resources?


 I have verified that, and it is:
 init-param
   param-nameapplication/param-name
   param-valueApplicationResources/param-value
 /init-param

 As I read it, that should go to the base directory
 where all classes are stored, and not traverse down to
 a specific package.  In other words, I have placed
 ApplicationResources.properties at the same level as
 the test directory that I mentioned earlier.
 Really, I would like to know if there is a place in
 the code that I can debug and print out the exact file
 name that the system is attempting to open.  Is there
 any way to have Win2000 display a log of files as it
 opens them?

 Bob


 --- Jason Rosenblum [EMAIL PROTECTED] wrote:
  make sure your web.xml file points to the
  ApplicationResources file that you're using.
  the entry looks like this:
init-param
param-nameapplication/param-name
 
 
 param-valuecom.cnet.app.intranet.app.psr.ApplicationResources/p
 aram-value
  /init-param
 
  ~Jason
 
  -Original Message-
  From: Bob Byron [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, June 27, 2001 10:24 AM
  To: [EMAIL PROTECTED]
  Subject: RE: Is struts really loading the resources?
 
 
  Yes, I did.  It has it in there.
 
  Bob
  --- Marcel  Andres [EMAIL PROTECTED] wrote:
   Bob,
  
   Did you make sure, that your jsp-page has the
   following entry, so it can use the
   bean:message-tag:
  
   %@ page language=java %
   %@ taglib uri=/WEB-INF/struts-bean.tld
   prefix=bean %
  
   Marcel
  
  
   -Original Message-
   From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
   Sent: Wednesday, June 27, 2001 5:17 PM
   To: [EMAIL PROTECTED]
   Subject: Is struts really loading the resources?
  
  
   I am new to struts and trying to get down some of
   the
   basics.  I am trying to use the command:
   bean:message key=header.title/
  
   When I do, I get the following exception:
   javax.servlet.jsp.JspException: Missing message
  for
   key header.title
  
   I have verified that my ApplicationResources file
   does
   contain:
   header.title=MY TEST
  
   Checking the log earlier, I find the following
   confirmation that the ApplicationResources
   properties
   were loaded, or were they:
   2001-06-27 09:20:31 - path=/test :action:
  Loading
   application resources from resource
   ApplicationResources
  
   The previous log entry mentions nothing about the
   resource file being found and loaded successfully.
 
   Am
   I missing something?  How do I know that they
   properties file was definately loaded?  How can I
   view
   the properties that are currently available?  I am
   just not sure what avenue of debugging to pursue
  at
   this point.
  
   Thank You,
   Bob Byron
  
  
  
   __
   Do You Yahoo!?
   Get personalized email addresses from Yahoo! Mail
   http://personal.mail.yahoo.com/
 
 
  __
  Do You Yahoo!?
  Get personalized email addresses from Yahoo! Mail
  http://personal.mail.yahoo.com/


 __
 Do You Yahoo!?
 Get personalized email addresses from Yahoo! Mail
 http://personal.mail.yahoo.com/





RE: concatenating resources files - in which class?

2001-06-28 Thread Niall Pemberton



I 
wouldn't put them anywhere in your code - I'd use some kind of deployment script 
to concatenate them and copy them to the appropriate 
directory.

Niall

  -Original Message-From: Jonathan 
  [mailto:[EMAIL PROTECTED]]Sent: 27 June 2001 16:57To: 
  [EMAIL PROTECTED]Subject: concatenating resources 
  files - in which class?
  Anyone have any suggestions as to where in the 
  code I should concatenate my multiple resource files? I actually would 
  like the resource files to be in the same directoryas the templates to 
  which they pertain (ie in with the jsp files). Assuming I put my jsp's 
  in WEB-INF/pages, I guess I would have to put the WEB-INF in the classpath as 
  well so that the properties files are visible to the 
  ActionServlet.


RE: Problem with resources when extending ActionServlet

2001-06-28 Thread Niall Pemberton

I have had no problems doing this - what does your sub-class look like?

If you are overriding the init() method, you need to call super.init() to
make sure the application resources are initialized.


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: 27 June 2001 13:21
 To:   [EMAIL PROTECTED]
 Subject:  Problem with resources when extending ActionServlet

The struts documentation states than extending ActionServlet is
unproblematic. However, as soon as I do this (regardless of the
subclass's functionality), I run into the following exception:

Internal Servlet Error:

javax.servlet.ServletException: Cannot find message resources under key
org.apache.struts.action.MESSAGE
at javax.servlet.ServletException.(ServletException.java:161)


 winmail.dat


RE: html:hidden ....

2001-06-28 Thread Niall Pemberton

Either write your own tag which generates a HTML hidden field from a message
resource key.

or

input type=hidden value=bean:message key='TEST'/ name=something 

Niall

 -Original Message-
 From: Michael Skariah [mailto:[EMAIL PROTECTED]]
 Sent: 27 June 2001 18:55
 To: [EMAIL PROTECTED]
 Subject: html:hidden 


 Hello all,
 In a html:hidden tag, how can we set a value that is present in the
 ApplicationResource file.
 Example:
 html:hidden property=id value=TEST/

 The value TEST should be taken from the resource file.

 Thanks,
 Michael.





RE: null pointer error

2001-06-28 Thread Niall Pemberton



I dont 
think html:text was designed to take a body - in the tld file for the 
html:hidden tag the body parameter is set to empty and they both extend 
the same parent class (BaseFieldTag).

BaseFieldTag is a child of BaseHandlerTag which extends 
BodyTagSupport and BaseFieldTag returns EVAL_BODY_TAG from its 
doStartTag() method - but I think this looks like a mistake because its not been 
written to process the body - I think it should really return 
SKIP_BODY.

My 
advice - dont put anything in the body.

Niall


  -Original Message-From: Nick Chalko 
  [mailto:[EMAIL PROTECTED]]Sent: 27 June 2001 19:53To: 
  [EMAIL PROTECTED]Subject: null pointer error 
  
  My jsp page 
  with the following tag
  html:text 
  property="username" size="20" maxlength="20" value="test" 
  inside/html:txt
  
  generates the 
  following java code (from VAJ 3.5.3)
   do 
  { 
  // 
  end 
  out.print(_jspx_html_data[4]); 
  // begin 
  [file="C:\\login.jsp";from=(16,0);to=(16,69)] 
  /*  html:text  
  */ 
  org.apache.struts.taglib.html.TextTag _jspx_th_html_text_1 = new 
  org.apache.struts.taglib.html.TextTag(); 
  _jspx_th_html_text_1.setPageContext(pageContext); 
  _jspx_th_html_text_1.setParent(_jspx_th_html_form_2); 
  JspRuntimeLibrary.introspecthelper(_jspx_th_html_text_1, 
  "maxlength","20",null,null, 
  false); 
  JspRuntimeLibrary.introspecthelper(_jspx_th_html_text_1, 
  "property","username",null,null, 
  false); 
  JspRuntimeLibrary.introspecthelper(_jspx_th_html_text_1, 
  "size","20",null,null, 
  false); 
  JspRuntimeLibrary.introspecthelper(_jspx_th_html_text_1, 
  "value","test",null,null, 
  false); 
  try 
  { 
  int _jspx_eval_html_text_1 = 
  _jspx_th_html_text_1.doStartTag(); 
  if (_jspx_eval_html_text_1 == 
  Tag.EVAL_BODY_INCLUDE) 
  throw new JspTagException("Since tag handler class 
  org.apache.struts.taglib.html.TextTag implements BodyTag, it can't return 
  Tag.EVAL_BODY_INCLUDE"); 
  if (_jspx_eval_html_text_1 != Tag.SKIP_BODY) 
  { 
  try 
  { 
  if (_jspx_eval_html_text_1 != Tag.EVAL_BODY_INCLUDE) {
  // the next nile sets out to 
  null 
  out = 
  pageContext.pushBody(); 
  _jspx_th_html_text_1.setBodyContent((BodyContent) 
  out); 
  } 
  _jspx_th_html_text_1.doInitBody(); 
  do 
  { 
  // 
  end 
  out.print(_jspx_html_data[5]); 
  // begin 
  [file="C:\\login.jsp";from=(25,0);to=(25,0)] 
  } while (_jspx_th_html_text_1.doAfterBody() == 
  BodyTag.EVAL_BODY_TAG); 
  } finally 
  { 
  if (_jspx_eval_html_text_1 != 
  Tag.EVAL_BODY_INCLUDE) 
  out = 
  pageContext.popBody(); 
  } 
  } 
  if (_jspx_th_html_text_1.doEndTag() == 
  Tag.SKIP_PAGE) 
  return; 
  } finally 
  { 
  _jspx_th_html_text_1.release(); 
  }
  
  
  The proplem 
  is pageContext.pushBody() returns null which then fails the next time 
  something is written to out.
  Any ideas. 
  
  
  R,
  Nick


RE: No Bean found under attribute key

2001-06-28 Thread Niall Pemberton

Your referring to a bean of name indexPage but the only thing in the code
you've shown named indexPage is a forward. This will not create a bean named
indexPage - try setting up an ActionForm and doing something along the
follwoing lines:

logic:equal name=myForm property=action scope=request
value=Display
html:text property=server size=16 maxlength=16/
  /logic:equal


.xml

  form-beans
  form-bean name=myForm type=com..MyForm/
  /form-beans


actionpath=/indexPage form=myForm
   type=com.niku.cm.IndexPageAction
  forward name=success path=/index.jsp/
  forward name=failure path=/nodata.jsp/
/action



-Original Message-
From: Rama Krishna [mailto:[EMAIL PROTECTED]]
Sent: 27 June 2001 20:07
To: [EMAIL PROTECTED]
Subject: No Bean found under attribute key


Hi all,

I am new to struts and i created a simple jsp and all along with proper
modifications to struts-config.xml and when i try to run my jsp i get the
above exception.


Can anyone tell me what could be the cause???


here is my code

.jsp

logic:equal name=indexPage property=action scope=request
value=Display
html:text property=server size=16 maxlength=16/
  /logic:equal


.xml

actionpath=/indexPage
   type=com.niku.cm.IndexPageAction
  forward name=success path=/index.jsp/
  forward name=failure path=/nodata.jsp/
/action


thanks,
rama




RE: Indexed Property Population to ActionForm

2001-06-28 Thread Niall Pemberton

Dave Hay has modified Struts tags to generate names appropriately.

You can download his tags from Ted Husted's site:

http://www.husted.com/about/struts/resources.htm#extensions


Niall

 -Original Message-
 From: Patrick van Leuveren [mailto:[EMAIL PROTECTED]]
 Sent: 28 June 2001 11:57
 To: '[EMAIL PROTECTED]'
 Subject: RE: Indexed Property Population to ActionForm


 Hi,

 One of realizing this is by naming the properties according to the naming
 rules for indexed properties.

 For example: if you define the property names as field[1], field[2], the
 HTML code that is renderd could look like this: INPUT TYPE=TEXT
 NAME=field[1] etc. When the form is submitted, the ActionForm is
 populated by calling setField ( int, String). In the body of this
 method you
 can use this index.

 Essentially, this does not have to map directly onto an array. One could
 also choose to use a Collection, or even distinct objects depending on the
 index. For your example, setting paramName[10], this will do.

 Success,
 Patrick

 -Original Message-
 From: [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 28, 2001 12:50 PM
 To: [EMAIL PROTECTED]
 Subject: Indexed Property Population to ActionForm


 Hi,
   Is it possible to populate indexed property to
 ActionForm. Of course, there should be delimiters in
 parameters for indexing. For example, paramName$10
 will populate to the bean with index 10 in the array
 paramName in ActionForm, ie. paramName[10]. Here $
 is the delimiter for indexing.

 Regards,
 Rice

 
 )_/9q$l+H=c!E73q$_%@,I  http://mail.kimo.com.tw
  :t 8t %M ,!!E:I b )_ /   http://www.kimo.com.tw





RE: beans and scope

2001-06-28 Thread Niall Pemberton

You can use request scope by storing the values in hidden fields using the
html:hidden tag - that way the values you are not showing get re-populated
back into your form when submitted.

Additionally to what John said about the default scope - I agree it is
session but Struts also supplies two ActionMapping sub-classes which can
be used to control the default scope - these are SessionActionMapping and
RequestActionMapping - all you have to do is add a mapping attribute to
the web.xml and you can have whichever default scope you prefer.

init-param
  param-namemapping/param-name

param-valueorg.apache.struts.action.RequestActionMapping/param-value
/init-param

Niall

 -Original Message-
 From: DHarty [mailto:[EMAIL PROTECTED]]
 Sent: 28 June 2001 21:22
 To: [EMAIL PROTECTED]
 Subject: RE: beans and scope


 Thank you John!

 Funny thing is, I had changed that in previous attempts.  When that didn't
 work, I must have forgot to put it back.

 Speaking of request scope,  Is there a way to do this (wizard steps) using
 the request scope, or do I just have to make the action classes
 responsible
 for reseting the form to start from scratch?

 Thanks again

 David

 -Original Message-
 From: John Schroeder [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 28, 2001 4:01 PM
 To: [EMAIL PROTECTED]
 Subject: RE: beans and scope


 Try removing the scope=request line below.  The formbean will default to
 session scope (I believe).  If you specify request scope, then
 the formbean
 will be accessible on the second page, but not the third...

 This worked for me after I banged my head against it as well!!

 !-- Create Project--
 actionpath=/projectcreate
type=edu.erau.dcm.teammate.action.ProjectCreateAction
name=ProjectForm
scope=request  -- remove this.
validate=false
input=/admin/project/project_create.jsp
   forward name=next
 path=/admin/project/project_add_leader.jsp/
   forward name=cancel path=/admin/project/project_admin.jsp/
 /action

 Hope this helps...

 --John





 -Original Message-
 From: DHarty [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 28, 2001 12:57 PM
 To: [EMAIL PROTECTED]
 Subject: beans and scope


 I'm trying to get a series of pages to populate a form ala a wizard
 interface.

 Each page enters a chunck of information which is then forwarded
 to the next
 page in the sequence.  The previous information is dispalyed along with an
 area to enter the next bit of info.

 The Problem is that after the information on the second page is
 entered, the
 third page doesn't receive the information from the fist page, only the
 second.  The informatoin never makes it into the second pages
 action class.
 I made the scope=session, but this still doesn't work.

 Please help, I've been banging my head against this for days.


 --first page---
 html:form action=/projectcreate scope=session
   pEnter Project Name: /b html:text name=ProjectForm
 property=name tabindex=1 / /p
   pnbsp;/p
   pbProject Description:/b/p
   blockquote html:textarea cols=50 name=ProjectForm
 property=description rows=5 tabindex=2 /
   /blockquote
   p align=right
   html:cancel tabindex=4/
   html:submit tabindex=3Next/html:submit
   /p
 /html:form
 --
 -second page---

  html:form action=/projectaddleader scope=session
   bAdd Project Leader:/b
   html:text name=ProjectForm property=newLeader /
   html:submit /

   Project Name:
   bean:write name=ProjectForm property = name /

   Project Description:
   bean:write name=ProjectForm property = description/
   /html:form
 --
 from stuts-config.xml---
 form-bean  name=ProjectForm
 type=edu.erau.dcm.teammate.form.ProjectForm/

   

 !-- Create Project--
 actionpath=/projectcreate
type=edu.erau.dcm.teammate.action.ProjectCreateAction
name=ProjectForm
scope=request
validate=false
input=/admin/project/project_create.jsp
   forward name=next
 path=/admin/project/project_add_leader.jsp/
   forward name=cancel path=/admin/project/project_admin.jsp/
 /action

   !-- Add Leader to Project --
 action   path=/projectaddleader
type=edu.erau.dcm.teammate.action.ProjectCreateAction
name=ProjectForm
scope=request
validate=false
input=/admin/project/project_add_leader.jsp
 forward name=nextpath=/admin/project/project_verify.jsp/
 forward name=finishedpath=/admin/project/project_admin.jsp/
 forward name=cancel path=/admin/project/project_admin.jsp/
 /action


RE: Generic handling of properties

2001-06-28 Thread Niall Pemberton

Kiran,

Sorry for the short answer previously. Below are some of the messages that
discussed this recently on the struts-dev list - the first message outlines
what we did, but a better way (modifying Bean/Property utils rather than
Struts tags) was pointed out by others in the thread.

http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg01485.html
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg01486.html
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg01487.html
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg01488.html
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg01489.html
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg01499.html
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg01500.html
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg01503.html

There are two archives (for the struts-user and struts-dev lists) these are:

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

hope this helps

Niall


 -Original Message-
 From: Gangadharappa, Kiran [mailto:[EMAIL PROTECTED]]
 Sent: 28 June 2001 17:13
 To: '[EMAIL PROTECTED]'
 Subject: RE: Generic handling of properties


 Hi Niall,
 I am kind of new to this mailing list. Any idea where I can find the
 archives?
 regards
 Kiran

 -Original Message-
 From: Niall Pemberton [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 28, 2001 4:08 AM
 To: [EMAIL PROTECTED]
 Subject: RE: Generic handling of properties


 Wait for dynamic properties to arrive in Struts (might be a
 while) or do it
 yourself.

 There are messages in the archive discussing how people have done this.


 Niall

  -Original Message-
  From: Gangadharappa, Kiran [mailto:[EMAIL PROTECTED]]
  Sent: 28 June 2001 00:52
  To: '[EMAIL PROTECTED]'
  Subject: Generic handling of properties
 
 
  hi,
  In my application contents of the Form are database driven. Is there
  anyway I could use Struts here?
  What I mean is I can not pre-define a custom Form class since
 getter and
  setters are not completely known initially.
  Any ideas?
  Regards
  Kiran
 





RE: multiple form fields

2001-06-28 Thread Niall Pemberton

Hey thats what this list is for - your headaches as valid as anyone elses,
keep sending them until you get a result.

Post all the bits of code in an email - your action form and/or bean(s) and
the jsp - plus when is throwing the Null pointer exception, - in the jsp,
before your page is displaying or afterwards when its trying to populate
back?

Off the top of my head you might be getting null pointer exceptions for a
couple of reasons:

1) If its happening before your page is displayed it might be because there
are nulls in your array/collection/vector - make sure its all
loaded/initialised containing no nulls before you forward to your jsp page.

2) If its happening after you submit your form back (using Daves tags) then
check the scope of your form - if its in session scope you should be OK, if
its in request scope you will need to do something clever to set it up
again. Struts effectively does a getX(index).setY(value) call

Anyway, if you post your code it'll be easier to see whats happening.

You are using Dave's modified tags from husted.com?

Niall

 -Original Message-
 From: Paul Beer [mailto:[EMAIL PROTECTED]]
 Sent: 29 June 2001 00:56
 To: [EMAIL PROTECTED]
 Subject: RE: multiple form fields


 Im still having problems getting this.  I just started using struts so
 please bear with me here.  But can someone please email me
 something similar
 to the logic-iterate example that cmoes with the example-taglibs demo ?  I
 am getting null pointer errors and I dont if it is my struts
 distribution or
 my own inability to grock this

 i will try not to toxify this list with any more of this 
 its just that
 if I cant model a formbean w/a grid of data struts is worthless to me,
 because my whole world is executing functions w/import tables.

 -paul
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 28, 2001 1:54 PM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: RE: multiple form fields




 Paul,

 a concrete example using modified tag:

 jsp:
   logic:iterate id=parameter name=ParametersForm
 property=parameterList
  .
 html:text name=parameter property=value indexed=true
 onchange=validate(this)/
  .
   /logic:iterate


 in my form bean (using a vector):

 public final class ParametersForm extends ActionForm
 {
/**
 * The parameter list
 */
private Vector parameterList = new Vector();


/**
 * Return the list of parameters
 */
public Vector getParameterList()
{
   return(this.parameterList);
}

/**
 * Set the list of parameters
 *
 * @param parameterList The new list
 */
public void setParameterList(Vector parameterList)
{
   this.parameterList = parameterList;
}

/**
 * Get a particular parameter from the parameterList, based on index
 *
 * @param   index The index of the parameter to retrieve
 */
public Parameter getParameter(int index)
{
   return (Parameter)parameterList.elementAt(index);

}
 }

 Hope that helps,

 Dave





 Paul Beer [EMAIL PROTECTED] on 06/28/2001
 02:32:55 PM

 Please respond to [EMAIL PROTECTED];
 Please
   respond to [EMAIL PROTECTED]

 To:   [EMAIL PROTECTED]
 cc:(bcc: David Hay/Lex/Lexmark)
 Subject:  RE: multiple form fields



 sorry i send the email accidently :

 doesnt :

   ...
 INPUT type=text name=qty value=1
 INPUT type=text name=qty value=2
 INPUT type=text name=qty value=3
 ...

 In your class:

 String[] qtys = request.getParameterValues(qty);


 defeat the purpose of having a form bean which seems like a kind
 of servlet
 abstraction of an html form ?  i dont really care.  I would just
 like to see
 some sample code that works.  I have searched through the quagmire that is
 the mail archives and every thread ends w/confusing comments.

 -p














RE: multiple form fields (I HATE CTRL-S )

2001-06-28 Thread Niall Pemberton
;
}

/**
 * Get a particular parameter from the parameterList, based on index
 *
 * @param   index The index of the parameter to retrieve
 */
public SapValidParameter getParameter(int index)
{
   return (SapValidParameter)parameterList.elementAt(index);

}


 -Original Message-
 From: Niall Pemberton [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 28, 2001 5:40 PM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: RE: multiple form fields


 Hey thats what this list is for - your headaches as valid as anyone elses,
 keep sending them until you get a result.

 Post all the bits of code in an email - your action form and/or
 bean(s) and
 the jsp - plus when is throwing the Null pointer exception, - in the jsp,
 before your page is displaying or afterwards when its trying to populate
 back?

 Off the top of my head you might be getting null pointer exceptions for a
 couple of reasons:

 1) If its happening before your page is displayed it might be
 because there
 are nulls in your array/collection/vector - make sure its all
 loaded/initialised containing no nulls before you forward to your
 jsp page.

 2) If its happening after you submit your form back (using Daves
 tags) then
 check the scope of your form - if its in session scope you should
 be OK, if
 its in request scope you will need to do something clever to set it up
 again. Struts effectively does a getX(index).setY(value) call

 Anyway, if you post your code it'll be easier to see whats happening.

 You are using Dave's modified tags from husted.com?

 Niall

  -Original Message-
  From: Paul Beer [mailto:[EMAIL PROTECTED]]
  Sent: 29 June 2001 00:56
  To: [EMAIL PROTECTED]
  Subject: RE: multiple form fields
 
 
  Im still having problems getting this.  I just started using struts so
  please bear with me here.  But can someone please email me
  something similar
  to the logic-iterate example that cmoes with the
 example-taglibs demo ?  I
  am getting null pointer errors and I dont if it is my struts
  distribution or
  my own inability to grock this
 
  i will try not to toxify this list with any more of this 
  its just that
  if I cant model a formbean w/a grid of data struts is worthless to me,
  because my whole world is executing functions w/import tables.
 
  -paul
  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, June 28, 2001 1:54 PM
  To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
  Subject: RE: multiple form fields
 
 
 
 
  Paul,
 
  a concrete example using modified tag:
 
  jsp:
logic:iterate id=parameter name=ParametersForm
  property=parameterList
   .
  html:text name=parameter property=value indexed=true
  onchange=validate(this)/
   .
/logic:iterate
 
 
  in my form bean (using a vector):
 
  public final class ParametersForm extends ActionForm
  {
 /**
  * The parameter list
  */
 private Vector parameterList = new Vector();
 
 
 /**
  * Return the list of parameters
  */
 public Vector getParameterList()
 {
return(this.parameterList);
 }
 
 /**
  * Set the list of parameters
  *
  * @param parameterList The new list
  */
 public void setParameterList(Vector parameterList)
 {
this.parameterList = parameterList;
 }
 
 /**
  * Get a particular parameter from the parameterList, based on index
  *
  * @param   index The index of the parameter to retrieve
  */
 public Parameter getParameter(int index)
 {
return (Parameter)parameterList.elementAt(index);
 
 }
  }
 
  Hope that helps,
 
  Dave
 
 
 
 
 
  Paul Beer [EMAIL PROTECTED] on 06/28/2001
  02:32:55 PM
 
  Please respond to [EMAIL PROTECTED];
  Please
respond to [EMAIL PROTECTED]
 
  To:   [EMAIL PROTECTED]
  cc:(bcc: David Hay/Lex/Lexmark)
  Subject:  RE: multiple form fields
 
 
 
  sorry i send the email accidently :
 
  doesnt :
 
...
  INPUT type=text name=qty value=1
  INPUT type=text name=qty value=2
  INPUT type=text name=qty value=3
  ...
 
  In your class:
 
  String[] qtys = request.getParameterValues(qty);
 
 
  defeat the purpose of having a form bean which seems like a kind
  of servlet
  abstraction of an html form ?  i dont really care.  I would just
  like to see
  some sample code that works.  I have searched through the
 quagmire that is
  the mail archives and every thread ends w/confusing comments.
 
  -p
 
 
 
 
 
 
 
 
 
 






RE: multiple form fields (I HATE CTRL-S )

2001-06-29 Thread Niall Pemberton
  SapValidParameter(orderitemsin_matlgroup,2000));
   parameterList.add(8,new
  SapValidParameter(orderitemsin_purchdate,2101));
   parameterList.add(9,new
  SapValidParameter(orderitemsin_currency,USD));
 }
 
 
 
 
 /**
  * Return the list of parameters
  */
 public Vector getParameterList()
 {
return(this.parameterList);
 }
 
public String getParameters()
 {
return(this.parameterList.toString());
 }
 
 /**
  * Set the list of parameters
  *
  * @param parameterList The new list
  */
 public void setParameterList(Vector parameterList)
 {
this.parameterList = parameterList;
 }
 
 /**
  * Get a particular parameter from the parameterList, based on index
  *
  * @param   index The index of the parameter to retrieve
  */
 public SapValidParameter getParameter(int index)
 {
return (SapValidParameter)parameterList.elementAt(index);
 
 }
 
 
 
  JSP:
 
logic:iterate id=parameter name=salesordercreateForm
  property=parameterList
  html:text name=parameter property=value
 indexed=true /
  /logic:iterate
 
 
 
  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
  Sent: Friday, June 29, 2001 10:06 AM
  To: [EMAIL PROTECTED]
  Subject: RE: multiple form fields (I HATE CTRL-S )
 
 
 
 
  Hi Paul.  Just got in (tied up this am).
 
  Agree with everything that Niall said.  Just wanted to confirm that you
  don't
  get an error when you actually BUILD Struts?  ie you get the error when
 you
  try
  and use the tag, and check that you have copied the struts-html.tld into
  your
  directory too?
 
  Let me know if you still have probs.
 
  Dave
 
  PS  Don't worry about asking the qu's - can all be quite confusing to
 start
  with!!
 
 
 
 
 
  Niall Pemberton [EMAIL PROTECTED]
 on
  06/28/2001 11:31:28 PM
 
  Please respond to [EMAIL PROTECTED]
 
  To:   [EMAIL PROTECTED],
[EMAIL PROTECTED]
  cc:(bcc: David Hay/Lex/Lexmark)
  Subject:  RE: multiple form fields (I HATE CTRL-S )
 
 
 
  Paul,
 
  1) The reason you're getting null pointer error for the attribute
 indexed
  is because Dave's tags initialise indexed to null - you have to set it
 to
  true or false in your jsp.
 
i.e.   html:text name=parameter property=value indexed=true/
 
  2) You seem to be setting up your data incorrectly in your jsp
 
  Typically an action of yours would run off, get some data and
 load it into
  your ActionForm which then forward to a jsp to display/edit.
 
  I'm not sure why you've got it in your jsp, but anyway what you've done
 isnt
  right - its creating your vector BUT isntead of putting it in your
  actionForm, your storing it as a page scope parameter under the name
  ParameterList.
 
  Instead of this:
 
   pageContext.setAttribute(ParameterList, vin,
 PageContext.PAGE_SCOPE);
 
  You should be doing something like:
 
   salesordercreateForm.setParameterList(vin);
 
  My suggestion too keep it simple, take that stuff out of your
 jsp and put
 it
  in the constructor of your ActionForm - then you know its
 always going to
 be
  present (dont have to worry about scope). Anyway as you have it at the
  moment youre always going to have any empty vector - so you wont see
  anything.
 
  i.e. something like
 
 public class SalesOrderCreateForm extends ActionForm {
 
 public SalesOrderCreateForm() {
   parameterList.add(0,new
  SapValidParameter(orderitemsin_itmnumber,00010));
   parameterList.add(0,new
  SapValidParameter(orderitemsin_material,TEST));
   parameterList.add(0,new
  SapValidParameter(orderitemsin_billdate,2101));
   parameterList.add(0,new
  SapValidParameter(orderitemsin_plant,2000));
   parameterList.add(0,new
  SapValidParameter(orderitemsin_targetqty,1000));
   parameterList.add(0,new
  SapValidParameter(orderitemsin_shorttext,TEST));
   parameterList.add(0,new
  SapValidParameter(orderitemsin_reqdate,2101));
   parameterList.add(0,new
  SapValidParameter(orderitemsin_matlgroup,2000));
   parameterList.add(0,new
  SapValidParameter(orderitemsin_purchdate,2101));
   parameterList.add(0,new
  SapValidParameter(orderitemsin_currency,USD));
 }
 
 etc. etc.
 
  3) Rama Krishna's (isnt he a Hindu God?) put up a reply for you about
 Vector
  or Vectors (havent done that flavour myself), so if you can get that
 working
  to display your data youre half way there.
 
  Niall
 
 
   -Original Message-
   From: Paul Beer [mailto:[EMAIL PROTECTED]]
   Sent: 29 June 2001 03:35
   To: Struts-User
   Subject: RE: multiple form fields (I HATE CTRL-S )
  
  
  
  
   OK here's my  bad code.  There are two problems Im try to
 resollve here
 :
  
   1) i cant iterate through a vector (how do i give the html tag an
   enumerator
   ???)
   2) even though i rebuilt struts w/tags from husted.com i get a
   null pointer
   error for the attribute

RE: beans and scope

2001-06-29 Thread Niall Pemberton

Yes it will hang around until the end of your session unless you remove it.
Theres an example of this in the strust example SaveRegistrationAction
class.

  session.removeAttribute(mapping.getAttribute());

Niall

 -Original Message-
 From: Gangadharappa, Kiran [mailto:[EMAIL PROTECTED]]
 Sent: 30 June 2001 00:53
 To: '[EMAIL PROTECTED]'
 Subject: RE: beans and scope


 if it is session scope, When will the bean get destroyed?
 Does it have to wait till the session is ended?
 What I mean is , isnt there any way to control the lifetime of
 this bean say
 programmatically?

 -Original Message-
 From: Niall Pemberton [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 28, 2001 2:35 PM
 To: [EMAIL PROTECTED]
 Subject: RE: beans and scope


 You can use request scope by storing the values in hidden
 fields using the
 html:hidden tag - that way the values you are not showing get
 re-populated
 back into your form when submitted.

 Additionally to what John said about the default scope - I agree it is
 session but Struts also supplies two ActionMapping sub-classes which can
 be used to control the default scope - these are
 SessionActionMapping and
 RequestActionMapping - all you have to do is add a mapping attribute to
 the web.xml and you can have whichever default scope you prefer.

 init-param
   param-namemapping/param-name

 param-valueorg.apache.struts.action.RequestActionMapping/param-value
 /init-param

 Niall

  -Original Message-
  From: DHarty [mailto:[EMAIL PROTECTED]]
  Sent: 28 June 2001 21:22
  To: [EMAIL PROTECTED]
  Subject: RE: beans and scope
 
 
  Thank you John!
 
  Funny thing is, I had changed that in previous attempts.  When
 that didn't
  work, I must have forgot to put it back.
 
  Speaking of request scope,  Is there a way to do this (wizard
 steps) using
  the request scope, or do I just have to make the action classes
  responsible
  for reseting the form to start from scratch?
 
  Thanks again
 
  David
 
  -Original Message-
  From: John Schroeder [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, June 28, 2001 4:01 PM
  To: [EMAIL PROTECTED]
  Subject: RE: beans and scope
 
 
  Try removing the scope=request line below.  The formbean will
 default to
  session scope (I believe).  If you specify request scope, then
  the formbean
  will be accessible on the second page, but not the third...
 
  This worked for me after I banged my head against it as well!!
 
  !-- Create Project--
  actionpath=/projectcreate
 type=edu.erau.dcm.teammate.action.ProjectCreateAction
 name=ProjectForm
 scope=request  -- remove this.
 validate=false
 input=/admin/project/project_create.jsp
forward name=next
  path=/admin/project/project_add_leader.jsp/
  forward name=cancel path=/admin/project/project_admin.jsp/
  /action
 
  Hope this helps...
 
  --John
 
 
 
 
 
  -Original Message-
  From: DHarty [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, June 28, 2001 12:57 PM
  To: [EMAIL PROTECTED]
  Subject: beans and scope
 
 
  I'm trying to get a series of pages to populate a form ala a wizard
  interface.
 
  Each page enters a chunck of information which is then forwarded
  to the next
  page in the sequence.  The previous information is dispalyed
 along with an
  area to enter the next bit of info.
 
  The Problem is that after the information on the second page is
  entered, the
  third page doesn't receive the information from the fist page, only the
  second.  The informatoin never makes it into the second pages
  action class.
  I made the scope=session, but this still doesn't work.
 
  Please help, I've been banging my head against this for days.
 
 
  --first page---
  html:form action=/projectcreate scope=session
pEnter Project Name: /b html:text name=ProjectForm
  property=name tabindex=1 / /p
pnbsp;/p
pbProject Description:/b/p
blockquote html:textarea cols=50 name=ProjectForm
  property=description rows=5 tabindex=2 /
/blockquote
p align=right
  html:cancel tabindex=4/
  html:submit tabindex=3Next/html:submit
/p
  /html:form
  --
  -second page---
 
   html:form action=/projectaddleader scope=session
  bAdd Project Leader:/b
  html:text name=ProjectForm property=newLeader /
  html:submit /
 
  Project Name:
  bean:write name=ProjectForm property = name /
 
  Project Description:
  bean:write name=ProjectForm property = description/
/html:form
  --
  from stuts-config.xml---
  form-bean  name=ProjectForm
  type=edu.erau.dcm.teammate.form.ProjectForm/
 
  
 
  !-- Create Project--
  actionpath

RE: Problems with iterate

2001-07-01 Thread Niall Pemberton

You need to do two things.

First, you need to generate appropriate names for your input fields. If you
use the current Struts tags then all the occurances of your two fields in
the example below will generate names of firstName and lastName. What
you want is to generate names in the format contactDataVector[x].firstName
and contactDataVector[x].lastName, where x is the index number of the
field. Dave Hay has posted a set of modified Struts tags which generate
these names on Ted Husted's site:
  http://www.husted.com/about/struts/resources.htm#extensions  - Indexed
Tags

Secondly you need to provide the appropriate getters/setters in your bean
and ActionForm. Obviously in your bean you need setFirstName() and
setLastName() methods - additionally you need the following getter in your
ActionForm:

  public ContactData getContactDataVector(int index) {

 return (ContactData)(contactDataVector.get(index));

  }

Hope this helps.


Niall



 -Original Message-
 From: Torsten Terp [mailto:[EMAIL PROTECTED]]
 Sent: 01 July 2001 19:01
 To: Struts user list
 Subject: Problems with iterate


 Hi,

 Sorry if this has been answered before, but i havent been able to
 find an answer!

 Im using iterate to display a vector containg valueobjects, i.e.,

 html:form action=showContacts
 logic:iterate id=contacts name=form property=contactDataVector
 html:hidden name=contacts property=contactId/
 tr
   td width=150
 html:text name=contacts property=firstName size=20/
   /td
   td width=150
 html:text name=contacts property=lastName size=20/
   /td
 /tr
 ...
 ...

 'form' is my struts form bean, 'contactDataVector' is a vector of
 'contactData'
 objects each containing (among others) the variables 'firstName'
 and 'lastName'.

 There is no problem in displaying the data, all goes well, but
 updating fields
 in the form is not working, when i want to save the changes in
 the struts action
 the vector is null! I can see that making a variable 'firstName'
 in the form, results
 in a call to its setter method, i.e., i can make it work when
 updating a single row,
 but i cant manage to get the update to work on the actual
 contactData objects in the
 vector. ?!?!

 Any advices out there??

 ^terp





RE: NotEqual Tag to compare multiple properties to a value

2001-07-04 Thread Niall Pemberton



You 
cant do that with the struts NotEqualTag  you can however with the 
IF/THEN/ELSE tags I wrote which Ted Husted has posted on his 
site:

http://www.husted.com/about/struts/resources.htm#extensions


logic:if  name="myForm" 
property="property1" op="NotEqual" value ="xxx"

logic:and name="myForm" property="property2" 
op="NotEqual" value ="xxx"/

logic:and name="myForm" property="property3" 
op="NotEqual" value ="xxx"/

 
logic:then
 
.
 
/logic:then



 
logic:else
 


 
/logic:else

/logic:if


Niall

-Original Message-From: 
Matt Raible [mailto:[EMAIL PROTECTED]]Sent: 03 July 2001 
17:35To: Struts UserSubject: NotEqual Tag to compare 
multiple properties to a value

  Is it possible to use the notEqual tag to compare 
  multiple properties to a single value?
  
  I'd like to write code similar to the 
  following
  
  logic:notEqual name="myForm" 
  properties="property1,property2" value=""
   do something if either 
  propertynot equal to ""
  /logic:notEqual
  
  Thanks,
  
  Matt
  
  P.S. I figured out my issue below - it was 
  an iPlanet bug. For value, I used value="%=""%" and it worked as 
  expected.
  
- Original Message - 
From: 
Matt 
Raible 
To: Struts User 
Sent: Monday, July 02, 2001 12:17 
PM
Subject: NotEqual or Present?

I am trying to check if the user entered a 
value for a search criteria in a results page. My ActionForm sets a 
propertyto "" if the user did not enter a value.

So in the following code, I want to only show 
it if the property does not equal "". But the following does not work, 
should it?

logic:notEqual name="myForm" 
property="searchParam" value=""
 show this if property 
"searchParam" is not equal to ""
/logic:notEqual

Thanks,

Matt


RE: html:link problem

2001-07-05 Thread Niall Pemberton

Rama,

Cant you use paramProperty?

html:link page=/target.cm paramId=value paramName=myCollectionElement
paramProperty=idclick here/html:link


Niall

-Original Message-
From: Rama Krishna [mailto:[EMAIL PROTECTED]]
Sent: 05 July 2001 20:10
To: [EMAIL PROTECTED]
Subject: html:link problem


is this correct

html:link page=/target.cm paramId=value paramName=bean:write
name='myCollectionElement' property='id'/click here/html:link

where myCollectionElement is a  collection
id is a property in the collection

and i want  http:///target.cm?value=2 (value of id)

i get null when i say

req.getParameter(value); in my action class??

any help???

thanks,
rama




RE: Where to do the init() for Actions?

2001-07-07 Thread Niall Pemberton

ActionServlet is a plain Servlet you can extend it and override the init()
method (make sure you call super.init(), so that the standard Struts init(0
stuff is done.

Niall

 -Original Message-
 From: Andreas Schildbach [mailto:[EMAIL PROTECTED]]
 Sent: 06 July 2001 18:02
 To: [EMAIL PROTECTED]
 Subject: Where to do the init() for Actions?


 Is there a similar thing to Servlet.init() in Actions?
 I want to access EJB's in Actions and have to setup the
 InitialContext, look
 up some Bean Remote Interfaces, etc. I don't want to do this every time my
 Action is called.
 If I were using a plain Servlet, I would put this stuff into init()...

 Thanks,

  - Andreas






RE: session form beans

2001-07-07 Thread Niall Pemberton

It doesn't - they will go when the session ends, or you have to explicitly
remove them.

Niall

 -Original Message-
 From: Jerome Jacobsen [mailto:[EMAIL PROTECTED]]
 Sent: 06 July 2001 20:09
 To: [EMAIL PROTECTED]
 Subject: session form beans


 Hi,

 In what cases does the Struts framework remove a Session Form
 bean from the
 Session?  Is this supposed to be done explicitly by the JSP or
 Action object
 writer?

 Thanks,

 -Jerome





RE: No Need To Localize

2001-07-07 Thread Niall Pemberton

The bean:message tag uses RequestUtils to find a message - this looks for
a locale stored in session scope under the key Action.LOCALE_KEY.

The usual way for the locale to be stored under this key is using the
html:html locale=true/ tag - if you dont use that, then struts will
always use the default locale.

But...if you are sure you never want an internationalized app then why don't
you do away with resource bundles altogether - just put all your messages
directly in the jsps?

Niall

 -Original Message-
 From: David White [mailto:[EMAIL PROTECTED]]
 Sent: 07 July 2001 17:37
 To: [EMAIL PROTECTED]
 Subject: No Need To Localize


 We are developing a web application using struts which will not need to
 be internationalized. Is there some way to tell struts NOT to look for
 and manipulate Locale's? In other words, there will always be one and
 only one resource bundle for tha application.

 Any pointer is appreciated.

 Thanks,

 David





RE: indexed properties

2001-07-07 Thread Niall Pemberton

Cameron,

Does the Action that is run when you submit the form have CourseList
associated with it?

If that sorts out the issue with not finding CourseList then I think
CourseList should look like this:

public final class CourseList extends ActionForm
{
  private ArrayList courseList = new ArrayList(6);

 public ArrayList getCourseList() {
  return(this.courseList);
 }

 public void setCourseList(ArrayList courseList) {
  this.courseList = courseList;
 }

 public CourseForm getCourseList(int index) {
  return (CourseForm)courseList.get(index);
 }

}

Then in your CourseForm bean you need setters for all the properties (i.e.
crstitle, crsdept, crshrs, crsnum).

Niall



-Original Message-
From: cahana [mailto:[EMAIL PROTECTED]]
Sent: 07 July 2001 21:40
To: [EMAIL PROTECTED]
Subject: indexed properties


Hi everyone-

I need some help on using the indexed properties for html:text option.
I've implemented Dave Hay's modification and can get the input boxes to show
up using the iterate tag.

logic:iterate id=course name=CourseList property=courseList
 tr
td%= courseNumber++ %/td
 tdhtml:text name=course property=crstitle size=25
maxlength=50 indexed=true//td
 tdhtml:text name=course property=crsdept size=6 maxlength=9
indexed=true//td
 tdhtml:text name=course property=crsnum size=5 maxlength=6
indexed=true//td
 tdhtml:text name=course property=crshrs size=5 maxlength=1
indexed=true//td
 /tr
 /logic:iterate

This is what my CourseList bean looks like:

public final class CourseList extends ActionForm
{
  private ArrayList courseList = new ArrayList(6);

 public ArrayList getCourseList() {
  return(this.courseList);
 }

 public void setCourseList(ArrayList courseList) {
  this.courseList = courseList;
 }

 public CourseForm getCourseForm(int index) {
  return (CourseForm)courseList.get(index);
 }

 public void setCourseForm(int index, CourseForm course) {
  this.courseList.add(index, course);
 }
}

The problem i have is that when i try to submit the information and try to
access CourseList.getCourseList(), it bombs and says CourseList cannot be
found. The scope is request. I tried putting it in the session and can
access it that way but it doesn't have the changes that were made on the
form. Anybody know what i'm doing wrong?

thanks,
cameron




RE: html:link problem

2001-07-07 Thread Niall Pemberton

No it just does a single parameter, for multiple params you need to use name
or name and property which points to a HashMap of parameters.

Niall

 -Original Message-
 From: Rama Krishna [mailto:[EMAIL PROTECTED]]
 Sent: 06 July 2001 01:40
 To: [EMAIL PROTECTED]
 Subject: Re: html:link problem


 Niall ,

 does it work for multiple param's??? or if not how do i tackle multiple
 params??

 thanks,
 rama.

 - Original Message -
 From: Niall Pemberton [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, July 05, 2001 4:39 PM
 Subject: RE: html:link problem


  Rama,
 
  Cant you use paramProperty?
 
  html:link page=/target.cm paramId=value
 paramName=myCollectionElement
  paramProperty=idclick here/html:link
 
 
  Niall
 
  -Original Message-
  From: Rama Krishna [mailto:[EMAIL PROTECTED]]
  Sent: 05 July 2001 20:10
  To: [EMAIL PROTECTED]
  Subject: html:link problem
 
 
  is this correct
 
  html:link page=/target.cm paramId=value paramName=bean:write
  name='myCollectionElement' property='id'/click here/html:link
 
  where myCollectionElement is a  collection
  id is a property in the collection
 
  and i want  http:///target.cm?value=2 (value of id)
 
  i get null when i say
 
  req.getParameter(value); in my action class??
 
  any help???
 
  thanks,
  rama
 
 





RE: iterate: offset

2001-07-07 Thread Niall Pemberton

Rama

I tried what you wrote below and the jsp ,didnt compile.

This did though, and worked :-)

  % int row=0; %
  logic:iterate ...
logic:iterate ... length=1 offset='%= +row %'

   % row++; %
/logic:iterate
  /logic:iterate

Also an alternative would be to use the indexId of the IterateTag which
means you dont have to declare and increment your row variable.

  logic:iterate indexId=row ...

logic:iterate ... length=1 offset='%= row.toString() %'
/logic:iterate

  /logic:iterate

Just out of interest - this looks like a solution to iterating through
multiple collections in parallel - is that what your using it for?

Niall


-Original Message-
From: Rama Krishna [mailto:[EMAIL PROTECTED]]
Sent: 06 July 2001 18:46
To: [EMAIL PROTECTED]
Subject: iterate: offset


hi all,

i am trying to iterate with length and offset when length=1 all the time
and offset gets incremented with each outer iteration.

i am trying to do something like this

% int row=0; %
logic:iterate ...

logic:iterate ... length=1 offset='%= \+row+\ %'


% row++; %
/logic:iterate
/logic:iterate

as offset takes an string i am enlosing the int in quotes. no errors, but
the value remains the same.

did any one try this.

any help is greatly appreciated.

thanks,
rama.




RE: html:text attribute question

2001-07-09 Thread Niall Pemberton

Jerzy,

Looking at the code of BaseHandlerTag (from which most of the html:...
tags inherit) everything looks in place to handle this attribute (it was
added on June 13th). I suggest you change your copy of the struts-html.tld
to include this attribute and see if it works.

Niall

 -Original Message-
 From: Jerzy Kalat [mailto:[EMAIL PROTECTED]]
 Sent: 09 July 2001 12:33
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: Re: html:text attribute question


 Hi,

 If this is true, what do I do wrong, as this line of code

 TD
 SPAN class=f-data
 html:text property=geoEntityType.id size=4 maxlength=4
 title=Enter Type ID/
 /SPAN
 /TD

 produces this error:
 org.apache.jasper.compiler.CompileException:
 C:\tomcat-3.2.1\webapps\myapps\geoEntityType.jsp(186,27) Attribute title
 invalid according to the specified TLD

 Jerzy Kalat


 - Original Message -
 From: Pham Thanh Quan [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, July 05, 2001 9:44 PM
 Subject: Re: html:text attribute question


  You can implement it perfectly by the way that you present
  Quan
  PS. I use IE 5.0
 
  - Original Message -
  From: Jerzy Kalat [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Thursday, July 05, 2001 9:25 PM
  Subject: html:text attribute question
 
 
   Hi,
  
   IE Browser has very nice, user friendly feature, with form input text
  field.
   If such field has attribute title='text to be displayed' and user put
 his
   mouse over this field, this text is displayed to the user.
  
   I do not see 'title' atribute in html:text input button.
 Any idea how
  can
   we implement it?
  
   Jerzy Kalat
  
  
  
 





RE: Using tokens for sensitive form submissions

2001-07-09 Thread Niall Pemberton

Action has a number of methods for transaction tokens [saveToken(),
isTokenValid(), resetToken()] and the example shows use of them (look at
EditRegistration.java and SaveRegistration.java).

You can also specify a transaction=true attribute on the LinkTag so that
the transaction token is retrieved from the session and stored in the
request.

Other than that, you need to do it yourself.

Niall



 -Original Message-
 From: Bud Gibson [mailto:[EMAIL PROTECTED]]
 Sent: 09 July 2001 14:36
 To: [EMAIL PROTECTED]
 Subject: Using tokens for sensitive form submissions


 Hi:

 We want to use tokens for sensitive form submissions.  It looks like
 struts can do this.  However, the feature is hidden (at least to me) and
 undocumented.

 Following David Geary's Advanced JSP book (and somewhat Core J2EE
 Patterns by Alur et al.), I would like to set a token when I send out
 certain forms and test the token when those forms are resubmitted.  At
 this stage, I have actually written my own action and borrowed Geary's
 tag library code.  If someone submits a form with a stale or no token,
 my action reroutes them to a default action that figures out what to do
 with them.  If someone submits a form without a stale token, then the
 form is forwarded to another action that does validation and processing.

 Have I reinvented the wheel?  Is there a built-in capacity to do this
 within struts?  I want to write as little infrastructure code as possible.

 Thanks,
 Bud Gibson
 University of Michigan Business School





RE: iterate problem

2001-07-09 Thread Niall Pemberton

Have you defined the struts-logic.tld at the top of your jsp?

 -Original Message-
 From: Moons Manuel [mailto:[EMAIL PROTECTED]]
 Sent: 09 July 2001 13:43
 To: '[EMAIL PROTECTED]'
 Subject: iterate problem
 
 
 Hello everyone.
 
 I am currently having some problems with iterating over an array 
 of objects.
 
 In my action class I have put an array into the session object
 (request.getSession().setAttribute(orderedsandwiches,...);)
 
 I would like to loop over these objects in my jsp page.
 
 I am trying to do this like this:
 
 bean:define id=orderedsandwiches name=orderedsandwiches/
 
 table
 logic:iterate id=element name=orderedsandwiches
   tr
   td
   bean:write name=element property=name/
   /td
   /tr
 /logic:iterate
 /table
 
 
 But when I try to do this, I get an exception like the following:
 
 9-jul-01 14:21:07 GMT+02:00 Error HTTP
 [WebAppServletContext(5325170,sandwich)] Root cause of ServletException
 javax.servlet.jsp.JspException: Cannot find bean element in scope null
 at 
 org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:493)
 at
 org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:179)
 at jsp_servlet._viewall._jspService(_viewall.java:183)
 at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
 at
 weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStu
 bImpl.java
 :213)
 at
 weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDis
 patcherImp
 l.java:157)
 at
 org.apache.struts.action.ActionServlet.processActionForward(Action
 Servlet.ja
 va:1683)
 at
 org.apache.struts.action.ActionServlet.process(ActionServlet.java:1520)
 at
 org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:485)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
 at
 weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStu
 bImpl.java
 :213)
 at
 weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAp
 pServletCo
 ntext.java:12
 65)
 at
 weblogic.servlet.internal.ServletRequestImpl.execute(ServletReques
 tImpl.java
 :1622)
 at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
 at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
 
 
 
 When I loop through the array using jsp snippets, I can print out the
 contents of the array like this:
 
 
 table
 %
   OrderBean []ob = (OrderBean[])orderedsandwiches;
   for(int i=0;iob.length;i++) {
   %trtd%
   out.println(ob[i]);
   %tdtr%
   }
 %
 /table
 
 The strange thing about all of this is that in another jsp page, 
 I do almost
 the same thing and there this works without any problems.
 
 Does anyone have an idea to solve this problem
 



RE: Help with if then else tags

2001-07-12 Thread Niall Pemberton

You need to compile the tags and drop the class files into the appropriate
directory, install the tld file (or modify the strust-logic.tld).

Examples of using them are:

   http://husted.com/about/struts/logic-niallp.htm

Niall

 -Original Message-
 From: Dudley Butt@i-Commerce [mailto:[EMAIL PROTECTED]]
 Sent: 12 July 2001 13:11
 To: [EMAIL PROTECTED]
 Subject: Help with if then else tags


 Hi all,

 I just downloaded and tried to get the new extened Logic Taglib to work,
 does anyone know of how to use them, and more importantly HOW TO
 GET THEM TO
 WORK!


 **
 This email and any files transmitted with it are confidential and
 intended solely for the use of the individual or entity to whom they
 are addressed. If you have received this email in error please notify
 the system manager.

 This footnote also confirms that this email message has been swept by
 MIMEsweeper for the presence of computer viruses.

 www.mimesweeper.com
 **





RE: Long Story short

2001-07-12 Thread Niall Pemberton

What scope is your ActionForm in - request or session?

If its in session scope - no problem, if its request you need to make sure
your array is set up with all the beans it requires (empty ones will do).

Niall

 -Original Message-
 From: Frank Ling [mailto:[EMAIL PROTECTED]]
 Sent: 12 July 2001 00:04
 To: [EMAIL PROTECTED]
 Subject: Re: Long Story short


 Hi, Dave:

 Thanks for the reply, I did have form-bean define at my struts-config.xml,
 in the matter fact, I did get all other form-bean field setting back form
 HTML form except this attributes array.

 The reason I used the changed indexed tag of html:text for iterate tag, is
 recently all the thread on this mailing list regarding for
 Iterate property
 updating all recommend using your changed tag to have text name set like
 array items (I.e. attributes[n].value), then sounds like will help to set
 this value back to original array on my form bean. I just don't get it how
 this will be happen.

 I do have all my html:text name set like that way (i.e.
 attributes[n].value), but still get nothing setting back to my array, I do
 have all the setter method for element of the array.

 Do you know how your indexed tag will help on this matters?

 Thanks again.

 Frank Ling


 - Original Message -
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, July 11, 2001 2:22 PM
 Subject: Re: Long Story short


 
 
  Frank,
 
  Do you have your struts-config set up correctly?  You might check that a
 new
  form is not being created...
 
  Dave
 
  PS  Do you need the indexed naming?  If you don't, you don't need to use
 the
  changed tags...
 
 
 
 
  Frank Ling [EMAIL PROTECTED] on
 07/11/2001
  01:19:29 PM
 
  Please respond to [EMAIL PROTECTED]
 
  To:   [EMAIL PROTECTED]
  cc:(bcc: David Hay/Lex/Lexmark)
  Subject:  Long Story short
 
 
 
  Hi, There:
 
  I send a long version story regarding for the Iteration tag with indexed
 tag
  for property update. Not too much people response. Here is the short
 version
  for that story.
 
  I get Dave hay's indexed tag work good with the Iterate tag for showing
 the
  text field of my array attributes. I get attributes[n].value shows
 properly
  on my JSP page. but nothing setting back to attributes array of my form
  bean. the whole array is null after I received it on the next action
 class.
 
  Can anybody explain to me, why I get all these attributes[n].value shows
 as
  the name of HTML text name, then that will automatically
 populate back to
 my
  array? It's not working that way for me right now. what I did wrong. Any
  suggestion will be highly appreciated.
 
  Thanks
 
  Best Regards
 
  Frank Ling
 
 
 
 
 
 
 
 





RE: html:select/options

2001-07-12 Thread Niall Pemberton

Either set a value=xyz or a name/property pointing to a bean with the
initial value on the html:select tag.

Niall

 -Original Message-
 From: DHarty [mailto:[EMAIL PROTECTED]]
 Sent: 12 July 2001 15:35
 To: Struts User
 Subject: html:select/options


 Is there a way to dictate which option in a collection is set as
 selected when the page is rendered?
 ex
   html:options collection=Roles property=name /

 For example, I have a collection of projects that are rendered by the
 html:options tag.  I also have  some java script which updates a project
 description box when the selection is changed.  The problem is
 when the page
 is first rendered, the two don't always match up.  I initialize the
 description box to the first item in the collection, but the
 select doesn't
 always choose the first item.

 Thanks
 D





RE: Indexed tags - Dave Hays code

2001-07-30 Thread Niall Pemberton

I believe Dave Hays tags were included in the nightly builds in the last
week or so. So if you download that you should be OK.

Niall

 -Original Message-
 From: Nathan Coast [mailto:[EMAIL PROTECTED]]
 Sent: 30 July 2001 15:38
 To: Struts-User (E-mail)
 Subject: Indexed tags - Dave Hays code


 Hi,

 I'm trying to use the Indexed tags from Dave Hays:
 http://husted.com/about/struts/indexed-tags.htm

 anyone got a replacement struts.jar with the relevant code changes in?

 It's not that I'm lazy, I'm just having trouble getting the code
 built using
 ant 1.3

 java.lang.NoClassDefFoundError: javax/xml/transform/Source
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:120)
 at
 org.apache.tools.ant.taskdefs.XSLTProcess.setProcessor(XSLTProcess.ja
 va:229)
 at
 org.apache.tools.ant.taskdefs.XSLTProcess.execute(XSLTProcess.java:13
 7)
 at org.apache.tools.ant.Target.execute(Target.java:153)
 at org.apache.tools.ant.Project.runTarget(Project.java:898)
 at org.apache.tools.ant.Project.executeTarget(Project.java:536)
 at org.apache.tools.ant.Project.executeTargets(Project.java:510)
 at org.apache.tools.ant.Main.runBuild(Main.java:421)
 at org.apache.tools.ant.Main.main(Main.java:149)




 **
 This email and any files transmitted with it are confidential and
 intended solely for the use of the individual or entity to whom they
 are addressed. If you have received this email in error please notify
 the system manager.

 This footnote also confirms that this email message has been swept by
 MIMEsweeper for the presence of computer viruses.

 www.mimesweeper.com
 **





RE: some comparision between JSP/struts and velocity

2001-07-30 Thread Niall Pemberton

The third wayif the Struts tags dont do what you want then write your
own. Then you dont have to use scriptlets, you have a re-useable bit of
functionality, the web designers are happy and you dont have to use
Velocity.

Niall

 -Original Message-
 From: Tim Colson [mailto:[EMAIL PROTECTED]]
 Sent: 31 July 2001 00:55
 To: [EMAIL PROTECTED]
 Subject: RE: some comparision between JSP/struts and velocity


 Scriptlets OK for view only?

 Another developer in my group and I discussed this at length last week. I
 believe scriptlets in the view to be bad practice...or at least
 a slippery
 slope towards badness. grin

 I suggest that there are two levels of separation we are trying
 to achieve.

 1) Separation of Business Logic from Display logic
 2) Separation of Developer tasks from Designer tasks

 I'd bet we all mostly agree and accept the first type as good MVC
 practice,
 and Struts does this quite well. The second type, though, would
 be violated
 by putting scriptlets into the View, something JSP does not prevent.

 While not violating MVC - the resulting View needs a Designer who knows
 Java.

 The counter-argument usually goes like so, Well, there's
 JavaScript on the
 page, and the Designer understands that... and the JSP Scriptlet is Java
 which kinda looks like JavaScript...ergo, the Designer should be okay with
 that too.

 Slippery Slope. The Designer probably copied the JS from a Script archive,
 or used a WYSIWIG tool like DreamWeaver to build the script... ;-)

 BTW - the scriptlet was written because the existing taglibs
 either couldn't
 do what we needed, or at least it was taking too much time to
 figure out if
 they could. If we had Velocity as an option, I could have written the
 necessary bits without the complication of Java in short order.
 I'm not sure
 the Designer would understand it, but I'm betting I'd have an easier time
 explaining the minimal Velocity directives versus the Java  grin

 Cheers,
 Tim Colson












RE: some comparision between JSP/struts and velocity

2001-07-30 Thread Niall Pemberton

Timothy,

Sorry, I couldnt disagree with you more.

Custom tags are exactly the place to put html - they are part of the view,
if you look at struts html tags thats what they do. There isnt currently
javascript in any struts tags (just attributes for most javascript events)
and there are probably browser issues that could complicate this, but its on
the Struts to do list to handle client side validation which almost
certainly means javascript and tags.

Niall

 -Original Message-
 From: Tim Colson [mailto:[EMAIL PROTECTED]]
 Sent: 31 July 2001 02:20
 To: [EMAIL PROTECTED]
 Subject: RE: some comparision between JSP/struts and velocity


  Niall Pemberton suggested
  ...if the Struts tags dont do what you want then write your
  own. Then you dont have to use scriptlets, you have a re-useable bit of
  functionality, the web designers are happy and you dont have to use
  Velocity.
 While a custom tag is an option; this bit of functionality would have
 required embedding  javascript code and html inside the custom tag lib. To
 me, putting view specific code like inside a tag library is also
 a slippery
 slope in the quest to keep thing separated.

 Cheers,
 Timothy





RE: Dealing with many JSP files with one Action

2002-06-12 Thread Niall Pemberton

I'm sure you can do something more intelligent than duplicating the whole
set of jsps for each different language. If the problem is that you need
different images for different languages then write your own tag to generate
the path for the image based on the localle.

IMHO I wouldn't resolve your issue this way, BUT...

you could sub-class Action and do something like the following:


public class LocalAction extends Action {

public ActionForward perform(ActionMapping mapping,
   ActionForm form,
   HttpServletRequest request,
   HttpServletResponse response) throws
IOException, ServletException  {

ActionForward forward = super.perform(mapping, form, request,
response);

String prefix = getLocale(request).getISO3Language();

if (prefix == null || prefix.length() ==0)
return forward;
else
return new ActionForward(prefix + '/' + forward.getPath());

}

}


Niall

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: 11 June 2002 12:54
 To: [EMAIL PROTECTED]
 Subject: RE: Dealing with many JSP files with one Action



 -- Envoyée par Olivier Schmeltzer/QVI/GRAF/FR le
 11/06/2002 13:43 ---


 Olivier Schmeltzer
 11/06/2002 09:01

 Pour : [EMAIL PROTECTED]
 cc :   [EMAIL PROTECTED] (ccc : Olivier
Schmeltzer/QVI/GRAF/FR)

 Objet : RE: Dealing with many JSP files with one Action

 Thanks for your answer. Unfortunately, I am not able to modify the
 directory structure and all the way this is going to work. We
 don't want to
 just have the text in multiple languages : images also have to be
 different
 ; everything can be modified by marketing people (from different
 countries)
 who don't develop the Internet site, through a Content Management System
 tool.
 The example I chose was meant to be simple, but it is actually much more
 complicated than this.
 So, I repeat my question : is there a way for a single Action to serve
 multiple JSP files, by taking advantage of a relative path ?
 If the current JSP page I am viewing now is /FR/home/home.jsp, can I put
 inside this page an action (let's say a ForwardAction) that will show me
 the /FR/logon/logon.jsp ? And I want to use the same flow
 description to go
 frome the /EN/home/home.jsp file to the /EN/logon/logon.jsp ?
 The following does not work but it gives the idea :

   action path=/homeLogonRel
 type=org.apache.struts.actions.ForwardAction
 parameter=../logon/logon.jsp
   /action

 Thank you for your time.

 Olivier Schmeltzer






 ---

 Les données et renseignements contenus dans ce message sont
 personnels, confidentiels et secrets. Ce message est adressé à
 l'individu ou l'entité dont les coordonnées figurent ci-dessus.
 Si vous n'êtes pas le bon destinataire, nous vous demandons de ne
 pas lire, copier, utiliser ou divulguer cette communication. Nous
 vous prions de notifier cette erreur à l'expéditeur et d'effacer
 immediatement cette communication de votre système.

 The information contained in this message is privileged,
 confidential, and protected from disclosure. This message is
 intended for the individual or entity adressed herein. If you are
 not the intended recipient, please do not read, copy, use or
 disclose this communication to others ;also please notify the
 sender by replying to this message, and then delete it from your system.


 --
 To unsubscribe, e-mail:
 mailto:struts-user- [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: Two questions

2002-06-12 Thread Niall Pemberton

I didn't understand the first question.

You can forward in a jsp using the struts forward tag:

  logic:forward name=sessionexpired/

Niall

 -Original Message-
 From: Yaman Kumar [mailto:[EMAIL PROTECTED]]
 Sent: 12 March 2002 23:04
 To: Struts Users Mailing List; [EMAIL PROTECTED]
 Subject: Two questions


 Hi,
 I have 2 questions
 1.Regarding calling a method that is in ActionForm from a jsp.
   Ex: I have an image and i would like to enable reset method to
 image that
 is in MyActionForm class.

 2. I have a forward that is in global-forwards and i would like
 to get that
 in a
 jsp page,
 Ex.
 global-forwards
   forward name=sessionexpired path=/InvalidSession.jsp/
 /global-forwards

 Can I call  sessionexpired forward name in a jsp file rather
 than writing
 InvalidSession.jsp?, So that if i change path of this forward in
 future that
 should
 affect in whole web application.

 TIA
 rayaku


 --
 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: Struts Design/construction process. question

2002-06-13 Thread Niall Pemberton

I saw this thread and thought...great, flame war..., but you guys are too
nice.

IMHO I suggest you learn from the guru before trying this next time:

  http://www.IamMarkGalbreath.org/FlameWar/HowTo/AnnoyTheHellOutOfEveryone

Niall

P.S. 'old (35?) mainframe programmers' on this list must have seen the
light...Hallelujah!


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]

 I'd like to apologize for that comment...  I did not mean it as a bad
 thing...

 I guess I just liken the old mainframes with the old programming
 methodologies that involved tons of upfront planning and an pretty
 unflexible design once programming started.  Back when the project
 delivery times were in years, not weeks...

 :)

 -Original Message-
 From: Jerry.Jalenak [mailto:[EMAIL PROTECTED]]

 As an 'old mainframe programmer' I resent this.  (:-)

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]

 I tend to agree on this.  I have only done a few things in struts, but
 have been programming for quite a while.  The idea of pumping everything

 out in seperate development projects just out right scares me.  If this
 was to have any chance of working out you would need:

 (1) A horrendous amount of upfront planning
 (2) Program requirements that don't change at all
 (3) A programming team that would not quit during an upfront design this

 heavy


 All in all, if its a large project you could probably dub it a death
 march project.

 #1 is too terrible to consider, #2 is just plain silly, #3... well...

 Personally, iterative development has worked in most of the projects I
 have been on and run.

 Thats all from here...

 PS. Are the project managers old mainframe programmers or something?



 -Original Message-
 From: josephb [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, June 12, 2002 7:54 PM
 To: struts-user
 Subject: RE: Struts Design/construction process. question


 This reminds me of the adage a former professor of mine used to preach:
 It is much easier to build a program than to give birth to one.

 The pump out a list of components and while bringing the page to
 life
 parts of your message make it sound an awful lot like your project
 management is involved in obstetrics in addition to software
 development. :)

 Seriously, though, you *will* run into problems doing things this way.
 For
 instance, having a junior developer create 60 form beans for the
 expected
 inputs on each page has several implications:

 1.  Your action developers will have to modify the beans anyway most
 likely
 because the form bean developer cannot know things like whether an array

 or
 a List is more appropriate for collection data in a particular instance
 (this usually depends on the Action).

 2. A naming convention for the beans must be established or madness will
 ensue.

 3. It may make sense to re-use a form bean for different jsps, or nest
 form
 beans depending on the implementation of the action classes.  The form
 bean
 developer will not know the nature of this implementation ahead of time
 and
 thus cannot make these decisions.

 b.t.w., there are tools (or you can build your own) for generating basic
 ActionForm beans, so this is not really an issue anyway.


  I have always assumed that the action classes would be completed
  at the same
  time that the page is converted to jsp/struts.

 Add ActionForm classes to the above statement and you are entirely
 correct.  We tend to view an Action, its ActionForm, and the
 presentation
 logic (i.e., Struts tags) in their associated JSP(s) as an action
 module
 of sorts, and a single developer is resonsible for these components.
 Things
 become very messy when you try to split the JSP, ActionForm, and Action
 work
 to different developers, IMHO.


 My $.02  ( more like $1.02?)


 peace,

 Joe Barefoot


  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, June 12, 2002 4:16 PM
  To: [EMAIL PROTECTED]
  Subject: Struts Design/construction process. question
 
 
 
 
  This is our *FIRST* Struts project and we are putting together a
  construction
  plan.
 
  I would like to find out how other projects divide the work
  between developers.
  Our project management would like to see a developer pump out a
 list(s) of
  disconnected components and have one person connect them together.
 
  Our page layout is well in place, and I can create a list of form
 beans.
  *note - we are not using dynabeans.
 
  So... our HMTL guy can go ahead a create the 60 pages in one shot.
  A junior developer can create 60 form beans
 
  If you are not using something like Junit, is it practical to
  design and create
  many action classes ahead of time?
 
  I have always assumed that the action classes would be completed
  at the same
  time that the page is converted to jsp/struts.
  I would have already created a generic template (that would
  compile and run ),
  so it seems 

RE: Struts Design/construction process. question

2002-06-13 Thread Niall Pemberton

Yeah Excellent, yahh booo...you suck too.

I still think we don't quite live up to the MG standard though - yoiu let
yourself down on the 'take back', but thanks, hehe ;-)

Niall

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]
 Sent: 13 June 2002 18:35
 To: [EMAIL PROTECTED]
 Subject: RE: Struts Design/construction process. question



 We may be heading off topic here...  I started out at the tail end of
 that era...  I swore an oath that I would never work on a mainframe and
 managed to avoid COBOL, RPG, JCL, Mainfram Assembler, Fortran except in
 school...

 Now back our regularly scheduled topics

 MAINFRAMES SUCK! (Happy Niall?)
 (incidentally the above was in jest - I hear you can run Linux on them
 now...)



 -Original Message-
 From: Jerry.Jalenak [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 13, 2002 1:00 PM
 To: struts-user
 Subject: RE: Struts Design/construction process. question


 Hard to believe there was a time when Cobol ruled the universe and
 programs
 were designed in a 'top-down' fashion isn't it?  And as an old (actually
 40+) mainframe programmer who is trying to make the transition from the
 non-object world of Cobol and (gasp here) assembler to the
 object-oriented
 world of Java (and JSP and struts and XML and and and), there are times
 when
 I really miss those 'good old days'.  But then I think, nah, just post a
 question on the mailing list and get the 'right' answer from all of you
 guys!

 Jerry

 -Original Message-
 From: Niall Pemberton [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 13, 2002 11:51 AM
 To: Struts Users Mailing List
 Subject: RE: Struts Design/construction process. question


 I saw this thread and thought...great, flame war..., but you guys are
 too
 nice.

 IMHO I suggest you learn from the guru before trying this next time:


 http://www.IamMarkGalbreath.org/FlameWar/HowTo/AnnoyTheHellOutOfEveryone

 Niall

 P.S. 'old (35?) mainframe programmers' on this list must have seen the
 light...Hallelujah!


  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED]]
 
  I'd like to apologize for that comment...  I did not mean it as a bad
  thing...
 
  I guess I just liken the old mainframes with the old programming
  methodologies that involved tons of upfront planning and an pretty
  unflexible design once programming started.  Back when the project
  delivery times were in years, not weeks...
 
  :)
 
  -Original Message-
  From: Jerry.Jalenak [mailto:[EMAIL PROTECTED]]
 
  As an 'old mainframe programmer' I resent this.  (:-)
 
  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED]]
 
  I tend to agree on this.  I have only done a few things in struts, but
  have been programming for quite a while.  The idea of pumping
 everything
 
  out in seperate development projects just out right scares me.  If
 this
  was to have any chance of working out you would need:
 
  (1) A horrendous amount of upfront planning
  (2) Program requirements that don't change at all
  (3) A programming team that would not quit during an upfront design
 this
 
  heavy
 
 
  All in all, if its a large project you could probably dub it a death
  march project.
 
  #1 is too terrible to consider, #2 is just plain silly, #3... well...
 
  Personally, iterative development has worked in most of the projects I
  have been on and run.
 
  Thats all from here...
 
  PS. Are the project managers old mainframe programmers or something?
 
 
 
  -Original Message-
  From: josephb [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, June 12, 2002 7:54 PM
  To: struts-user
  Subject: RE: Struts Design/construction process. question
 
 
  This reminds me of the adage a former professor of mine used to
 preach:
  It is much easier to build a program than to give birth to one.
 
  The pump out a list of components and while bringing the page to
  life
  parts of your message make it sound an awful lot like your project
  management is involved in obstetrics in addition to software
  development. :)
 
  Seriously, though, you *will* run into problems doing things this way.
  For
  instance, having a junior developer create 60 form beans for the
  expected
  inputs on each page has several implications:
 
  1.  Your action developers will have to modify the beans anyway most
  likely
  because the form bean developer cannot know things like whether an
 array
 
  or
  a List is more appropriate for collection data in a particular
 instance
  (this usually depends on the Action).
 
  2. A naming convention for the beans must be established or madness
 will
  ensue.
 
  3. It may make sense to re-use a form bean for different jsps, or nest
  form
  beans depending on the implementation of the action classes.  The form
  bean
  developer will not know the nature of this implementation ahead of
 time
  and
  thus cannot make these decisions.
 
  b.t.w., there are tools (or you

RE: tag for the blank string to nbsp; ... performance

2002-06-20 Thread Niall Pemberton

Alternatively, you could sub-class the struts PresentTag and override the
doStartTag() method to output the nbsp; if the condition is not true (I
haven't tested it, but see below example).

Then use in the same way as the struts PresentTag ... how clear is that?

  logic:presentNbsp name=theForm property=theProp
  bean:write name=theForm property=theProp/
  /logic:presentNbsp


===
import javax.servlet.jsp.JspException;
import org.apache.struts.util.ResponseUtils;
public class PresentTagNbsp extends
org.apache.struts.taglib.logic.PresentTag {

/**
 * Perform the test required for this particular tag, and either
evaluate
 * or output a nbsp;
 *
 * @exception JspException if a JSP exception occurs
 */
public int doStartTag() throws JspException {

// Present, output body
if (condition())
return (EVAL_BODY_INCLUDE);

// Not Present, output nbsp.
ResponseUtils.write(pageContext, nbsp;);

return (SKIP_BODY);

}
}
===

 -Original Message-
 From: emmanuel.boudrant [mailto:[EMAIL PROTECTED]]
 Sent: 19 June 2002 23:00
 To: Struts Users Mailing List; [EMAIL PROTECTED]
 Subject: RE: tag for the blank string to nbsp; ... performance





 jsp:useBean id=theForm class=xxx.TheFormClass scope=session/
 td
% if ( theForm.getTheProp() != null ) { %
 %= theForm.getTheProp() %
% } else { %nbsp;% } %
  /td

 is's more readable ;) ... but scope must be known.


 -Emmanuel


   Joseph Barefoot [EMAIL PROTECTED] a écrit :
 
  Hi,
 
  I've got a simple question, custom tags decrease performance,
  isn't it ? When using a custom tag, a object is instancied,
  doStartTag, doEndTag... invoked.
 
  so why use a tag for making a simple test ?

 4 reasons:

 1. You are testing for the existence of a property of an
 Attribute, not the
 existence of the attribute itself. See below for the difference.

 2. You are enforcing MVC concepts by limiting logic expressions
 in your JSP

 3. By using the tag with no scope specified, the object with name
 theForm
 could be in any scope. Doing it the scriplet way would require
 you to write
 code for a specific scope (request, sesssion, etc.).

 4. The tag is a a helluva lot easier to read than the corresponding
 scriplet (see below).
 
 
 
 
 
 
 
 
 
  became
 
 
 
 
 
 


 The above would not have the desired effect. You would have to cast and
 invoke the getter. It would have to be:


 null ) { %




 Note that this assumes the form bean is in the request. You would have to
 write more code if it could be either session or request scope. Note also
 that you are still invoking a custom tag to ouput the value, so if you're
 trying to eliminate tag overhead it should be:


 null ) { %





 Isn't that fun to read? :):)


 
 
  -Emmanuel
 
  James Mitchell a écrit :
  DOH!!.hehehe.sorry, that's what I meant. (going thru my mail too
  quickly)
 
  James Mitchell
  Software Engineer\Struts Evangelist
  Struts-Atlanta, the Open Minded Developer Network
  http://struts-atlanta.open-tools.org
 
   -Original Message-
   From: Joseph Barefoot [mailto:[EMAIL PROTECTED]]
   Sent: Thursday, June 20, 2002 4:02 PM
   To: Struts Users Mailing List; [EMAIL PROTECTED]
   Subject: RE: tag for the blank string to  
  
  
   That's what we do, except the   should be outside the logic tag, or
   it won't get ouputted when the property isn't present:
  
  
  
  
  
  
  
  
-Original Message-
From: James Mitchell [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 19, 2002 1:03 PM
To: Struts Users Mailing List
Subject: RE: tag for the blank string to  
   
   
You might be frustrated by the way tables are displayed when a
is empty
(especially if you are using stylesheets to format your tables)
   
Instead of rewriting a bunch tablib to support this, or
 calling helper
functions, I've overcome this by always adding a in
   every like
this
   
   
   
   
   
   
   
Hope this helps!
   
   
James Mitchell
Software Engineer\Struts Evangelist
Struts-Atlanta, the Open Minded Developer Network
http://struts-atlanta.open-tools.org
   
 -Original Message-
 From: Cheng, Sophia [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, June 19, 2002 2:20 PM
 To: '[EMAIL PROTECTED]'
 Subject: tag for the blank string to  


 Hi,
 Is there any tag which will write the blank string(null
   String or
 String with length 0) to   for a form property?

 Currently I am using logic:notPresent(see below), but I
 need to do it
 for many properties. Is there some other way to handle it?












 Thanks in advance.

 Sophia


 --
 To unsubscribe, e-mail:

 For additional 

RE: Newbie Struts requirements question

2002-07-18 Thread Niall Pemberton

You don't have to have a web server to run struts - you do need a servlet
container such as Tomcat. I don't know anything about Windows ME, but I used
to run Tomcat of Windows 98 at home, before I upgraded to Win2000.

Niall

 -Original Message-
 From: Ballard [mailto:[EMAIL PROTECTED]]
 Sent: 18 July 2002 19:57
 To: [EMAIL PROTECTED]
 Subject: Newbie Struts requirements question


 I've got a question. I want to run this Struts sample app at home but I'm
 running Windows ME. I've downloaded the Apache web server but it isn't
 really supported on ME. I don't want to make this exercise any harder than
 it needs to be, so I'm thinking of upgrading my OS to Windows XP
 Professional. What I can't figure out from the Microsoft site is:
 Can I run
 services on Windows XP Professional? Or can I run them on the regular XP?
 Would I be better of upgrading to Windows 2000 Professional? I know I can
 run services on that. I know the missus wouldn't be pleased if I switched
 our PC to Linux so it's either 2000 Pro or some kind of XP. (I think).

 You don't happen to have any insight here, do you?

 --
 To unsubscribe, e-mail:
 mailto:struts-user- [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: AND/OR with logic tags

2001-10-01 Thread Niall Pemberton

I have a set of tags based on If that includes AND/OR, which can be
downloaded from Ted husted's site (reference is shown under Contributor
Taglib on the strust site):

  http://jakarta.apache.org/struts/userGuide/resources.html
  http://husted.com/about/struts/logic-niallp.htm


However this was recently discussed on the Dev list and 9 out of 10
committers (well 3 actually - Craig McClanahan, Martin Cooper, Ted Husted)
preferred the JSPTL route than this.

I include links to that thread below:

http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg02946.html
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg02947.html
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg02959.html
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg02960.html
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg02962.html


Niall

 -Original Message-
 From: Eric Rizzo [mailto:[EMAIL PROTECTED]]
 Sent: 01 October 2001 17:06
 To: [EMAIL PROTECTED]
 Subject: AND/OR with logic tags


 Sorry if this has already been asked/answered here - the mail
 archive doesn't
 let me search for AND OR.

 Is there a way to have multiple conditional logic with the Struts
 logic taglib?
   For example, IF (user is present) OR (visitor equals true).

 TIA,
   Eric
 --
 Eric Rizzo, Software Engineer
 OpenNetwork Technologies
 http://www.opennetwork.com
 -
 I embrace my personality flaws, for without them
 I might have no personality at all.





RE: Cannot find message resources under key org.apache.struts.action.MESSAGE

2001-03-04 Thread Niall Pemberton

Have you defined an initialization parameter for the resource bundle?

From the User Guide:
---

When you configue the controller servlet in the web application deployment
descriptor, one of the things you will need to define in an initialization
parameter is the base name of the resource bundle for the application. In
the case described above, it would be com.mycompany.mypackage.MyResources.

servlet
  servlet-nameaction/servlet-name
  servlet-classorg.apache.struts.action.ActionServlet/servlet-class
  init-param
param-nameapplication/param-name
param-valuecom.mycompany.mypackage.MyResources/param-value
  /init-param
  .../
/servlet

The important thing is for the resource bundle to be found on the class path
for your application.

 From: G.L. Grobe [mailto:[EMAIL PROTECTED]]
 Subject: Cannot find message resources under key
org.apache.struts.action.MESSAGE


 Just started learning struts. I'm using orion server 1.4.5. I've got the
 struts.jar in my ~/WEB-INF/lib dir and have listed the taglibs in the
 ~/WEB-INF/web.xml file as well as included all the *.tld in this same dir.
   taglib
   taglib-uri/WEB-INF/struts-bean.tld/taglib-uri
   taglib-location/WEB-INF/struts-bean.tld/taglib-location
/taglib

taglib
   taglib-uri/WEB-INF/struts-html.tld/taglib-uri
   taglib-location/WEB-INF/struts-html.tld/taglib-location
/taglib
 ...

 When running the following page, I get the error list down below:
 I've also got a file called 'myProps.properties' packaged under the
 ~/WEB-INF/classes/com.mydir1/mydir2/resources dir.

  index.jsp ---
 %@ page language="java" %
 %@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %
 %@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %

 html:html
 head
 title
bean:message key="main.title" /
 /title
 /head

 body
 html:errors /

 This is a atest.
 /body
 /html:html

 --- error output -

 500 Internal Server Error
 javax.servlet.jsp.JspException: Cannot find message resources under key
 org.apache.struts.action.MESSAGE at
 org.apache.struts.util.RequestUtils.message(RequestUtils.java, Compiled
 Code) at
 org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java,
 Compiled Code) at /index.jsp._jspService(/index.jsp.java,
 Compiled Code) at
 com.orionserver.http.OrionHttpJspPage.service(JAX, Compiled Code) at
 com.evermind.server.http.HttpApplication.xj(JAX, Compiled Code) at
 com.evermind.server.http.JSPServlet.service(JAX, Compiled Code) at
 com.evermind.server.http.d3.sw(JAX, Compiled Code) at
 com.evermind.server.http.d3.su(JAX, Compiled Code) at
 com.evermind.server.http.ef.s1(JAX, Compiled Code) at
 com.evermind.server.http.ef.do(JAX, Compiled Code) at
 com.evermind.util.f.run(JAX, Compiled Code)


 Any help much appreciated.






You make the decision Velocity/Turbine vs. Struts/JSP

2001-03-04 Thread Niall Pemberton

Jon,

http://jakarta.apache.org/velocity/ymtd/ymtd.html

I read your comparison of Turbine/Velocity and Struts/JSP and although you
state it your aim to be "fair and unbiased", I think you failed since most
of your examples, although sytanctically correct, were poor examples of the
use of Struts and Jsp. I only started getting into Jsp  Struts a couple of
weeks ago but below are my comments on your article. I also copy this to the
struts mailing list as I am sure more experienced people may be able to
comment better.


In your first example "Saying Hello" there is not need whatsoever in Jsp to
have any "out.println" statements. The example you gave could have been
coded in the following way:

html
headtitleHello/title/head
body
h1
% if (request.getParameter("name") == null) %
  Hello World
% else %
  Hello, % request.getParameter("name") %
/h1
/body/html


On the subject of "Generation", I don't believe this is a big issue, since
1) its automatically handled by the servlet container and therefore not a
big issue to developers and 2) the performance issue is only relevant when
you change the application, its not like it happens every time you run the
jsp.

On the subject of "Error Handling", you are comparing Velocity only with
Jsp - the idea of Struts is that, it takes the need for Scriptlets out of
Jsp by providing custom tags (java classes) to deal with those situations.
What you quote here from Jason's books is only relevant to Scriptlets, not
well written Struts applications. The issues stated there are exactly why a
framework such as Struts was developed and an argument for using Struts.

Again in the section of "JavaBeans" you are not comparing like-with-like.
Velocity/Turbine will have the same issues of "Scope" that any Web
Application has and from what I see of your Velocity/Turbine example, you
have just hidden this from the Web Designer. The same can be done in a
Struts application with Struts tags rather than the "jsp:useBean" tag.
Again your quote from Jason's book relates solely to Jsp and is not a fair
comparison to Struts.

I'll ignore the sample app section, again its Jsp not Struts.

The "Taglibs" section is the first serious section which deals with Struts
and you start with cheap points about "cutting edge of a broken wheel" - so
tell me how is Velocity cutting edge then? - yet another scripting language
to handle presentation that a Web Designer needs to get to grips with. The
idea with Jsp/Struts is that it extends HTML in the same "style" to what Web
Designers are used to.

I would be the first to say the Struts documentation could be better but the
two examples that you listed from the Struts documentation were small
examples used to illustrate specific Struts features and not the best way to
develop Struts applications on the Model 2 architecture. The first example
using the logic:equal tag is poor because it encapsulates the "business
logic" (I know its simple) of the app in the presentation and therefore
shouldn't have been in the Jsp. Complex logic shouldn't be in the
presentation layer and so their use should be limited. The "if. . . .else"
logic of Velocity looks good to me, as a programmer, but I think a Web
Designer would be more at home with the Tag Style they are used to.

In your second example from the Struts document which uses a Scriptlet to
define an ArrayList - this has clearly been done to make the example simple
(a point I seem to remember being made in the document, though I couldn't
find the example again) - it is a break from the MVC architecture but its
not how Struts should be used, this collection would have been created in
the "logic" java end and put into scope ready for a Web Designer to use
through Struts tags - as simple or simpler than the Velocity example.

And finally - the example from "Jason Hunters" book which you say has been
entirely implemented as a Struts app - this is awful and is a complete abuse
of everything that Struts is about - why not get a decent Struts developer
(not me!) of giving you a good example - also where is the Velocity
equivalent for fair comparison - nowhere to be seen!

I was hoping for an article which would help me make an informed decision
but your portrayal of Struts didn't show it in the way it should be used or
explain what else it could do, such as Internationalization. I understand
(but not like) commercial software vendors going to any means to disparage a
competitors product but I am shocked that one Open Source project has done
it to another when they both come under the same Apache umbrella.

Niall

 winmail.dat


RE: You make the decision Velocity/Turbine vs. Struts/JSP

2001-03-04 Thread Niall Pemberton

Your're right, my mistake, but I'm wasn't criticising your aim, just the
acutal guts of the comparison, the aim's a good one :-)

Niall


 -Original Message-
 From: Jon Stevens [mailto:[EMAIL PROTECTED]]
 Sent: 04 March 2001 21:47
 To: Niall Pemberton
 Cc: [EMAIL PROTECTED]
 Subject: Re: You make the decision Velocity/Turbine vs. Struts/JSP


 I'm going through the document and making some changes based on yours (and
 others) suggestions and I have a question:

 on 3/4/01 11:55 AM, "Niall Pemberton" [EMAIL PROTECTED]
 wrote:

  I read your comparison of Turbine/Velocity and Struts/JSP and
 although you
  state it your aim to be "fair and unbiased"

 Where exactly do I state that?

 I see:

 "Therefore, a lot of effort has gone into this essay to state things as
 fairly and accurately as possible."

 Which is true and I don't think that should change. But, I don't
 see where I
 said "unbiased".

 :-)

 -jon

 --
 If you come from a Perl or PHP background, JSP is a way to take
 your pain to new levels. --Anonymous
 http://jakarta.apache.org/velocity/ymtd/ymtd.html






RE: Minimizing Action class proliferation

2001-03-07 Thread Niall Pemberton

Donnie,

How about this as an alternative. I have created a subclass of Action called
StandardAction which uses reflection to invoke a method with the same name
as the "actions" path (defined in the struts-config.xml file). So all you
have to do is extend the Standard action and implement methods that
correspond to the paths that use it.

For example if you define three actions in your struts-config.xml file of
/saveOrder, /editOrder and /deleteOrder that all use a class OrderAction
which extends StandardAction and then create a OrderAction class as shown
below:

I hope this is of use.

Niall


--Example of StandardAction implementation---

public class OrderAction extends StandardAction{

  public ActionForward saveOrder(ActionMapping mapping,
   ActionForm form,
   HttpServletRequest request,
   HttpServletResponse response) {


  }
  public ActionForward editOrder(ActionMapping mapping,
   ActionForm form,
   HttpServletRequest request,
   HttpServletResponse response) {


  }
  public ActionForward deleteOrder(ActionMapping mapping,
   ActionForm form,
   HttpServletRequest request,
   HttpServletResponse response) {


  }
}

---StandardAction Class---
package nkp;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;

/**
 * @author Niall Pemberton
 * @version 1.0
 */

public abstract class StandardAction  extends Action {

  public ActionForward perform(ActionMapping mapping,
   ActionForm form,
   HttpServletRequest request,
   HttpServletResponse response) {


// Determine the method name to call (based on the path without the "/")
String methodName = mapping.getPath().substring(1);

// Get the method with the same name as the path
Class cls = this.getClass();
Method method = null;
try {
  method = cls.getMethod(methodName, new Class[] {ActionMapping.class,
  ActionForm.class,

HttpServletRequest.class,

HttpServletResponse.class});
}
catch (NoSuchMethodException ex) {
  servlet.log("Method "+methodName+" not found in class
"+this.toString());
}

// Invoke the Method
Object obj = null;
try {
  obj = method.invoke(this, new Object[] {mapping, form, request,
response});
}
catch (InvocationTargetException etargEx) {
  servlet.log("Error Involing Method
"+methodName+"(InvocationTargetException) "+this.toString());
}
catch (IllegalAccessException illEx) {
  servlet.log("Error Involing Method
"+methodName+"(IllegalAccessException) "+this.toString());
}
ActionForward actionForward = (ActionForward)obj;

// Forward control to the specified success URI
return actionForward;
  }
}

 winmail.dat


RE: Tomcat question

2001-03-21 Thread Niall Pemberton

Johan,

I'm using Tomcat Version 3.2.1 and the readme document had the following
information
on Tomcat versions. There isn't info about 3.2.2  3.3 there but probably if
you
download those versions there will be a readme explaining the changes.

Besides the differences in functionality the other difference is the
quality/stability
of the versions - whether they are milestone, beta or release quality.

Tomcat Versions 3.1.1 and 3.2.1 are the only "release" builds.
Tomcat Versions 3.2.2 and 4.0 are beta versions.
Tomcat Version 3.3 is a milestone build.

From a Struts point of view the minimum requirement is Tomcat 3.1 but there
are lots of
messages from those in the know that version 3.1 is not recommended, you
need 3.2 at least.

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

Hope this helps.

Niall

README 1.  INTRODUCTION
README Tomcat Version 3.2.1 is a security related update!  See Section 7,
below,
README for details on the changes that have been made.  All other existing
issues with
README Tomcat 3.2 will remain in 3.2.1 -- they will be addressed in
subsequent
README maintenance updates (3.2.2, and so on).

README 4.  TOMCAT: PAST, PRESENT, AND FUTURE
README - Version 3.0 (released 12/1999) was the initial release of Tomcat.
In
README addition to implementing the Java Servlet and Server Pages
specification,
README this release featured a minimal Apache connector.

README - Tomcat 3.1 (released 4/2000) improved the Apache connection and
added
README connector support for Netscape and IIS web servers. It also added
WAR file
README support, automatic servlet reloading, and a command line tool (jspc)
to
README compile ahead of time the JSP pages that comprise your application.
Finally,
README version 3.1 also focused on reorganizing the code (modularization,
cleanup,
README refactoring, removal of dead code, and separation of J2EE-specific
code).

README - Tomcat 3.2 is the first performance tune-up, and also adds a few
new
README features (see next section).

README - Tomcat 4.0 is separate development from Tomcat 3.x.  It is based
on the
README Catalina architecture, which is very different from the architecture
of
README Tomcat 3.x.  In addition, Tomcat 4.0 is to be the reference
implementation
README for the Servlet 2.3 and JSP 1.2 specifications.

README 7.  SECURITY VULNERABILITIES FIXED IN TOMCAT 3.2.1


README 7.1 Protection of Resources in /WEB-INF and /META-INF Directories

README The servlet specification prohibits servlet containers from serving
resources
README in the /WEB-INF and /META-INF directories of a web application
archive directly
README to clients.  In Tomcat 3.2, this means that URLs like:

READMEhttp://localhost:8080/examples/WEB-INF/web.xml

README will return an error message, rather than the contents of your
deployment
README descriptor.  However, there is a vulnerability in Tomcat 3.2 that
exposes
README this information if the client requests a URL like this instead:

README http://localhost:8080/examples//WEB-INF/web.xml

README (note the double slash before "WEB-INF").  This vulnerability has
been
README corrected in Tomcat 3.2.1.


README 7.2 Show Source Vulnerability

README The example application delivered with Tomcat 3.2 included a
mechanism to
README display the source code for the JSP page examples.  This mechanism
could
README be used to bypass the restrictions on displaying sensitive
information in
README the WEB-INF and META-INF directories.  This vulnerability has been
removed.


 -Original Message-
 From: Johan Compagner [mailto:[EMAIL PROTECTED]]
 Sent: 22 March 2001 00:00
 To: Struts
 Subject: Tomcat question


 Hi,

 One tomcat question for this list (i know there are some tomcat
 developers here)
 Why can't i find changes.html or something like that for the
 tomcat versions?

 You got now a
 3.1.x branch (doesn't seem to be in development anymore)
 3.2.x branch (still development 3.2.2 beta 1 as latest mile stonde)
 3.3.x branch (the latest in 3.x)

 And you got 4.0

 I know the differences between 3.x (servlet 2.2 / jsp 1.1) and
 4.x (servlet 2.3 / jsp 1.2)

 But why all those 3.x branches and why are there even 2 in development?

 Johan








RE: form question

2001-03-25 Thread Niall Pemberton

I have the same problem - form fields embedded in an iterate tag.

Would it be possible to change tags such as CheckboxTag and BaseFieldTag so
that they detect when they are embedded in the "iterate" tag and format the
name attribute appropriately.

I tried changing these two tags replacing the following line in the the
doStartTag() method:

results.append(property);

With the following code and it worked well, automatically populating my
collection objects:

results.append(decideName());

/**
 * Determine the name attribute
 */
private String decideName() {

  // Check if this Tag is embedded in an Iterator Tag
  Tag tag = findAncestorWithClass(this, IterateTag.class);

  // No iterator, use the property as the name
  if (tag == null)
return this.property;

  IterateTag iterator = (IterateTag)tag;
  int index = iterator.getLengthCount()-1;

  return iterator.getProperty()+"["+index+"]."+this.property;

}

Niall

P.S. thanks for Struts - great framework.

 -Original Message-
 From: Uwe Pleyer [mailto:[EMAIL PROTECTED]]
 Sent: 25 March 2001 07:24
 To: [EMAIL PROTECTED]
 Subject: Re: form question


 Hey,

 I had some hard nights fighting with exactly this problem and got
 a solution
 wich is not very elegant but works...


 html:form action="/formAction.do"
 table border="1" width="100%"
 // some headings for the table
   % int i = 0; %
   logic:iterate name="Bean" property="beanItems" id="anything"
   tr
 td
   html:text name="Bean" property='%= "beanItems[" + i +
 "].amount"
 %'/
 /td
 td
 $bean:write name="Bean" property='%= "beanItems[" + i +
 "].total"
 %' filter="true" /
 /td
 td
 html:checkbox name="Bean" property='%= "beanItems[" + i +
 "].checkbox" %'/
 /td
 td
  /tr
  % i++; %
   /logic:iterate
   /table
html:submit/
 /html:form

 As you see, you use the collektion of your formbean directly. The
 Bean needs
 properties, getter and setter Methods according to the Javabean-Spec whats
 the reason to change BeanItems to beanItems!

 private Collection beanItems;
 public Item getBeanItems(int index)
 public void setBeanItems(int index, Item item)
 public Item[] getBeanItems()
 public void setBeanItems(Item[] items)

 It's also important to configure your formbean with scope="session" in
 Struts-config and never to destroy your Collection in the
 reset-Method! The
 HTML for the input field will show like this: input type="text"
 name="beanItems[0].amount" value="123"

 After submit Struts uses the following setter Method:
 Bean.getBeanItems(0).setAmount("123"); As struts use the getBeanItems(i)
 Method to get yor Item-Objects, there is no chance to create them in the
 request-scope. There must be held from the moment you establish your
 beanItems-Collection for output till the submit of the user in
 session-scope.

 Hope that helps

 Uwe


 JOEL VOGT schrieb:

  Hi all,
 
  I have a html form on a jsp page. This form has a table generated by the
  logic iterate tag.
  In each table row, there are two fields, one a checkbox and the other a
  text field.
  What I want is when the user clicks 'submit' all the values are sent to
  an action form for storing and then to my servlet for processing.
  How do I make a form that will automatically be populated by all these
  values? In other words I'm stuffed please help ;)
 
  Thanks, Joel.
 
  Sample jsp:
 
  html:form action="/formAction.do"
  table border="1" width="100%"
  // some headings for the table
logic:iterate name="Bean" property="BeanItems" id="bean"
tr
  td
html:text name="bean" property="amount"/
  /td
  td
  $bean:write name="bean" property="total" filter="true" /
  /td
  td
  html:checkbox name="bean" property="checkbox"/
  /td
  td
   /tr
/logic:iterate
/table
 html:submit/
  /html:form
 
  How do I get these values into a form then servlet then database?






RE: using titles from an application resource file in my templates

2001-03-27 Thread Niall Pemberton

Have you included the bean TLD in your jsp?

   %@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %


 -Original Message-
 From: Troy Hart [mailto:[EMAIL PROTECTED]]
 Sent: 27 March 2001 17:52
 To: [EMAIL PROTECTED]
 Subject: Re: using titles from an application resource file in my
 templates


 This doesn't work. In the case you show below, the title ends up being:

   "b bean:message key="publish.title" /  /b"

 Troy

  Luckly someone answered this last week:
 
   template:put name="title" direct="true"
 b bean:message key="publish.title" /  /b
/template:put
 
 
  Troy Hart wrote:
 
  I am using struts-template.tld and I want to be able to use my
 application
  resources to get the correct title for any given page. I thought I had
 seen
  this talked about somewhere but I can't find it anyplace in the mail
  archives. I'm sure people that use struts templates must be doing this,
 but
  I'm just not seeing how right now. It seems to me that I need
 a tag that
  works similar to:
 
  bean:message key="somePage.title"/
 
  Except that it needs to expose a scripting variable with the value,
 instead
  of writing it to the output stream. Maybe the message tag could be
 extended
  to include an "id" parameter which, if set, stores the value in a page
  scoped attribute with the given name... This way I could do something
 like
  this:
 
  ...
  bean:message id="pageTitle" key="somePage.title"/
  template:put name="title" content="%= pageTitle %" direct="true"/
  ...
 
  Maybe there is already a mechanism to cleanly accomplish this...any
  pointers?
 
  Thanks,
 
  Troy





RE: Can I nest struts:message tag in struts:link tag?

2001-03-27 Thread Niall Pemberton

When you say struts:message do you mean the 0.5 struts TLD, if so I don't
know. I'm using struts 1.0 beta and you can do the following:

html:link page="/something.do"bean:message key="x."//html:link

 -Original Message-
 From: JeanX [mailto:[EMAIL PROTECTED]]
 Sent: 27 March 2001 06:01
 To: struts-user
 Subject: Can I nest struts:message tag in struts:link tag?


 Hi struts-user,

 Can I nest struts:message tag in struts:link tag ?
 Because I want to setup some query parameter in resources.
 Thx

 :=)
 Best regards,
 JeanX
 pacificnet.com(GZ)






RE: POSTing arrays in struts

2001-04-09 Thread Niall Pemberton

This issue has come up quite regularly in the list. I got round this by
taking my own copies of struts tags and modifying them so that they check if
they are contained in an "IterateTag". If they are then I generate the name
appropriately using the property from the IterateTag, the current index
value and the property from the actual tag. Struts then automatically
populates the data back appropriately. You have to do something a bit more
complex if your using request rather than session scope to generate a bean
collection but thats the only issue.

For Example:
logic:iterate id="list" name="formExample" property="beanArray"
   trtdhtml:text name="list" property="desc"//td
/logic:iterate

generates:
input type="text" name="beanArray[0].desc" value=".."/
input type="text" name="beanArray[1].desc" value=".."/
input type="text" name="beanArray[2].desc" value=".."/ etc. etc.

With my modified iterate and text ( BaseFieldTag) tags. This then
causes Struts to generate appropriate method calls to populate the values
back to the form [e.g. formExample.getBeanArray(0).setCode(..) etc.]

I detailed this a couple of times as a request but unfortunately so far no
one has given any feedback. Even if this proposal is no accepted then
putting the logic to generate the "name" attribute in separate methods which
could be overriden rather than copying the tag and having to change the
doStartTag() method would be really useful.

Previous messages:
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg05231.html
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg00975.html

Niall

P.S I also have a similar issue where I want to overide the default
behaviour for setting the "value" attribute for another issue.

 -Original Message-
 From: Will Spies/Towers Perrin [mailto:[EMAIL PROTECTED]]
 Sent: 09 April 2001 16:13
 To: [EMAIL PROTECTED]
 Cc: '[EMAIL PROTECTED]'
 Subject: RE: POSTing arrays in struts

 I don't really understand why I have to do this. That's a lot of code to
 write too. The JSP code that I have below actually works on the read.
 Struts handles it fine and I see the actual data sitting in the input
 control when the form comes up in my browser. If struts can do that, I
 can't see why struts can't go the other way and match it up on a
 post so my
 "form' already has the data way before the 'perform' method is called.


  To:
 "'[EMAIL PROTECTED]'"
 "Taylor,
 [EMAIL PROTECTED]
 Jeremy"  cc: (bcc: Will
 Spies/Towers Perrin)
 jtaylor@lehmSubject: RE: POSTing
 arrays in struts
 an.COM



 04/09/01

 11:04 AM

 Please

 respond to

 struts-user








 If all your input fields have the same name then when the form is
 submitted
 there will be a

 in your Action class there will be a method "perform" has takes a
 parameter
 HttpServletRequest request,

 so, rather than doing
 PropertyUtils.copyProperties(user, form);

 do something like

 String[] rows = request.getParameterValues("InputFieldName");
 form.setRows(rows);


  -Original Message-
  From: Will Spies/Towers Perrin [SMTP:[EMAIL PROTECTED]]
  Sent: 09 April 2001 15:41
  To:   [EMAIL PROTECTED]
  Cc:   '[EMAIL PROTECTED]'
  Subject:   RE: POSTing arrays in struts
 
 
 
  Ok. Now we are talking.
 
  Q1: My save action class DOES work like the example. It gets
 the form and
  expects the ActionServlet to fill it up. By the time I get the form, the
  ActionServlet is done with it? How would I change this to work properly
 or
  do I need a new version of the util class?
 
  Q2: I was under the impression the html:text tags did not work properly
  inside an iterate tag.
 
 
 
 
 
 
 
   To:
  "'[EMAIL PROTECTED]'"
  "Taylor,
 [EMAIL PROTECTED]
 
  Jeremy"  cc: (bcc: Will Spies/Towers
  Perrin)
  jtaylor@lehmSubject: RE: POSTing arrays
  in struts
  an.COM
 
 
 
  04/09/01
 
  10:32 AM
 
  Please
 
  respond to
 
  struts-user
 
 
 
 
 
 
 
 
  You don't need to generate index properties for the input tags.
  Also, how does your save action class work? If you based it on
 the struts
  examples you'll need to
  change it because the util class that copies bean properties won't work
  with
  the array of values for the rows property.
 
   -Original Message-
   From: Will Spies/Towers Perrin [SMTP:[EMAIL PROTECTED]]
   Sent: 09 April 2001 15:13
   To:   [EMAIL PROTECTED]
   Cc:   '[EMAIL PROTECTED]'
   Subject:   RE: POSTing arrays in 

RE: POSTing arrays in struts

2001-04-09 Thread Niall Pemberton

I don't know if I understand your situation but is this a scope issue?
Either you use session scope and set up your beanArray before showing the
form, then when a POST is done Struts will call the appropriate setters on
the beans in the array. Or you use request scope which is a bit more tricky
because the bean array is empty so Struts can't call the setters. In this
case I got round this by generating beans as the setters were being called:

In my ActionForm class:

  private Vector beanVector;

  public MyBean getBeanVector(int index) {
if (beanVector == null)
  beanVector = new Vector(15, 5);

if (index+1  beanVector.size()) {
  for (int i = beanVector.size(); i  index+1; i++) {
  beanVector.add(new MyBean());
  }
}

return (MyBean)beanVector.get(index);
  }


Thus Struts tags:
 logic:iterate id="list" name="myForm" property="beanVector"
trtdhtml:text name="list" property="desc"//td
 /logic:iterate

generates:
 input type="text" name="beanVector[0].desc" value="abc"/
 input type="text" name="beanVector[1].desc" value="def"/
 input type="text" name="beanVector[2].desc" value="ghi"/

Causing Struts to generate the following method call to populate your bean
array in your ActionForm:
getBeanVector(0).setDesc("abc");
getBeanVector(1).setDesc("def");
getBeanVector(2).setDesc("ghi");



 -Original Message-
 From: Will Spies/Towers Perrin [mailto:[EMAIL PROTECTED]]
 Sent: 09 April 2001 20:37
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: RE: POSTing arrays in struts


 Thanks for your reply. I did see these messages and I'm ok with fixing the
 iterate tag issue. I have a bigger (related) problem.  My problem
 is when I
 get a POST struts does not fill in my ActionForm correctly. For
 example, in
 your example my LoginForm would not contain a beanArray with 3
 elements. It
 would contain 0. Struts is failing to generate the proper getter calls as
 far as I can tell.

   To:
 [EMAIL PROTECTED]
 "Niall Pemberton" cc: (bcc:
 Will Spies/Towers Perrin)
 niall.pemberton@btIntSubject:
 RE: POSTing arrays in struts
 ernet.com

 This issue has come up quite regularly in the list. I got round this by
 taking my own copies of struts tags and modifying them so that they check
 if
 they are contained in an "IterateTag". If they are then I
 generate the name
 appropriately using the property from the IterateTag, the current index
 value and the property from the actual tag. Struts then automatically
 populates the data back appropriately. You have to do something a bit more
 complex if your using request rather than session scope to generate a bean
 collection but thats the only issue.

 For Example:
 logic:iterate id="list" name="formExample" property="beanArray"
trtdhtml:text name="list" property="desc"//td
 /logic:iterate

 generates:
 input type="text" name="beanArray[0].desc" value=".."/
 input type="text" name="beanArray[1].desc" value=".."/
 input type="text" name="beanArray[2].desc" value=".."/ etc. etc.

 With my modified iterate and text ( BaseFieldTag) tags. This then
 causes Struts to generate appropriate method calls to populate the values
 back to the form [e.g. formExample.getBeanArray(0).setCode(..) etc.]

 I detailed this a couple of times as a request but unfortunately so far no
 one has given any feedback. Even if this proposal is no accepted then
 putting the logic to generate the "name" attribute in separate methods
 which
 could be overriden rather than copying the tag and having to change the
 doStartTag() method would be really useful.

 Previous messages:
 http://www.mail-archive.com/struts-user@jakarta.apache.org/msg05231.html
 http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg00975.html

 Niall

 P.S I also have a similar issue where I want to overide the default
 behaviour for setting the "value" attribute for another issue.

  -Original Message-
  From: Will Spies/Towers Perrin [mailto:[EMAIL PROTECTED]]
  Sent: 09 April 2001 16:13
  To: [EMAIL PROTECTED]
  Cc: '[EMAIL PROTECTED]'
  Subject: RE: POSTing arrays in struts
 
  I don't really understand why I have to do this. That's a lot of code to
  write too. The JSP code that I have below actually works on the read.
  Struts handles it fine and I see the actual data sitting in the input
  control when the form comes up in my browser. If struts can do that, I
  can't see why struts can't go the other way and match it up o

RE: POSTing arrays in struts

2001-04-09 Thread Niall Pemberton

Yes I have it working and I'm using the beta (i.e. version 1.0-b1).

Not quite sure what you mean by "one level of indirection lower" but my
suggestion is to set the debug level in BeanUtils - which is what
ActionServlet uses to populate the bean - it should give you a whole load of
output telling you what its trying to do - unfortunately its using
System.out.println so it'll come out to the tomcat console.

BeanUtils.setDebug(1); // its a static method

Otherwise you could try posting your code here and perhaps someone will be
able to spot whats going wrong.

Niall

 -Original Message-
 From: Will Spies/Towers Perrin [mailto:[EMAIL PROTECTED]]
 Sent: 09 April 2001 21:30
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: RE: POSTing arrays in struts

 That is my situation exactly. I've tried session scope and request scope.
 For request, I did the same exact trick you have here. Both cases it's not
 working for me. My ActionForm is not getting populated at all. I am one
 level of indirection lower than what you have here but same
 concept. If you
 have this working though the problem could just be that I'm messing up
 somewhere and one of my properties is coming back null. I didn't think so
 though. What build are you using?

   To:
 [EMAIL PROTECTED]
     "Niall Pemberton" cc: (bcc:
 Will Spies/Towers Perrin)
 niall.pemberton@btIntSubject:
 RE: POSTing arrays in struts
 ernet.com



 I don't know if I understand your situation but is this a scope issue?
 Either you use session scope and set up your beanArray before showing the
 form, then when a POST is done Struts will call the appropriate setters on
 the beans in the array. Or you use request scope which is a bit
 more tricky
 because the bean array is empty so Struts can't call the setters. In this
 case I got round this by generating beans as the setters were
 being called:

 In my ActionForm class:

   private Vector beanVector;

   public MyBean getBeanVector(int index) {
 if (beanVector == null)
   beanVector = new Vector(15, 5);

 if (index+1  beanVector.size()) {
   for (int i = beanVector.size(); i  index+1; i++) {
   beanVector.add(new MyBean());
   }
 }

 return (MyBean)beanVector.get(index);
   }


 Thus Struts tags:
  logic:iterate id="list" name="myForm" property="beanVector"
 trtdhtml:text name="list" property="desc"//td
  /logic:iterate

 generates:
  input type="text" name="beanVector[0].desc" value="abc"/
  input type="text" name="beanVector[1].desc" value="def"/
  input type="text" name="beanVector[2].desc" value="ghi"/

 Causing Struts to generate the following method call to populate your bean
 array in your ActionForm:
getBeanVector(0).setDesc("abc");
getBeanVector(1).setDesc("def");
getBeanVector(2).setDesc("ghi");



  -Original Message-
  From: Will Spies/Towers Perrin [mailto:[EMAIL PROTECTED]]
  Sent: 09 April 2001 20:37
  To: [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Subject: RE: POSTing arrays in struts
 
 
  Thanks for your reply. I did see these messages and I'm ok with fixing
 the
  iterate tag issue. I have a bigger (related) problem.  My problem
  is when I
  get a POST struts does not fill in my ActionForm correctly. For
  example, in
  your example my LoginForm would not contain a beanArray with 3
  elements. It
  would contain 0. Struts is failing to generate the proper
 getter calls as
  far as I can tell.
 
To:
  [EMAIL PROTECTED]
  "Niall Pemberton" cc: (bcc:
  Will Spies/Towers Perrin)
  niall.pemberton@btIntSubject:
  RE: POSTing arrays in struts
  ernet.com
 
  This issue has come up quite regularly in the list. I got round this by
  taking my own copies of struts tags and modifying them so that
 they check
  if
  they are contained in an "IterateTag". If they are then I
  generate the name
  appropriately using the property from the IterateTag, the current index
  value and the property from the actual tag. Struts then automatically
  populates the data back appropriately. You have to do something a bit
 more
  complex if your using request rather than session scope to generate a
 bean
  collection but thats the only issue.
 
  For Example:
  logic:iterate id="list" name="formExample" property="beanArray"
 trtdhtml:text name="list" property="desc"//td
  /logic:iterate
 
  generates:
  input type="text" name="beanArray[0].desc"

RE: POSTing arrays in struts

2001-04-09 Thread Niall Pemberton

I looked at your first message and saw the code snippet you put there. I
tried out using your jsp code and put together a couple of classes  got it
working no problem:

html:text property="data.rows[1].employeeName" size="30"
maxlength="30"/

One problem I did have was I had to change the above from "EmployeeName" to
"employeeName" to get it working.

I also used the following classes:

In the Action Form:

  private TestBean data = new TestBean();
  public TestBean getData() {
return data;
  }

I created a TestBean as follows:

  public class TestBean {
private EmplBean[] rows = new EmplBean[] {new EmplBean("Fred"), new
EmplBean("John")};
public EmplBean getRows(int index) {
  return rows[index];
}
  }

I created an EmplBean as follows:

  public class EmplBean {
public String EmployeeName;
public EmplBean(String name) {
  EmployeeName = name;
}
public String getEmployeeName() {
  return EmployeeName;
}
public void setEmployeeName(String name) {
      EmployeeName = name;
}
  }

 -Original Message-
 From: Niall Pemberton [mailto:[EMAIL PROTECTED]]
 Sent: 10 April 2001 01:03
 To: [EMAIL PROTECTED]
 Subject: RE: POSTing arrays in struts


 Yes I have it working and I'm using the beta (i.e. version 1.0-b1).

 Not quite sure what you mean by "one level of indirection lower" but my
 suggestion is to set the debug level in BeanUtils - which is what
 ActionServlet uses to populate the bean - it should give you a
 whole load of
 output telling you what its trying to do - unfortunately its using
 System.out.println so it'll come out to the tomcat console.

   BeanUtils.setDebug(1); // its a static method

 Otherwise you could try posting your code here and perhaps someone will be
 able to spot whats going wrong.

 Niall

  -Original Message-
  From: Will Spies/Towers Perrin [mailto:[EMAIL PROTECTED]]
  Sent: 09 April 2001 21:30
  To: [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Subject: RE: POSTing arrays in struts
 
  That is my situation exactly. I've tried session scope and
 request scope.
  For request, I did the same exact trick you have here. Both
 cases it's not
  working for me. My ActionForm is not getting populated at all. I am one
  level of indirection lower than what you have here but same
  concept. If you
  have this working though the problem could just be that I'm messing up
  somewhere and one of my properties is coming back null. I
 didn't think so
  though. What build are you using?
 
        To:
  [EMAIL PROTECTED]
  "Niall Pemberton" cc: (bcc:
  Will Spies/Towers Perrin)
  niall.pemberton@btIntSubject:
  RE: POSTing arrays in struts
  ernet.com
 
 
 
  I don't know if I understand your situation but is this a scope issue?
  Either you use session scope and set up your beanArray before
 showing the
  form, then when a POST is done Struts will call the appropriate
 setters on
  the beans in the array. Or you use request scope which is a bit
  more tricky
  because the bean array is empty so Struts can't call the
 setters. In this
  case I got round this by generating beans as the setters were
  being called:
 
  In my ActionForm class:
 
private Vector beanVector;
 
public MyBean getBeanVector(int index) {
  if (beanVector == null)
beanVector = new Vector(15, 5);
 
  if (index+1  beanVector.size()) {
for (int i = beanVector.size(); i  index+1; i++) {
beanVector.add(new MyBean());
}
  }
 
  return (MyBean)beanVector.get(index);
}
 
 
  Thus Struts tags:
   logic:iterate id="list" name="myForm" property="beanVector"
  trtdhtml:text name="list" property="desc"//td
   /logic:iterate
 
  generates:
   input type="text" name="beanVector[0].desc" value="abc"/
   input type="text" name="beanVector[1].desc" value="def"/
   input type="text" name="beanVector[2].desc" value="ghi"/
 
  Causing Struts to generate the following method call to
 populate your bean
  array in your ActionForm:
 getBeanVector(0).setDesc("abc");
 getBeanVector(1).setDesc("def");
 getBeanVector(2).setDesc("ghi");
 
 
 
   -Original Message-
   From: Will Spies/Towers Perrin [mailto:[EMAIL PROTECTED]]
   Sent: 09 April 2001 20:37
   To: [EMAIL PROTECTED]
   Cc: [EMAIL PROTECTED]
   Subject: RE: POSTing arrays in struts
  
  
   Thanks for your reply. I did see these messages and I'm ok with fixing
  the
   iterate tag issue. I have a bigger (related) problem.  My problem
   is when I
   

RE: POSTing arrays in struts

2001-04-09 Thread Niall Pemberton

Brilliant :-)

It was the substance I was concentrating on.

 -Original Message-
 From: Matthew O'Haire [mailto:[EMAIL PROTECTED]]
 Sent: 10 April 2001 02:17
 To: '[EMAIL PROTECTED]'
 Subject: RE: POSTing arrays in struts



  One problem I did have was I had to change the above from "EmployeeName"
 to
  "employeeName" to get it working.

 Good Java style normally reserves Capitalized identifiers for class
 declarations.  Struts reflection expects you to be following bean naming
 conventions and styles.

  I created an EmplBean as follows:

 With public get/set your bean memeber variable should be private
 or at least
 protected.  Also, a little white-space never killed anyone.

   public class EmplBean {
 private String employeeName;

 public EmplBean(String employeeName) {
   this.mployeeName = employeeName;
 }

 public String getEmployeeName() {
   return employeeName;
 }
 public void setEmployeeName(String employeeName) {
   this.employeeName = employeeName;
 }
   }





RE: POSTing arrays in struts

2001-04-10 Thread Niall Pemberton

I tried it as an inner class and it worked fine.

 -Original Message-
 From: Will Spies/Towers Perrin [mailto:[EMAIL PROTECTED]]
 Sent: 10 April 2001 12:26
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: RE: POSTing arrays in struts

 The uppercase was a typo. I simplified my snipet before putting
 it up here.
 In real life, it's lower case.

 Your example is pretty much exactly what I have. The only difference is my
 "EmplBean" is actually an inner class of my "TestBean". I have been  using
 the BeanUtils.setDebug and this is the kind of message I get from it when
 it populates my Bean:

 {action=[Ljava.lang.String;@508805ec, data.rows[1].empEmployeeId
 =[Ljava.lang.String;@508005ec, org.apache.struts.taglib.html.TOKEN
 =[Ljava.lang.String;@509805ec}
 BeanUtils.populate(com.towers.bas.sample.EmploymentForm@48805ee, {action
 =[Ljava.lang.String;@508805ec, data.rows[1].empEmployeeId
 =[Ljava.lang.String;@508005ec, org.apache.struts.taglib.html.TOKEN
 =[Ljava.lang.String;@509805ec})
   name='action', value.class='[Ljava.lang.String;'
 No such property, skipping
   name='data.rows[1].empEmployeeId', value.class='[Ljava.lang.String;'
 getPropertyDescriptor: java.lang.reflect.InvocationTargetException
 No such property, skipping
   name='org.apache.struts.taglib.html.TOKEN', value.class
 ='[Ljava.lang.String;'
 getPropertyDescriptor: java.lang.NoSuchMethodException: Unknown
 property 'org'
 No such property, skipping

 Some of these I've added myself. So, I'm getting an InvocationException
 error. None of my classes are null and this all works when I pass it to my
 view ( so I know my method names are proper since it works once using an
 EditAction like example ).

 I still think I'm screwing up somewhere somehow. I think you answered my
 original question though. Since you have this working chances are my
 problem is just that. My problem. I have learned that at least someone has
 this working in the same version I'm using so chances are I just need to
 figure out my own problem. Unless you think the inner class has something
 to do with it ( yes, it's public )?
   To:
 [EMAIL PROTECTED]
     "Niall Pemberton" cc: (bcc:
 Will Spies/Towers Perrin)
 niall.pemberton@btIntSubject:
 RE: POSTing arrays in struts
 ernet.com


 I looked at your first message and saw the code snippet you put there. I
 tried out using your jsp code and put together a couple of
 classes  got it
 working no problem:

 html:text property="data.rows[1].employeeName" size="30"
 maxlength="30"/

 One problem I did have was I had to change the above from
 "EmployeeName" to
 "employeeName" to get it working.

 I also used the following classes:

 In the Action Form:

   private TestBean data = new TestBean();
   public TestBean getData() {
 return data;
   }

 I created a TestBean as follows:

   public class TestBean {
 private EmplBean[] rows = new EmplBean[] {new EmplBean("Fred"), new
 EmplBean("John")};
 public EmplBean getRows(int index) {
   return rows[index];
 }
   }

 I created an EmplBean as follows:

   public class EmplBean {
 public String EmployeeName;
 public EmplBean(String name) {
   EmployeeName = name;
 }
 public String getEmployeeName() {
   return EmployeeName;
 }
 public void setEmployeeName(String name) {
   EmployeeName = name;
 }
   }

  -Original Message-
  From: Niall Pemberton [mailto:[EMAIL PROTECTED]]
  Sent: 10 April 2001 01:03
  To: [EMAIL PROTECTED]
  Subject: RE: POSTing arrays in struts
 
 
  Yes I have it working and I'm using the beta (i.e. version 1.0-b1).
 
  Not quite sure what you mean by "one level of indirection lower" but my
  suggestion is to set the debug level in BeanUtils - which is what
  ActionServlet uses to populate the bean - it should give you a
  whole load of
  output telling you what its trying to do - unfortunately its using
  System.out.println so it'll come out to the tomcat console.
 
   BeanUtils.setDebug(1); // its a static method
 
  Otherwise you could try posting your code here and perhaps someone will
 be
  able to spot whats going wrong.
 
  Niall
 
   -Original Message-
   From: Will Spies/Towers Perrin [mailto:[EMAIL PROTECTED]]
   Sent: 09 April 2001 21:30
   To: [EMAIL PROTECTED]
   Cc: [EMAIL PROTECTED]
   Subject: RE: POSTing arrays in struts
  
   That is my situation exactly. I've tried session scope and
  request scope.
   For request, I did the same exact trick you have here. Both
  cases it's not
   working for me. My ActionForm is not getting populated at
 all. I am one
   level of indirection lower than what you have here but same
   concept. If you
   have this working though the problem could just be that

RE: How to display the size of an Collection attribute of a bean?

2001-04-10 Thread Niall Pemberton



How 
about implementing a getSize() method in your bean which returns the size, then 
you can use the tags such as bean:write

  -Original Message-From: Thai Thanh Ha 
  [mailto:[EMAIL PROTECTED]]Sent: 10 April 2001 08:43To: 
  [EMAIL PROTECTED]Subject: How to display the size of 
  an Collection attribute of a bean?
  I want to display 
  the size of an Collection attribute of a Bean using Struts taglibs. I 
  can use scriptlet but are there any other ways to do that? 

  
  Regards,
  Thai


RE: POSTing arrays in struts

2001-04-10 Thread Niall Pemberton

No, you still need to change Struts to do this.

Currently I believe they are on a feature freeze for 1.0. The following
entry is on the 1.1 TODO list which I believe is the same issue. However
there is no volunteer currently against this entry on the web Site and how
it is implemented may be different to what I have done.

HTML Tag Library

"Improved Iteration Support. Improve the ability to use the logic:iterate
tag over a collection, and generate a set of input fields for each member of
the collection (perhaps auto-generating a subscript?). A significant use
case is master-detail relationships (say, a customer and their current
orders) where you allow editing of any and all fields. [STRUTS-USER, Lars,
12/06/2000] [STRUTS-USER, Chandan Kulkarni, 12/26/2000]"

Niall

 -Original Message-
 From: Michael Mok [mailto:[EMAIL PROTECTED]]
 Sent: 11 April 2001 03:05
 To: [EMAIL PROTECTED]
 Subject: RE: POSTing arrays in struts


 Niall

 Do we still have to apply the patch to the iterate and text tags as you
 mentioned in your previous email or can we use STRUTS without your patch?

 "With my modified iterate and text ( BaseFieldTag) tags. This then
 causes Struts to generate appropriate method calls to populate the values
 back to the form [e.g. formExample.getBeanArray(0).setCode(..) etc.]"

 TIA

 Regards,

 Michael Mok







RE: Action Forms And Model objects

2001-04-12 Thread Niall Pemberton

We are currently building the following:

1) GenericActionForm with dynamic properties
2) Override ActionServlet to populate the GenericActionForm
3) Provide type validation  conversion mechanisms in the GenericActionForm
4) Provide mechanism to unload the GenericActionForm into GenericBeans

Our Actions initiate form validation, unload data into GenericBeans which
are then passed to our logic layer and I believe this will allow us to put
most of our effort into developing the JSP's and logic layer.

 -Original Message-
 From: Natra, Uday [mailto:[EMAIL PROTECTED]]
 Sent: 12 April 2001 20:17
 To: '[EMAIL PROTECTED]'
 Subject: Action Forms And Model objects


 Hi All,
 I want to know how you all are desiging the Datacopy from ActionForm Beans
 to actual Model objects. In my opinion ActionForms should have only String
 DataTypes(Dates are represented as strings). But the Model objects have
 actual Data Types since they represent the actual Domain objects. If it is
 the case, we need to write code to copy the contents of the
 ActionForm into
 the Domain Object as we cannot use the
 PropertyUtils.copyProperties(formBean, modelObject);

 Can anybody comment on this??

 Thanks,
 Uday.





RE: Action Forms And Model objects

2001-04-13 Thread Niall Pemberton

I'm still developing/debugging it at the moment so its fairly rudimentary at
the moment. I'm still considering how I could devlop it at the moment -
possibly your XML idea.

I have extended Action and done some stuff in the perform method to cast the
form and manage a connection and then call a processForm() method. Also it
handles control with standard success  failure forwards but I'm looking at
developing that as well - probably creating a transport object rather than
just returning a String message key.

A processForm() method validating input looks something like this:

  protected String processForm(HttpServletRequest request,
   HttpServletResponse response,
   GenericActionForm form,
   Connection connection) throws Exception {

// Validate the form
form.setRule("empl_id", true, form.INT);// required Integer
form.setRule("empl_name", true);// required String
form.setRule("empl_dob", true, form.DATE);  // required date
form.setRule("empl_married", form.BOOLEAN); // optional Boolean
if (form.validateProperties() != null) {
  return message;
}

// Store values from the form in GenericBean(s)
GenericBean bean = form.createBean();

// Process Business Logic
return message = new LogicBuildProgram().createBuildProgram(connection,
bean);
  }

 -Original Message-
 From: Rajan Gupta [mailto:[EMAIL PROTECTED]]
 Sent: 13 April 2001 13:32
 To: [EMAIL PROTECTED]
 Subject: RE: Action Forms And Model objects


 How do you store or manage your validation rules since your
 GenericActionForm could be validating fields types of forms?
 --- Niall Pemberton [EMAIL PROTECTED] wrote:
   Niall-
   To understand it a little better, does it mean that you do not allow
   ActionServlet to call the validate() method on your GenericActionForm
   since u do your validation in Action instead? Or I missed something!
 
  Yes.
 
   Also, do you store your validation rules in some type of a XML file or
   similar?
 
  No.
 
   Further, I would imagine that your Action itself checks with the model
  for
   any incorrect data in the form if it needs to?
 
  Yes.
 
   I guess u still derive GenericActionForm from ActionForm
 
  Yes.
 
   -Rajan
   --- Niall Pemberton [EMAIL PROTECTED] wrote:
Normally you extend ActionForm and implement getters/setters for
  each
property
e.g.public String getCustName()
public void setCustName(String name)
   
I have a GenericActionForm which has some standard getters/setters
e.g.public String getString(String property)
public void setString(String property, String value)
   
GenericActionForm stores these property/value pairs in internal
  arrays.
I
have customised ActionServlet to populate these and also customised
  some
of
the html tags to use the generic getter method if the form is an
instance
of my GenericActionForm.
   
I don't really know what you mean by "dynamic" validation of
  properties.
When processing a GenericActionForm in the Action you can set up
  rules
for
each of the properties to say whether it is required input and what
  data
type it should be. The form has a validate method to check whats
  been
received agaist those rules. Its not dynamic but it is straight
  forward.
   
If the above checks fail, I can then re-display the form with the
  values
entered. If the checks pass I can then safely populate the data into
beans
converting from Strings to the correct data types.
   
   
   
 -Original Message-
 From: Levi Cook [mailto:[EMAIL PROTECTED]]
 Sent: 13 April 2001 01:05
 To: [EMAIL PROTECTED]
 Subject: Re: Action Forms And Model objects


 Can you elaborate on what you mean by "dynamic" properties?

 How does this refer to dynamic validation of properties?

 -- Levi

 - Original Message -
 From: "Niall Pemberton" [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, April 12, 2001 5:58 PM
 Subject: RE: Action Forms And Model objects


  We are currently building the following:
 
  1) GenericActionForm with dynamic properties
  2) Override ActionServlet to populate the GenericActionForm
  3) Provide type validation  conversion mechanisms in the
 GenericActionForm
  4) Provide mechanism to unload the GenericActionForm into
GenericBeans
 
  Our Actions initiate form validation, unload data into
 GenericBeans which
  are then passed to our logic layer and I believe this will
 allow us to put
  most of our effort into developing the JSP's and logic layer.
 
   -Original Message-
   From: Natra, Uday [mailto:[EMAIL PROTECTED]]
   S

RE: Action Forms And Model objects

2001-04-14 Thread Niall Pemberton

JavaScript just makes the client side more interactive (which is good) but
it doesn't reduce the need to do stuff server side since for safety you
still need to repeat all the validation on the server side.

 -Original Message-
 From: Rajan Gupta [mailto:[EMAIL PROTECTED]]
 Sent: 14 April 2001 04:50
 To: [EMAIL PROTECTED]
 Subject: RE: Action Forms And Model objects


 ON 2nd thoughts, could one not achieve the results you are expecting using
 client side JavaScript?
 --- Rajan Gupta [EMAIL PROTECTED] wrote:
  Niall,
  I guess your formula does reduce coding for ActionsForms which require
  simple validation  do not need to access the model for any type of
  validation, but I think you will still have to write a class for every
  form where you will create your validation rules. This does not
  eliminate
  the total number of classes vs. the total number of classes required by
  Struts. Please correct me if I did not get this right.
 
  Maybe you could use XML-Schema to define every rules for every form.
  Rules
  can be associated based upon a form name which is handed over to
  ActionServlet using a request parameter. The GenericActionForm can load
  the XMLSchema for the form  validate the the form input. Regardless, it
  is good idea  definetly worth pursuing with a purpose of reducing the
  number of classes required in the application implementation.
 
  Rajan Gupta
 
  --- Niall Pemberton [EMAIL PROTECTED] wrote:
   I'm still developing/debugging it at the moment so its fairly
   rudimentary at
   the moment. I'm still considering how I could devlop it at the moment
  -
   possibly your XML idea.
  
   I have extended Action and done some stuff in the perform method to
  cast
   the
   form and manage a connection and then call a processForm() method.
  Also
   it
   handles control with standard success  failure forwards but I'm
  looking
   at
   developing that as well - probably creating a transport object rather
   than
   just returning a String message key.
  
   A processForm() method validating input looks something like this:
  
 protected String processForm(HttpServletRequest request,
  HttpServletResponse response,
  GenericActionForm form,
  Connection connection) throws Exception
  {
  
   // Validate the form
   form.setRule("empl_id", true, form.INT);// required Integer
   form.setRule("empl_name", true);// required String
   form.setRule("empl_dob", true, form.DATE);  // required date
   form.setRule("empl_married", form.BOOLEAN); // optional Boolean
   if (form.validateProperties() != null) {
 return message;
   }
  
   // Store values from the form in GenericBean(s)
   GenericBean bean = form.createBean();
  
   // Process Business Logic
   return message = new
   LogicBuildProgram().createBuildProgram(connection,
   bean);
 }
  
-Original Message-
From: Rajan Gupta [mailto:[EMAIL PROTECTED]]
Sent: 13 April 2001 13:32
To: [EMAIL PROTECTED]
Subject: RE: Action Forms And Model objects
   
   
How do you store or manage your validation rules since your
GenericActionForm could be validating fields types of forms?
--- Niall Pemberton [EMAIL PROTECTED] wrote:
  Niall-
  To understand it a little better, does it mean that you do not
   allow
  ActionServlet to call the validate() method on your
   GenericActionForm
  since u do your validation in Action instead? Or I missed
   something!

 Yes.

  Also, do you store your validation rules in some type of a XML
   file or
  similar?

 No.

  Further, I would imagine that your Action itself checks with the
   model
 for
  any incorrect data in the form if it needs to?

 Yes.

  I guess u still derive GenericActionForm from ActionForm
    
     Yes.
    
  -Rajan
  --- Niall Pemberton [EMAIL PROTECTED] wrote:
   Normally you extend ActionForm and implement getters/setters
  for
 each
   property
 e.g.public String getCustName()
 public void setCustName(String name)
  
   I have a GenericActionForm which has some standard
   getters/setters
 e.g.public String getString(String property)
 public void setString(String property, String value)
  
   GenericActionForm stores these property/value pairs in
  internal
 arrays.
   I
   have customised ActionServlet to populate these and also
   customised
 some
   of
   the html tags to use the generic getter method if the form
  is
   an
   instance
   of my GenericActionForm.
  
   I don't really know what you mean by "dynamic" validation of
 properties.
   When processing a GenericActionForm in the Action 

RE: Action Forms And Model objects

2001-04-14 Thread Niall Pemberton

No, I don't agree with you.

My model is unchanged, containing validation rules, whether I use my
approach or standard Struts stuff.

I wouldn't have any validation rules in ActionForms if a could help it
except for the fact that, initially you need to store input as Strings so
that you can re-display what they user keyed in in the event of an error.

Using GenericActionForm and GenericBean I get rid of all the ActionForms and
"data" beans I had previously and can concentrate on the view (JSP's) and
model. For me it was alot less classes.

Thanks for your interest.

Niall
 -Original Message-
 From: Rajan Gupta [mailto:[EMAIL PROTECTED]]
 Sent: 14 April 2001 01:46
 To: [EMAIL PROTECTED]
 Subject: RE: Action Forms And Model objects


 Niall,
 I guess your formula does reduce coding for ActionsForms which require
 simple validation  do not need to access the model for any type of
 validation, but I think you will still have to write a class for every
 form where you will create your validation rules. This does not eliminate
 the total number of classes vs. the total number of classes required by
 Struts. Please correct me if I did not get this right.

 Maybe you could use XML-Schema to define every rules for every form. Rules
 can be associated based upon a form name which is handed over to
 ActionServlet using a request parameter. The GenericActionForm can load
 the XMLSchema for the form  validate the the form input. Regardless, it
 is good idea  definetly worth pursuing with a purpose of reducing the
 number of classes required in the application implementation.

 Rajan Gupta

 --- Niall Pemberton [EMAIL PROTECTED] wrote:
  I'm still developing/debugging it at the moment so its fairly
  rudimentary at
  the moment. I'm still considering how I could devlop it at the moment -
  possibly your XML idea.
 
  I have extended Action and done some stuff in the perform method to cast
  the
  form and manage a connection and then call a processForm() method. Also
  it
  handles control with standard success  failure forwards but I'm looking
  at
  developing that as well - probably creating a transport object rather
  than
  just returning a String message key.
 
  A processForm() method validating input looks something like this:
 
protected String processForm(HttpServletRequest request,
 HttpServletResponse response,
 GenericActionForm form,
 Connection connection) throws Exception {
 
  // Validate the form
  form.setRule("empl_id", true, form.INT);// required Integer
  form.setRule("empl_name", true);// required String
  form.setRule("empl_dob", true, form.DATE);  // required date
  form.setRule("empl_married", form.BOOLEAN); // optional Boolean
  if (form.validateProperties() != null) {
return message;
  }
 
  // Store values from the form in GenericBean(s)
  GenericBean bean = form.createBean();
 
  // Process Business Logic
  return message = new
  LogicBuildProgram().createBuildProgram(connection,
  bean);
}
 
   -Original Message-
   From: Rajan Gupta [mailto:[EMAIL PROTECTED]]
   Sent: 13 April 2001 13:32
   To: [EMAIL PROTECTED]
   Subject: RE: Action Forms And Model objects
  
  
   How do you store or manage your validation rules since your
   GenericActionForm could be validating fields types of forms?
   --- Niall Pemberton [EMAIL PROTECTED] wrote:
 Niall-
 To understand it a little better, does it mean that you do not
  allow
 ActionServlet to call the validate() method on your
  GenericActionForm
 since u do your validation in Action instead? Or I missed
  something!
   
Yes.
   
 Also, do you store your validation rules in some type of a XML
  file or
 similar?
   
No.
   
 Further, I would imagine that your Action itself checks with the
  model
for
 any incorrect data in the form if it needs to?
   
Yes.
   
 I guess u still derive GenericActionForm from ActionForm
   
Yes.
   
 -Rajan
 --- Niall Pemberton [EMAIL PROTECTED] wrote:
  Normally you extend ActionForm and implement getters/setters for
each
  property
  e.g.public String getCustName()
  public void setCustName(String name)
 
  I have a GenericActionForm which has some standard
  getters/setters
  e.g.public String getString(String property)
  public void setString(String property, String value)
 
  GenericActionForm stores these property/value pairs in internal
arrays.
  I
  have customised ActionServlet to populate these and also
  customised
some
  of
  the html tags to use the generic getter method if the form is
  an
  instance
  of my GenericActionForm.
 
  I don't really know what you mean by "dynam

RE: Obtaining multiple values from dynamically generate textboxes

2001-04-27 Thread Niall Pemberton

Strut's tags could easily generate names of the format array[0].property
if a tag is embedded in an IterateTag. This would cause the appropriate bean
array to populate automatically - I have customised Struts to do this and it
works fine.

I have suggested this a couple of times but this has been totally ignored by
Struts comitters - I assume they don't like the suggestion but its
disappointing they are not prepared to discuss it -  must be an ego thing
;-)

http://www.mail-archive.com/struts-user@jakarta.apache.org/msg05231.html
http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg00975.html
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg06696.html

I also have a general comment that if the tags were more granular in their
design it would be easier to sub-class and modify behaviour - at the moment
most doStartTag() methods are just one lump of code.

Niall


 -Original Message-
 From: Walker, John H. [mailto:[EMAIL PROTECTED]]
 Sent: 27 April 2001 19:02
 To: '[EMAIL PROTECTED]'
 Subject: RE: Obtaining multiple values from dynamically generate
 textboxes


 Thanks for that,
 It would be nice if struts handled this scenario
 automatically - you could specify a prefix/suffix for a property
 and all the
 struts tags on a JSP that use the prefix/suffix in their property
 name will
 be concatenated into an array and one call will be made to a
 set/get  method
 based on the prefix/suffix only. e.g.

 html:select property=arrayTest1 . ..  /
 html:select property=arrayTest2  . . . /


 Form Bean
   getArrayTest(String[]); // the prefix is ArrayTest and the rest is
 stripped off
   setArrayTest(String[]);

 I noticed the struts source does have a concept of a prefix/suffix for a
 Http parameter but I am not sure what they are doing with it?

 The solution of looping thru the Http parameter list will work but I would
 like to keep my data collection in the form bean and not have to
 move it to
 the action bean.

 The get/set methods do not pass in the request object so I would have to
 save the request in a member variable to access it in the
 setMethod() which
 is not pretty.

 We have a solution that uses javascript to loop thru the multiple
 HTML text,
 select objects and copies the values to a hidden field as a delimited
 string. When the page is submitted the setHiddenField() is called
 passing in
 all the values as a concatenated string.


 JW

 -Original Message-
 From: Web Programmer [mailto:[EMAIL PROTECTED]]
 Sent: Friday, April 27, 2001 10:30 AM
 To: [EMAIL PROTECTED]
 Subject: RE: Obtaining multilpe values from dynamically generate
 textboxes


 See Scott Walker's response to my question earlier
 today which worked.  If you can't get it, post again.


 --- Gogineni, Pratima [EMAIL PROTECTED]
 wrote:
  Hi - I am doing something similar. Dont know if its
  the best way to do it.
 
  My form bean has an indexed property over a vector
  of values (so that its
  size can change dynamically ..)
  The form bean also has a size property which tells
  me how many values exist
  in the indexed property.
 
  in the JSP page
  I loop based on the size property and have
  html:text elements that display
  the indexed property in a text field.
 
  Pratima
 
  -Original Message-
  From: Walker, John H.
  [mailto:[EMAIL PROTECTED]]
  Sent: Friday, April 27, 2001 9:56 AM
  To: '[EMAIL PROTECTED]'
  Subject: Obtaining multilpe values from dynamically
  generate textboxes
 
 
  We have the senereo where we are dynamically
  generating a number of
  textfields. The number of textfields are not a known
  entity so we cannot
  have multiple setTextField1(), setTextField2()..
  . methods on the Action Form. How does struts handle
  this case where you
  basically want all the values of the textFields
  concatenated and passed into
  one Action Form method as an Array.
 
  Any ideas.
  Thanks
  John Walker


 __
 Do You Yahoo!?
 Yahoo! Auctions - buy the things you want at great prices
 http://auctions.yahoo.com/





RE: Iterate certain number of times?

2001-04-27 Thread Niall Pemberton

I know its not that elegant, but generate an array of page numbers in your
ActionForm based on the count

private int pageCount;

public String[] getPages() {

  String[] pages = new String[pageCount];

  for (int i = 0; i  pageCount; i++) {
int j = i + 1;
pages[i] = +j;
  }

  return pages;

}

Alternatively, write your own Tag which will look up a specified value in
your bean and loop the appropriate number of times.

Niall

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: 27 April 2001 20:29
 To: [EMAIL PROTECTED]
 Subject: Iterate certain number of times?




 Hi.

 Am wanting to iterate a certain number of times, based on a value
 in my form
 bean, to create a set of page links for the number of pages the
 user can view
 (similar to at the bottom of most search engine results).

 How do I do this with Struts?  Obviously I am not iterating over
 a collection.
 But surely it is possible - what am I missing?

 Many thanks,

 Dave








RE: i18n...

2001-04-27 Thread Niall Pemberton

I think your solution below should be a last resort - I would look first at
trying to cure the performance problem you have and only after lots of
effort consider the route you're proposing.

How many messages do you have in each of your four properties files?

Is the performance problem just the first time you access a message for a
given locale? Does it improve subsequent times you run your jsp for a
locale?

MessageResources stores all messages in a single HashMap using a combination
of the locale and message key. The first time a locale is used it attempts
to load the messages for that locale.

1) If the performance problem is just the first time perhaps you could put a
getMessage(locale, key) call for each of your four locales when
ActionServlet starts up so that all messages for your four locales are
loaded ready.

2) Perhaps the HaspMap is getting too large with all your messages for your
four locales. I have had a quick peek in Struts source and its been designed
so that if you want you can create your own implementation of
MessageResources. You could try and implement a storage mechanism which
suits your situation better or is more efficient than the Struts one.

Struts provides the PropertyMessageResources and
PropertyMessageResourcesFactory classes as concrete implementations of
MessageResources and MessageResourcesFactory and these are the default
classes it uses. To create your own you just need to provide your own
concrete implementations of these classes and have a factory parameter in
your web.xml file for the ActionServlet configuration.

Niall

P.S. Having a tag look up a key value is never going to be as efficient as
what your proposing, which is effectively hard coding your literals in html,
but it shouldn't be as slow as what you say.

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: 27 April 2001 23:34
 To: [EMAIL PROTECTED]
 Subject: Re: i18n...


 I hate to keep asking the same question but I haven't gotten any
 repsonse yet.

 One thought I have had is do do something like:

 if(en)
 {
   jsp:include file=english.jsp/
 }
 else (fr)
 {
   jsp:include file=french.jsp/
 }
 etc...

 What would be the performance drawbacks of something like this?


 --
 Jason Smith
 [EMAIL PROTECTED]

 - Original Message -
 From: [EMAIL PROTECTED]
 Date: Friday, April 27, 2001 12:53 pm
 Subject: i18n...

  I have a couple of questions.
 
  I had a JSP in which I had approximately 40 bean:message tags for
  i18n.
  This page was taking 15 seconds to load.  If I had two requests
  for the
  page at the same time it would take 45 to 60 seconds.  Obviously
  this is
  not acceptable.  When I replaced the bean:message tags with the
  text,
  the response time goes to a respectable 3 to 5 seconds with
  multiple
  hits.  Therefore, I have to come up with another method of
  internationalization.
 
  I am new to this so I am looking for suggestions.  I have to
  support 4
  languages.  My current thought is to detect the browser's settings
  and
  forward the request to the appropriate JSP that is specific to the
  language settings.  I'm not sure exactly where this should be
  done.  I
  would like it to be dynamic so that I can reuse FORM and ACTION
  beans
  for each related page.
 
  Again, any suggestions would be appreciated.
 
  --
  Jason Smith
  [EMAIL PROTECTED]
 
 






RE: html form widgets not appearing

2001-04-27 Thread Niall Pemberton

LoadLocale is in the PropertyMessageResources class - it doesn't trap an
error if it doesn't find your file.

You could copy this class (MyMessageResources) and put out some messages
showing the file name its trying to load and whether its sucessful. Also
copy the PropertyMessageResourcesFactory (MyMessageResourcesFactory) class
and change it to instantiate your MyMessageResources. Then change your
ActionServlet configuration in web.xml and set a factory parm to your
MyMessageResourcesFactory class. Struts then uses your classes for
MessageResources.

Niall

P.S. I don't think its finding your file.


-Original Message-
From: G.L. Grobe [mailto:[EMAIL PROTECTED]]
Sent: 28 April 2001 01:51
To: [EMAIL PROTECTED]
Subject: Re: html form widgets not appearing


The entire index.jsp file is included in this message so you can see the
html source at the end. I havn't actually re-compiled the struts.jar file to
see what was happening (because it wasn't easy to get working w/ orion
server) but just by looking at MessageTag.java, I could see where in
doStart() the message var came back as null and threw the exception when
trying to read the key. I saw the file it was trying to read was correct by
doing a println(getClass().getResource(my.properties)... in my jsp file.

I'll look at this loadLocale to see how and where to use it. Thnxs.
- Original Message -
From: Jason Chaffee
To: '[EMAIL PROTECTED]'
Sent: Friday, April 27, 2001 7:09 PM
Subject: RE: html form widgets not appearing


What does the html source look like?  You also might want to check the
method loadLocale() and make sure the message strings are being loaded from
the file.
-Original Message-
From: G.L. Grobe [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 27, 2001 5:11 PM
To: [EMAIL PROTECTED]
Subject: Re: html form widgets not appearing


Heh, I've been on this prob for almost two weeks and I'm loosing motivation
in this project because of this bug. My servlet config I believe is correct.
I made it as simple as possible by putting the cais.properties file in the
~/WEB-INF/classes dir (no package path) and saying:
!-- Action Servlet Configuration --
  servlet
servlet-nameaction/servlet-name
servlet-classorg.apache.struts.action.ActionServlet/servlet-class
init-param
  param-nameapplication/param-name
  param-valuecais/param-value
/init-param
Other keys are not being found as well. I know the correct file is being
found as I println the ...getClass().getResources(cais.properties) and it
shows it's got the correct path and according to the struts code, it's
finding the file, but not the key.
I'm pretty sure I'm referencing the key correclty:
 %@ page language=java %
%@ taglib uri=/WEB-INF/struts-bean.tld prefix=bean %
%@ taglib uri=/WEB-INF/struts-html.tld prefix=html %
html:html
head
title
   bean:message key=main.title /
/title
- Original Message -
From: Scott Cressler [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, April 27, 2001 6:58 PM
Subject: RE: html form widgets not appearing


 Well, at least now you know you're invoking the bean:message tag.  ;-)
 That's a problem I've found with debugging custom tags: if you forget the
 taglib directive or screw it up, you get no complaints.

 It seems to be saying it can't find your message by that key.  Can you
find
 any messages?  Do you have the correct reference to the properties file in
 your web.xml file, e.g.:

   !-- Action Servlet Configuration --
   servlet
 servlet-nameaction/servlet-name
 servlet-classorg.apache.struts.action.ActionServlet/servlet-class
 init-param
   param-nameapplication/param-name
   param-valuecom.propel.webapp.Resources/param-value
 /init-param

 In my case, that means the file is at
 webapproot/classes/com/propel/webapp/Resources.properties .  I don't
think
 it necessarily has to be there (isn't there some search path for finding
 it?), but that has worked for me (using resin).

 Make sure you can find any message and then make sure your tag is
 referencing the message key correctly, e.g., I would expect given what
 you've said it would be:

 bean:message key=main.title/

 Scott

  -Original Message-
  From: G.L. Grobe [mailto:[EMAIL PROTECTED]]
  Sent: Friday, April 27, 2001 4:51 PM
  To: [EMAIL PROTECTED]
  Subject: Re: html form widgets not appearing
 
 
  I don't get it, if I match prefix=struts-bean w/ a tag of
  bean:message
  key ...
  it can't find the keys in the properties file, which I'd say is to be
  expected. But if I change the prefix=bean w/ tags of
  bean:message ...
  making the prefix and tag the same like it should be, then I get the
  following error.
 
  500 Internal Server Error
  javax.servlet.jsp.JspException: Missing message for key main.title at
  org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag
  .java:242) at
  /index.jsp._jspService(/index.jsp.java:136) (JSP page line 9) at
  com.orionserver[Orion/1.4.8 (build
  

Implement HTTP and HTTPS in a safe, flexible, and easily maintainable manner

2002-02-21 Thread Niall Pemberton

This gives an example of how to integrate SSL into a Web App, using Struts
as an example.


http://www.javaworld.com/javaworld/jw-02-2002/jw-0215-ssl.html



winmail.dat
Description: application/ms-tnef

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


RE: Struts Basic/Pooling DataSource Vs Poolman

2002-04-02 Thread Niall Pemberton

I haven't used poolman, but isn't the problem with it that it is no longer
being developed?

Niall

 -Original Message-
 From: hemant [mailto:[EMAIL PROTECTED]]
 Sent: 01 April 2002 23:12
 To: struts
 Subject: Struts Basic/Pooling DataSource Vs Poolman


 I currently use poolman in my webapp. I was wondering if anyone
 got a chance to play with the classes in commons-dbcp.jar.

 How different are these from poolman?. I still dont think that
 Struts classes provide features such as resultset cache, periodic
 update of the cache with new data, query cache, Pool Management etc.

 Regards
 hemant







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




  1   2   3   >