Re: Problems with an inherited getter in a derived bean

2003-06-19 Thread Gareth Andrew
Hi,

Just for fun  I set up a little test app.  It demonstrates that the bug 
is definitely in Common Beanutils.  Normal Java relfection can call a 
method derived from a protected nested class without problems.  The 
problem seems to be in o/a/c/b/MethodUtils.java :  line 442ish where 
Beanutils checks the declaring class to see if its public - it should 
probably check the derived class instead ie clazz = method.getClass()

-MethodUtils.java - getAccessibleMethod(Method method) -

   // If the requested method is not public we cannot call it
   if (!Modifier.isPublic(method.getModifiers())) {
   return (null);
   }
   // If the declaring class is public, we are done
   Class clazz = method.getDeclaringClass();
   if (Modifier.isPublic(clazz.getModifiers())) {
   return (method);
   }
End--

As far as your problem goes the simplest fix seems to be write a public 
getName() method in Area and in its implementation call super.getName().
The alternative is to fix Beanutils (I haven't checked bugzilla so this 
might even be a recently fixed bug).  I'm cross-posting this to 
commons-dev to confirm that it is a bug since I may look at it a bit 
furthere and write a patch next week if I have the time.

Paul- Hope this helps
Alan - Hope this is of interest
Gareth.

PS.  I've also appended a quick test app I wrote

--scratchpad.java --

public class scratchpad {

   public static void main(String[] args) throws Exception{
   publicNestedClass test = new publicNestedClass();
  
   //Works - nested inheritance works ok
   //System.out.println(test.getMessage());
  
  
   //Doesn't work PropertyUtils bug
   //System.out.println((String)PropertyUtils.getProperty(test, 
"message"));
  
   Class c = publicNestedClass.class;
   Method m = c.getMethod("getMessage", null);
   if(m!=null){
   System.out.println("Method " + m.getName() + " of " + 
m.getDeclaringClass() + " found.");
   System.out.println("Method " + 
(Modifier.isPublic(m.getModifiers()) ? "is" : "isn't") + " public");
   System.out.println("Class " + 
(Modifier.isPublic(m.getClass().getModifiers()) ? "is" : "isn't") + " 
public");
   System.out.println("Declaring Class " + 
(Modifier.isPublic(m.getDeclaringClass().getModifiers()) ? "is" : 
"isn't") + " public");
   }
  
   System.out.println((String)m.invoke(test, null));
   }
  
   protected static class protectedNestedClass {
   public String getMessage(){
   return "Hello from a protected nested class";
   }
   }
  
   public static class publicNestedClass extends protectedNestedClass{
  
   }
}
---



Paul Harrison wrote:

thanks for confirming that this should work - one fact that I omitted 
in my original mailing was that the classes were inner classes

i.e. it  was the PostCode.Area class that is in the collection

public class PostCode
{
protected static class Pbase
   {
   protected String name;
   public String getName()
   {
   return name;
   }
   }
   public static class Area extends Pbase
   {
   }}
I works it I change the access on the Pbase class to public, but do I 
have to ? I thought that it was legal to have derived classes increase 
the accessibility - I do not want to expose the Pbase class - 
however this is pushing the limits of my knowledge about what should 
be happening.

Alen Ribic wrote:

I'm doing the same thing in my current project successfully.
No problems in my specializes class.
e.g.

public abstract class BaseBusinessBean
   implements java.io.Serializable {
   protected int id;
   protected String description;
   // getters/setters here
}
e.g.

public class Category
   extends BaseBusinessBean {
   // Category specific getters/setters
}
Now  I use Category class with no problem in my options for select box.

You have code ?

--Alen



- Original Message -
From: "Paul Harrison" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, June 18, 2003 4:55 PM
Subject: Problems with an inherited getter in a derived bean
 

In my struts application, I have a base bean with a set of basic
properties (e.g. name) and then I create various derived beans with
their own extra properties. I have a problem with the  
tag
in that if I try to read a property  that is inherited from the base
bean  from a collection of the derived beans

i.e. I have a tag like this



- I get an error saying

No getter method available for property name for bean under name
  
CountyList
 

and if I implement the getter in the derived bean the  error goes away.
Is this known behaviour in struts - is seems like a bug to me (or
perhaps a bug in commons-beanutils?) Can anyone comment

Re: [validator] arg0-arg3 elements need name attribute to displaymessage?

2003-06-08 Thread Gareth Andrew
David Graham wrote:

I'm glad someone is doing some work on the validator. And speaking of 
that,
I will most likely be using the validator extensively pretty soon in 
a new
application, which may result in some contributions. Are there 
specific bugs
or feature requests where help is needed?


You can query bugzilla for a list of current bugs and enhancements.  
I'm basically working alone on validator right now but Rob Leland has 
recently moved the Javascript stuff from Struts over to commons and 
added a UrlValidator.

Here are some things I'm planning for commons-validator 2.0:
- Move base Java requirement to 1.4.  I tested replacing all of the 
ORO classes with the Java 1.4 regex equivalents and there was a 50% 
speed increase.
Does that mean that future struts-1.x releases will be unable to use 
commons-validator 2.x without changing the Struts base requirements to 1.4?

Gareth.

- Change "form" and "field" semantics to "bean" and "property" to 
better align the validator with bean validation as opposed to form 
validation.  Forms are just a special case of bean validation.

I'm comfortable enough with the current changes to cut a 
commons-validator-1.1 release after Struts 1.1 goes final.  All help 
and contributions are welcome!

David




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


Re: DateUtilities for ActionForms?

2003-06-03 Thread Gareth Andrew
java.util.Date exists simply to *store* dates, the calendar class and 
the dateFormat class exist to *manipulate* dates.  java.sql.Date exists 
because SQL has different conventions for storing a date than the JVM.
The Java API docs for java.util.Date explain the deprecated methods.

"Prior to JDK 1.1, the class |Date| had two additional functions. It 
allowed the interpretation of dates as year, month, day, hour, minute, 
and second values. It also allowed the formatting and parsing of date 
strings. Unfortunately, the API for these functions was not amenable to 
internationalization. As of JDK 1.1, the |Calendar| class should be used 
to convert between dates and time fields and the |DateFormat| class 
should be used to format and parse date strings. The corresponding 
methods in |Date| are deprecated."

java.sql.Date is simply a java.util.Date object that has its hours, 
minutes, and seconds values set to zero since SQL DATEs do not have a 
time component.

In summary,

java.util.Date is the standard java API mechanism for storing a date.
java.sql.Date is a subclass of java.util.Date with a subset of the 
functionality designed to represent the functionality provided by a SQL 
DATE.
java.sql.Timestamp is a composite of Date and an extra nanoseccond value 
designed to represent the functionality provided by a SQL TIMESTAMP.

Gareth

Mark Galbreath wrote:

java.sql.Date is a subclass of java.util.Date (as is java.sql.TimeStamp) and
as far as I can see, is the only reason for the latter's existence.  As
David Flannigan points out in "Java In A Nutshell, 4th Ed" (O'Reilly 2002),
p. 654: "Since Java 1.1 many of the methods in the Date class have been
deprecated in favor of the methods of the Calendar class."  java.sql.Date
exists simply to pass milliseconds through JDBC to and from a database.
Mark
 



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


Re: DateUtilities for ActionForms?

2003-06-01 Thread Gareth Andrew
What are you talking about?  I assume you mean the java.util.Date 
class.  This class is anything but deprecated, it is the de facto method 
of storing a date in Java. The reason it has a lot of deprecated methods 
and constructors is that in 1.2 the class was extensively refactored 
with a lot of the functionality moved into helper classes such as 
Calender and DateFormat.  I hope this isn't why you are recommending 
java.sql.date over java.util.date.

Gareth.

Mark Galbreath wrote:

Why are you guys continuing to advocate the use of a deprecated class?  Look
at the API!
Mark

-Original Message-
From: Gareth Andrew [mailto:[EMAIL PROTECTED] 
Sent: Saturday, May 31, 2003 1:59 PM
To: Struts Users Mailing List
Subject: Re: DateUtilities for ActionForms?

If you want to use Locale aware conversions perhaps you should be using 
LocaleBeanUtils rather than BeanUtils.  You should be able to convert a 
string to a date as follows:

java.util.Date myDate = (java.util.Date)LocaleConvertUtils.convert("18 
Jan 2003", Class.forName("java.util.Date"));

If you change your form-properties to strings, copyProperties() should 
automagically do the String->Date conversion for you - although I think 
it uses toString() for Date->String so you'd need to use the DateFormat 
class and some locale information you have about the user 
(request.getLocale()?) to reformat the string.

Gareth



Mick Knutson wrote:

 

I looked at the javadocs, but I just can't seem to understand how to
use that. I looked at the struts source, but that is never used there.
Does anyone have a working example of this?


---
Thanks...
Mick Knutson
---




   

From: Gareth Andrew <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" 
<[EMAIL PROTECTED]>
To: Struts Users Mailing List <[EMAIL PROTECTED]>
Subject: Re: DateUtilities for ActionForms?
Date: Sat, 31 May 2003 18:23:27 +0100

Mick,

Have you tried using the BeanUtils converters. From the docs:

*org.apache.commons.beanutils.locale.converters.DateLocaleConverter
*
Standard |LocaleConverter| <cid:[EMAIL PROTECTED]>
implementation that converts an incoming locale-sensitive String into 
a |java.util.Date| object, optionally using a default value or 
throwing a |ConversionException| 
<cid:[EMAIL PROTECTED]> if a conversion error occurs.

It sounds like it might help, but I haven't used it before so i can't
comment.  At the very least the source might be useful if you decide 
you need to write your own DateUtilities.

HTH.

Gareth.

Mick Knutson wrote:

 

Is there already a set of DateUtilities for ActionForms?
I am finding myself converting to and from Strings and also
reformating my Dates to and from my DB.
I am using EntityBeans and ValueObjects with my ActionForms, so to
keep the types in synch, it seems I have to do serious conversion 
all the time.
Thanks in advance for the help.

---
Thanks...
Mick Knutson
---
_
The new MSN 8: smart spam protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail

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

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

_
Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
   



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


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



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


Re: DateUtilities for ActionForms?

2003-06-01 Thread Gareth Andrew
If you want to use Locale aware conversions perhaps you should be using 
LocaleBeanUtils rather than BeanUtils.  You should be able to convert a 
string to a date as follows:

java.util.Date myDate = (java.util.Date)LocaleConvertUtils.convert("18 
Jan 2003", Class.forName("java.util.Date"));

If you change your form-properties to strings, copyProperties() should 
automagically do the String->Date conversion for you - although I think 
it uses toString() for Date->String so you'd need to use the DateFormat 
class and some locale information you have about the user 
(request.getLocale()?) to reformat the string.

Gareth



Mick Knutson wrote:

I looked at the javadocs, but I just can't seem to understand how to 
use that. I looked at the struts source, but that is never used there.
Does anyone have a working example of this?



---
Thanks...
Mick Knutson
---




From: Gareth Andrew <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: Struts Users Mailing List <[EMAIL PROTECTED]>
Subject: Re: DateUtilities for ActionForms?
Date: Sat, 31 May 2003 18:23:27 +0100
Mick,

Have you tried using the BeanUtils converters. From the docs:

*org.apache.commons.beanutils.locale.converters.DateLocaleConverter
*
Standard |LocaleConverter| <cid:[EMAIL PROTECTED]> 
implementation that converts an incoming locale-sensitive String into 
a |java.util.Date| object, optionally using a default value or 
throwing a |ConversionException| 
<cid:[EMAIL PROTECTED]> if a conversion error occurs.

It sounds like it might help, but I haven't used it before so i can't 
comment.  At the very least the source might be useful if you decide 
you need to write your own DateUtilities.

HTH.

Gareth.

Mick Knutson wrote:

Is there already a set of DateUtilities for ActionForms?
I am finding myself converting to and from Strings and also 
reformating my Dates to and from my DB.

I am using EntityBeans and ValueObjects with my ActionForms, so to 
keep the types in synch, it seems I have to do serious conversion 
all the time.
Thanks in advance for the help.

---
Thanks...
Mick Knutson
---
_
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail

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



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
_
Help STOP SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail

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



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


Re: DateUtilities for ActionForms?

2003-06-01 Thread Gareth Andrew
Mick,

Have you tried using the BeanUtils converters. 
From the docs:

*org.apache.commons.beanutils.locale.converters.DateLocaleConverter
*
Standard |LocaleConverter|  
implementation that converts an incoming locale-sensitive String into a 
|java.util.Date| object, optionally using a default value or throwing a 
|ConversionException|  if a 
conversion error occurs.

It sounds like it might help, but I haven't used it before so i can't 
comment.  At the very least the source might be useful if you decide you 
need to write your own DateUtilities.

HTH.

Gareth.

Mick Knutson wrote:

Is there already a set of DateUtilities for ActionForms?
I am finding myself converting to and from Strings and also 
reformating my Dates to and from my DB.

I am using EntityBeans and ValueObjects with my ActionForms, so to 
keep the types in synch, it seems I have to do serious conversion all 
the time.
Thanks in advance for the help.

---
Thanks...
Mick Knutson
---
_
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail

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



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


Re: Can I have more than one properties file and retrieve from thembased on the context

2003-05-29 Thread Gareth Andrew
Hi,

Yup, you can have as many  entries in 
struts-conffig.xml as you want (each with a different 'key' attribute), 
then in  you can specify which properties file you want 
with the attribute bundle.

http://jakarta.apache.org/struts/userGuide/configuration.html#resources_config
http://jakarta.apache.org/struts/userGuide/struts-bean.html#message
HTH,

Gareth.

PS.  Does anyone know if referencing properties in web.xml like so

|application

   com.mycompany.mypackage.MyResources

|
deprecated by 

Hi,

  I am using struts  tag to retrieve messages from
properties file. I need to specify the properties file name in web.xml
for the action servlet. Can I have more than one properties file and
retrieve it from the properties file by specifying some identifier.
  For e.g., .

Regards,
Thiru
 



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


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


Re: The Action, the bean and the JSP

2003-05-27 Thread Gareth Andrew
Torsten Schlabach wrote:

Dear List,

I am working with Struts for some weeks now, but there are just some
concepts that don't become clear to me neither from the docs nor from all that
tutorials. They all stop where my questions start. So first of all, I would like
to ask the list for confirmation on what I found out / understood so far.
Is it right that in a web browser environment:
a) everyhting starts with a request coming in
b) and the result of that is some web page beeing rendered in the browser
c) all that Struts (and other methodologies for application login in such an
environment) are about taking the input from the request to somehow generate
the output being sent to the browser
d) The request - response thing is stateless meaning that while processing a
request neither myself nor the framework should care about the preceeding or
potential following requests (with the little exception of *optionally*
keeing a session state in some session content)
Working from that assumption, I exlained to myself that this is what happens
inside Struts when a request comes in:
- The ActionServlet determines the appropriate action from the
struts-config.xml.
- In case that action has a form bean associated with it, it instantiates
that form bean and fills it with the request parameters.
- After that it calls the execute method on the Action passing the (now
filled) form bean instance in as a parameter.
- The code in the execute method can read information from the FormBean, do
calculations, lookups, whatever and write results back into the form bean.
- The execute method returns control to the ActionServlet letting it know
which JSP page to render (choosing either from local or global forwards).
- The JSP page is rendered using the FormBean (still the same one?!?) as a
data source and sent back to the broser?
Am I right or wrong until here?
 

Sounds fairly correct.

In case I am right (and in case I am wrong, too), please help me understand:

- Why do I need to use a *forward* to display the output page? (My
understand of forward would be: I am being sent somewhere else than I originally
intended to go.) It would be much more logical to me if my  in
stuts-config.xml had a "output" attribute (similar to the "input" attribute) that names
the page that I want to use to render the results of the action.
 

Your definition of forward is closer to the definition of "redirect".  
Forwarding is just transferring control (usually to a JSP page to render 
the view).
The reason its possible to to forward to more than one location, rather 
than just a single "output" attribute is that the action may have 
different outputs depending on some logic (for example I have a search 
action which returns one of three forwards depending on whether 0,1 or 
multiple items are found).

- If the results page contains a form that has an action associated to it
that the user *might* fire by clicking "submit" on the rendered page (he or she
could as well use a link to go somewhere else) Struts will instantiate the
form bean for that potential request already before even rendering the page
containing the form that will enable the user to make that request later (or
leave it). What's the sense in here?
 

There are generally two actions involved in handling user input with forms.

Step 1.  The user follows a link to a page with a form - for example, 
Edit user details.

Request --> Action1 --> EditUserForm.jsp

Step 2.  The user hits the submit button after filling in the form.

Request --> Action2 --> confirmation.jsp

Both actions will be associated with same form  in the struts-config.xml 
- lets call it newUserForm.
Before calling Action1.execute() Struts will instantiate a new 
newUserForm and call execute. The action may then wish to preopulate 
this form with some data from the model ie. from the database.  In this 
case it will be the users current details.  The action then forwards to 
the EditUserForm.jsp via a local forward (if errors occurred when 
loading the user data or some flag was set or something then perhaps the 
action might forward to a different location :-).  The jsp can then 
render the filled in values as HTML form controls.
The Action form instantiated for Action2 will be populated with the 
values that were filled in by the user.  Action2 can then submit these 
to the database.

I am sure I got at least one concept wrong. Please enlighten me.

Torsten

 

Hope this helps (sorry if i spelled things out a bit slowly)

Gareth

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


Re: Loosing Objects in the Request.

2003-04-04 Thread Gareth Andrew
When faced with similar problems.  I forward to a quick and dirty jsp 
page to print out everything in the request.  This sometimes can provide 
the piece of magic inspiration thats solves the problem.
Don't know if it will help but here it is:

Begin request.jsp --

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


The contents of the request: 





AuthType

ContextPath

Header
   
   
   <%= 
((HttpServletRequest)req).getHeader((String)name) %>
   
   
   

Method

PathInfo

PathTranslated

QueryString

RemoteUser

RequestedSessionId

RequestURI

RequestURL


ServletPath


Attributes
  
   
   <%= req.getAttribute((String)name) %>
   
   
  


Parameters
  
   
   <%= req.getParameter((String)name) %>
   
   
  




End request.jsp -

Gareth.

Ps. it was designed for tiles so it doesn't have   or  tags.

Jindal, Ashwini wrote:

Max,

That is what the problem is I dont see the "test" in the request when it reaches the jsp. Now where and why does it lose is question?

...AJ

-Original Message-
From: Max Cooper [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 03, 2003 2:02 PM
To: Struts Users Mailing List
Subject: Re: Loosing Objects in the Request.
Are you certain that the request is getting to the JSP with the test in it?

-Max

- Original Message -
From: "Jindal, Ashwini" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 03, 2003 11:43 AM
Subject: Loosing Objects in the Request.
Hi All,

I am trying to set some attributes in the request object

  request.setAttribute("test", "TEST");

before invoking the forward:

  mapping.findForward(Constants.SUCCESS_KEY);

When I look up in the jsp:

   
 FOUND!
   
The implementation is in:

   public ActionForward execute(ActionMapping mapping, ActionForm form,
  HttpServletRequest request, HttpServletResponse response)
throws Exception
I do not find the object "test".

Any explanation???

..AJ

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




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



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


Re: Where to catch/throw Exceptions in Struts Tiered Architecture

2003-04-03 Thread Gareth Andrew
IMO, catch the database exception in user, then throw a new (wrapped) 
exception, catch it in UserAction and throw a new exception, and use 
struts decalritive exception handling features to handle it.  This 
avoids undue coupling between UserAction, User and Database.

Gareth.

Navjot Singh wrote:

Hi,

Take a simple case.

  Action
 Y
UserAction -> User -> Database
 |
V
 user.jsp
Say, Database throws exception. What is best way to handle exception?

1. Catch in User class and return NULL / some ErrorObject to UserAction and
let UserAction decide how to handle it?
2. Let User class __pass on__ the Exception from Database to UserAction.

2a. As execute() is already throwing Exception so it will handle ALL so Set
 handler that can send the user to some nice page?
2b. Catch Exception in UserAction and then do some thing ...
Which one do you guys follow in not-so-large scale web applications?

would appreciate any comments.
-navjot singh


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



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


Re: No action instance for path could be created

2003-04-02 Thread Gareth Andrew
Max, I'm curious as to whats wrong with using mixed case (camelCase) 
package names.  Obviously its better to remove any redundant words from 
package (or class, or object) names, but surely the advising someone to 
avoid mixed case package names is a little over prescriptive.

Gareth.

Your Action's fully qualified class name is src.ginsu.strutsApp.AddFileForm
but Struts will be looking for ginsu.strutsApp.AddFileAction.
I recommend removing src. from your package structure as it is probably a
mistake for it to be there. Many project directory structures have a 'src'
directory, but that should not be a part of the package name itself. Also,
avoid the use of mixed case package names, like 'strutsApp'. Simply using
'struts' or 'web' or something might be better.
-Max
 



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


Re: HELP: Dispaly Date in a JSP that used Tiles

2003-04-02 Thread Gareth Andrew
I'm not sure what you mean.  Perhaps if you e-mail me your code I could 
take a quick look at it.

Gareth.

Heligon Sandra wrote:

Your Javascript/DHTML knowledge knowledge is very good, your code
allows to display the date like a text and not like a field that
can be edited.
But I have yet a problem, with this code some controls (not all)
of my form do not stop moving.
what is this has?  
contrary to you my JavaScript knowledge is really basic. 
 
Thanks in advance

 

 



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


Re: No action instance for path could be created

2003-04-02 Thread Gareth Andrew
Could it be that your action class is in package:

package src.ginsu.strutsApp;

and in your struts-config.xml you are trying to load

type="ginsu.strutsApp.AddFileAction"

ie. package ginsu.strutsApp



Dan Tarkenton wrote:

Hello all.  I apologize for the size of this message,
but I thought it necessary to include some of my
source.  

I am trying to do a very basic thing here.  I trying
to pass form data to an Action object.  However i am
getting the following tomcat error, when I submit from
http://localhost:8080/ginsu/test/addFile.jsp :
*** Begin My Error ***

HTTP Status 500 - No action instance for path /addFile
could be created
type Status report

message No action instance for path /addFile could be
created
description The server encountered an internal error
(No action instance for path /addFile could be
created) that prevented it from fulfilling this
request.
*** End My error **

I have consulted both the Struts in Action book as
well as the struts-example web app.  I just don't see
where my problem resides.  So I thought it best to
consult you more experienced struts users.  My first
guess is that I have configured struts-config.xml
incorrectly.
I will first list my struts-config.xml file (which is
where I _think_ my error may be), my addFile.jsp (a
simple form), my AddFileForm (struts FormBean), and my
AddFileAction class (Struts Action). 

I hope you guys can see something obvious.  Here's
hoping.
* struts-config.xml ***



 "-//Apache Software Foundation//DTD Struts
Configuration 1.0//EN"

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



 
 
 

type="ginsu.strutsApp.ContentForm" />

type="ginsu.strutsApp.AddFileForm" />

 
 
 

 
   
   
 
 
 

   
  name="contentForm"> 
   
   
   
  name="addFileForm"
  input="/test/addFile.jsp"> 
 
   
   
 
type="org.apache.struts.actions.AddFormBeanAction"/>

   
 
type="org.apache.struts.actions.AddForwardAction"/>

   
 
type="org.apache.struts.actions.AddMappingAction"/>

   
 
type="org.apache.struts.actions.ReloadAction"/>

   
 
type="org.apache.struts.actions.RemoveFormBeanAction"/>

   
 
type="org.apache.struts.actions.RemoveForwardAction"/>

   
 
type="org.apache.struts.actions.RemoveMappingAction"/>

 



*** end struts-config.xml ***

And now my jsp form:

*** Begin addFile.jsp ***



 Add an XML File to Slide







 
   
 Filename:
   
   
 
   
 
 
   
 

 
   
 
   
   
 
   
 






** End addFile.jsp 

My FormBean:

** Begin AddFileForm.java *

package src.ginsu.strutsApp;

import org.apache.struts.action.*;

public class AddFileForm extends ActionForm {

   protected String filename = null;
   
   public String getFilename() {
   return this.filename;
   }
   
   public void setFilename(String filename) {
   this.filename = filename;
   }
   
}

** End AddFileForm.java 

And finally, My AddFileAction class:

** Begin AddFileAction.java 

package src.ginsu.strutsApp;

import ginsu.content.adapter.*;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.xml.transform.dom.DOMSource;
/**
*
* @author  tarkentond
*/
public class AddFileAction extends Action {
   
   public ActionForward perform (ActionMapping
mapping,
   ActionForm form,
   HttpServletRequest
request,
  
HttpServletResponse response) {
  
  AddFileForm addForm = (AddFileForm)form;
  String fullPath = addForm.getFilename();
  StringTokenizer tokenizer = new
StringTokenizer(fullPath, "/");
  Vector temp = new Vector();
  
  while (tokenizer.hasMoreTokens()) {
   temp.addElement(tokenizer.nextToken());
  }
  String slideFileName =
(String)temp.lastElement();

  
  String slideUri = "/files/" + slideFileName;
  
  try {
ContentAdapterImpl adapter = new
ContentAdapterImpl();
adapter.initDomain("ginsunamespace", "root");
   
adapter.createFile(new
FileInputStream(fullPath), slideUri);
DOMSource dom =
adapter.retrieveXml(slideUri);
request.setAttribute("dom", dom);
   
  } catch (Exception e) {
  
request.setAttribute("exception",
e.toString());  
  }
  return mapping.findForward("xslServlet");
   }
   
}

*** End AddFileAction.java 

Thanks in advance for your time and effort looking
over this long email.  

-Dan

__
Do you Yahoo

Re: HELP: Dispaly Date in a JSP that used Tiles

2003-04-02 Thread Gareth Andrew
It's about now I have to admit that my Javascript/DHTML knowledge is 
about 4 years out of date.  I have no idea how many browsers that this 
will work on, but it does seem to work on IE6.0 and Mozilla 1.3:

In your script replace:

document.myForm.dateControl.value=time;

with

document.getElementById("dateControl2").innerHTML=time;

and in your html/jsp replace :

   

with



Good luck,

Gareth

Heligon Sandra wrote:

Thank you very much for this explanation 
I have finally a solution which goes, after such an amount of time that
given pleasure. 
I still have nevertheless a very small problem. 
I would like to post the date like a label I don't want that the user can
edit it. 
Is this possible? by what can I replace the tag 
name="dateControl" size="30"/>.

My JSP:


   
	:
	
   
   
 
   
function aff_heure(){
var d=new Date();
var weekdays=new Array
("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var monthname=new Array
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
var weekday=weekdays[d.getDay()];
var date = d.getDate();
var month = monthname[d.getMonth()];
var year = d.getFullYear();
var hour = d.getHours();
var minute = d.getMinutes();
var second = d.getSeconds();
var time = new String(weekday + " " + date
+ "." + month + " " + year
+ ", " + hour + ":" + minute
+ ":" + second);
document.myForm.dateControl.value=time;
setTimeout("aff_heure()",100);
}
aff_heure();
Thanks a lot in advance. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: messages into struts 1.1

2003-04-02 Thread Gareth Andrew
I've just had a similar problem, recently. The docs seem to be a bit 
misleading (or perhaps the docs are right and theres a bug somewhere?).
 doesn't seem to do any actual writing, its just a form 
of iterator that loops through the specified messages and puts them in a 
page-scope attribute. To actually display them you need to use 
eg.




Note you may also need to set the message paramater of the html:message 
tag to "true" if you have created your messages using the 
ActionMessages.GLOBAL_MESSAGE key as the tag (confusingly) defaults to 
using ActionErrors.GLOBAL_ERROR

Hope this helps,

Gareth

[EMAIL PROTECTED] wrote:

Hi everyone,

Is anybody knows how to use messages system of struts. I just 
want to print some information on the user screen, so I use an 
ActionMessages object, then i fill it with ActionMessage, I 
save it, and in my jsp, I use the tag  in which messages is the name of my svaed 
object, but nothing is printed out? So perhaps I do not use 
correctly this?

Cheers
Pierre
Accédez au courrier électronique de La Poste : www.laposte.net ; 
3615 LAPOSTENET (0,34€/mn) ; tél : 08 92 68 13 50 (0,34€/mn)"



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



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


Re: HELP: Dispaly Date in a JSP that used Tiles

2003-04-02 Thread Gareth Andrew
Yup, the error is coming from

  

as it is looking for a FormBean called MyForm.
Instead use:


Heligon Sandra wrote:

thank you for your answer but when you say "just use plain html tags"
it is what I do with   isn't it ?
But it doesn't work because when I run my application I have the error
"javax.servlet.ServletException: Cannot find bean myForm in any scope".
Why ?
With the plain html tag form, who is responsible for creation of the
form instance ?


As of February 12th, 2003 Thomson unifies its email addresses on a worldwide
basis. 
Please note my new email address: [EMAIL PROTECTED] 

http://www.thomson.net/ 

----Original Message-
From: Gareth Andrew [mailto:[EMAIL PROTECTED]
Sent: 02 April 2003 11:10
To: Struts Users Mailing List
Subject: Re: HELP: Dispaly Date in a JSP that used Tiles
You don't need to create an ActionForm, since the form is never going to 
be submitted, and you don't need to be able to access the form 
information outside of the current page. So just use plain html tags 
instead of the struts-html tags.

Gareth.

Heligon Sandra wrote:

 

First, thanks a lot for your help.

I think indeed that this manner of making is better 
but I have a problem to set up it.
Because I must define a tag form. 

  


As I explained in my previous message I use Tiles all the
pages are composed of several modules header, menu, body and footer.
It is in the header module that I want to display the date,
for the moment the header.jsp page is the following:
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>



  

  
  
 
   
  




When I run the application I have an error no instance of MyForm
has been created.
I thus defined a DynaValidatorForm in struts-config.xml,and use the Struts
tag
. But when I compile the application I have the
following
message "action is mandatory for tag form".
But I don't want to associate an action to this page.
How can I do ?
Thanks a lot in advance
Sandra
---
   

-
 

As of February 12th, 2003 Thomson unifies its email addresses on a
   

worldwide
 

basis. 
Please note my new email address: [EMAIL PROTECTED] 

http://www.thomson.net/ 

Original Message-
From: Gareth Andrew [mailto:[EMAIL PROTECTED]
Sent: 02 April 2003 00:49
To: [EMAIL PROTECTED]
Subject: RE: HELP: Dispaly Date in a JSP that used Tiles
I think your problem has nothing to do with tiles or jsp.  You just need 
to write the output to a control instead of trying to write to the page.
If the browser were to allow your code to work as you have written it 
you would actually get a list of times.
The following code should work - it renders to a named textBox.

BEGINNING OF CODE SAMPLE --

<br>
 function aff_heure() {<br>
  var d=new Date()<br>
  var weekdays=new 
Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday<br>
   </tt><br>
<br>
</blockquote><tt>"<br>
 </tt><br>
<br>
<blockquote style="border-left: #FF solid 0.1em; margin: 0em; padding-left: 1.0em"><tt>)<br>
  var monthname=new 
Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","De<br>
   </tt><br>
<br>
</blockquote><tt>c<br>
 </tt><br>
<br>
<blockquote style="border-left: #FF solid 0.1em; margin: 0em; padding-left: 1.0em"><tt>")</tt><br>
<br>
<tt>   var weekday=weekdays[d.getDay()]<br>
   var date = d.getDate()<br>
   var month = monthname[d.getMonth()]<br>
  var year = d.getFullYear()<br>
  var hour = d.getHours()<br>
  var minute = d.getMinutes()<br>
  var second = d.getSeconds()<br>
   
   var time = new String(weekday + " " + date<br>
+ "." + month + " " + year<br>
+ ", " + hour + ":" + minute<br>
+ ":" + second)<br>
   document.myForm.dateControl.value=time;</tt><br>
<br>
<tt> 
  setTimeout("aff_heure()",100);<br>
 }</tt><br>
<br>
<tt>


  

END OF CODE SAMPLE --

Hope this helps,

Gareth

PS.  You can also render to put your answer in other html objects such 
as spans and divs but if you're trying to make it work on as many 
browsers as possible that might be a bit of a headache.
PPS.  Why not use d.toGMTString() or d.toLocaleString() instead of 
trying to format the string yourself?

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


   



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



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


Re: HELP: Dispaly Date in a JSP that used Tiles

2003-04-02 Thread Gareth Andrew
You don't need to create an ActionForm, since the form is never going to 
be submitted, and you don't need to be able to access the form 
information outside of the current page. So just use plain html tags 
instead of the struts-html tags.

Gareth.

Heligon Sandra wrote:

First, thanks a lot for your help.

I think indeed that this manner of making is better 
but I have a problem to set up it.
Because I must define a tag form. 

   


As I explained in my previous message I use Tiles all the
pages are composed of several modules header, menu, body and footer.
It is in the header module that I want to display the date,
for the moment the header.jsp page is the following:
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>


 
   

   
   
  

   
 



When I run the application I have an error no instance of MyForm
has been created.
I thus defined a DynaValidatorForm in struts-config.xml,and use the Struts
tag
. But when I compile the application I have the
following
message "action is mandatory for tag form".
But I don't want to associate an action to this page.
How can I do ?
Thanks a lot in advance
Sandra


As of February 12th, 2003 Thomson unifies its email addresses on a worldwide
basis. 
Please note my new email address: [EMAIL PROTECTED] 

http://www.thomson.net/ 

Original Message-
From: Gareth Andrew [mailto:[EMAIL PROTECTED]
Sent: 02 April 2003 00:49
To: [EMAIL PROTECTED]
Subject: RE: HELP: Dispaly Date in a JSP that used Tiles
I think your problem has nothing to do with tiles or jsp.  You just need 
to write the output to a control instead of trying to write to the page.
If the browser were to allow your code to work as you have written it 
you would actually get a list of times.
The following code should work - it renders to a named textBox.

BEGINNING OF CODE SAMPLE --

<br>
  function aff_heure() {<br>
   var d=new Date()<br>
   var weekdays=new 
Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"<br>
)<br>
   var monthname=new 
Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec<br>
")</tt><br>
<br>
<tt>var weekday=weekdays[d.getDay()]<br>
var date = d.getDate()<br>
var month = monthname[d.getMonth()]<br>
   var year = d.getFullYear()<br>
   var hour = d.getHours()<br>
   var minute = d.getMinutes()<br>
   var second = d.getSeconds()<br>

var time = new String(weekday + " " + date<br>
 + "." + month + " " + year<br>
 + ", " + hour + ":" + minute<br>
 + ":" + second)<br>
document.myForm.dateControl.value=time;</tt><br>
<br>
<tt>  
   setTimeout("aff_heure()",100);<br>
  }<br>
 



   

END OF CODE SAMPLE --

Hope this helps,

Gareth

PS.  You can also render to put your answer in other html objects such 
as spans and divs but if you're trying to make it work on as many 
browsers as possible that might be a bit of a headache.
PPS.  Why not use d.toGMTString() or d.toLocaleString() instead of 
trying to format the string yourself?

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



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


RE: HELP: Dispaly Date in a JSP that used Tiles

2003-04-01 Thread Gareth Andrew
I think your problem has nothing to do with tiles or jsp.  You just need 
to write the output to a control instead of trying to write to the page.
If the browser were to allow your code to work as you have written it 
you would actually get a list of times.
The following code should work - it renders to a named textBox.

BEGINNING OF CODE SAMPLE --


function aff_heure() {
var d=new Date()
var weekdays=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

var weekday=weekdays[d.getDay()]
var date = d.getDate()
var month = monthname[d.getMonth()]
var year = d.getFullYear()
var hour = d.getHours()
var minute = d.getMinutes()
var second = d.getSeconds()
var time = new String(weekday + " " + date
+ "." + month + " " + year
+ ", " + hour + ":" + minute
+ ":" + second)
document.myForm.dateControl.value=time;


setTimeout("aff_heure()",100);
}
END OF CODE SAMPLE -- Hope this helps, Gareth PS. You can also render to put your answer in other html objects such as spans and divs but if you're trying to make it work on as many browsers as possible that might be a bit of a headache. PPS. Why not use d.toGMTString() or d.toLocaleString() instead of trying to format the string yourself? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]