Struts test cases

2003-12-18 Thread Ovidiu EFTIMIE
Hi,
Has anyone used WSAD 5.0 with StrutsTestCase 2.0 ?
I've only succeded to make it work after several operation which don't inspire
me much confidence, or maybe is just me  taking  the hard way.
Is there anyone there who used this and can give me some hints?

Thanx,
Ovidiu

PS: For anyone interested here are the steps I took to make it work the way it
does

[1]. in setUp() add
setContextDirectory(new File(D:\\workspace\\strutsJunit\\jsp));
setConfigFile(/WEB-INF/struts-config.xml);
[2.]Replace the  servletunit.ServletContextSimulator getRessource() method
content with
try {
   return this.getClass().getResource(path);
 } catch (Exception e) {
  return null;
 }
[3.]execute ant to build a new strutstest-2.0.0.jar (the new one has 42K)
[4.]replace in the /WEB-INF/lib/ strutstest-2.0.0.jar (38K) with the new one
[5.]In your /WEB-INF/classes/ create a directory called /WEB-INF/ and copy
struts-config.xml and web.xml there
Run your tests


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



Targeted forward

2003-12-17 Thread Ovidiu EFTIMIE
Hi,
I have an abstract  base Action class which calls an abstract method called
executeAction. All my Actions implement the executeAction method.
//Snip from BaseAction class

public ActionForward execute(ActionMapping mapping,ActionForm
form,HttpServletRequest request,HttpServletResponse response)throws Exception {
ActionForward forward = null;
try {
forward = executeAction(mapping,form,request,response);
} catch (Exception e) {
ActionErrors errors= new ActionErrors();
ActionError error = null;

if(e instanceof BaseException){
BaseException lex = (BaseException)e;
error = new ErrorMessage(lex.getMessage());
forward = new ActionForward(mapping.getInput());
errors.add(lex.getType(),error);

}else{
if(e.getMessage() != null){
error = new ErrorMessage(e.getMessage());
}else{
error = new ErrorMessage(Constants.DEFAULT_MESSAGE);
}
forward = mapping.findForward(systemError);
errors.add(Constants.BLOCKING,error);
}
saveErrors(request,errors);
}
return forward;
}

//--end snip

So as you can see in case of exception I do a forward to the  input page. The
thing is that there are several cases in which I don't want forward to the
input, and that's beacuse I have a master page which triggers submits on an
iframe. So if there is an error in the iframe page the input (that means the
master page) will be displayed in the iframe ... and that wouldn't look very
nice.

So my question is:   is there any way that I can get the input page to be loaded
in the _parent and not in the iframe,  in case of an error?



Thanx,

Ovidiu


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



Re: [OT?] WebSphere and commons-logging

2003-12-17 Thread Ovidiu EFTIMIE
Hi,

Make a file called commons-logging.properties and add this line:

org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.Log4jFacto
ry

Put the file in your classpath



Ovidiu

- Original Message - 
From: Hibbs, David [EMAIL PROTECTED]
To: Struts-Users (E-mail) [EMAIL PROTECTED]
Sent: Wednesday, December 17, 2003 3:37 PM
Subject: [OT?] WebSphere and commons-logging


 For those who are using commons-logging (i.e all Struts users!) on
 WebSphere 4.0 or greater, you need to be aware that WebSphere comes with its
 own implementation of a commons-logging Log.  Not only that, but it comes
 with its own implementation of LogFactory... and a
 commons-logging.properties file that forces the use of the IBM Log.

 This isn't so bad in itself, but the IBM log swallows all log
 messages of a detail greater than info.  i.e. log.debug() and log.trace()
 messages disappear.  That would be fine if you could change the log level
 (as expected with commons-logging) and make them appear.  However, IBM
 support won't tell me how to change it!  As far as they know (and the pushed
 it back to level 3, i.e. the developers), it cannot be changed.  Thus,
 you're stuck at a log level of Info and using their logger unless you change
 your class loader mode to application first rather than parent first.  What
 a kludge!

 Instead of fixing the problem, they opened a feature request!
 Aaargh!  They're as bad as Sun!  If your log messages are important to you,
 along with the capability to change log levels and loggers without having to
 kludge a server setting, please visit their RFE database and vote for the
 RFE so as to get it through their thick skulls.  It requires a
 login/password, but it's a simple matter of signing up for one.

 To quote support, It is request # 241 and you can view it via this
 link : http://www7b.software.ibm.com/webapp/wsdd/wasServlet3. Development
 will evaluate and prioritize the requests (if chosen) to be included in
 future release of Websphere Application Server -- and if you have problems
 getting to the page, well, try again later.  Their website seems flaky.  Go
 figure.

 Thanks,

 --David

 David Hibbs, ACS
 Staff Programmer / Analyst
 Distributed Applications Development and Support
 American National Insurance Company


 -
 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: security pattern

2003-11-28 Thread Ovidiu EFTIMIE
Hi,
My suggestion is to use custom taglibs: one to check the user session and one to
check his role.
When the user logs in you can create a user bean which you'll store in the
session. In this user bean you can have a method called getRole().
So in  your taglib you'll have :

public int doStartTag() throws JspException{
MyContext ctx = new
MyContext((HttpServletRequest)pageContext.getRequest(),(HttpServletResponse)page
Context.getResponse()) ;
if(ctx.isAuthorized(getRole())){
return EVAL_BODY_AGAIN
}else{
return SKIP_BODY;
}
}
Where MyContext is your object on which you make the authorization procedure,
and role is an attribute to your custom tag.
Your tld will look like this :
tag
nameauthorized/name
tagclassmypackage.AuthorizedTag/tagclass
bodycontentJSP/bodycontent
attribute
namerole/name
requiredtrue/required
rtexprvaluetrue/rtexprvalue
/attribute
/tag
And in your jsp page you'll have :
auth:authorized role=A
!--your page content here--
/auth:authorized

It's not such a good ideea to hard code the roles in jsp page . A better aproach
will be to have insead of role an attribute called ressourceid, for example, a
NotAuthorized taglib,  and have your user bean load a black list and check if
the ressource the user is trying to access is not on his black list.


Ovidiu

- Original Message - 
From: Vano Beridze [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, November 28, 2003 4:57 PM
Subject: security pattern


 Hello
 I'm a new user to struts.

 What will be the best design pattern to achieve jsp pages protection in
 my web app?

 For instance I want to implement the following scenario.

 user A has a role RoleA
 user B has a role RoleB

 I have to pages:
 PageThatRequiresRoleA.jsp
 PageThatRequiresRoleB.jsp

 only user A must have an access to PageThatRequiresRoleA.jsp
 and
 only user B must have an access to PageThatRequiresRoleB.jsp

 Thank you very much

 Vano



 -
 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: Simulating multiple inheritance for Action and DispatchAction

2003-11-21 Thread Ovidiu EFTIMIE
I think that DispatchAction allows a better separation of code than an Action in
which the execute() method contains a if/else branch. I'll no longer need to
implement the if/else and I'm letting struts do that.

Regards,
Ovidiu

- Original Message - 
From: Daniel Joshua [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Friday, November 21, 2003 4:27 AM
Subject: RE: Simulating multiple inheritance for Action and DispatchAction


 Can I branch this of a bit.

 First, do you really need to use a DispatchAction?

 Would it be possible to just use an Action and in the execute() method to do
 a branching based on a request parameter.

 Are DispatchActions relly that useful?


 Regards,
 Daniel


 -Original Message-
 From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
 Sent: Thursday, 20 November, 2003 8:11 PM
 To: Struts Users Mailing List
 Subject: Simulating multiple inheritance for Action and DispatchAction


 Hi,
 In my application I need to have my Actions and my DispatchActions.
 Each one of this actions must have the same base class in which I have
 common
 methods to both of them.
 My solution is to first declare an interface IGeneral in which I'm declaring
 the
 common methods, then create an implementation class,GeneralImpl.Next thind
 to do
 would be to create my base classes BaseAction and BaseDispatchAction and
 this
 two must implement IGeneral, and in their implementation they should
 delegate to
 a private static member of type GeneralImpl, which will handle this methods.
 Example:
 code
 public interface IGeneral{
 public Connection getConnection() throws SQLException;
 ...
 public User getUser(HttpServletRequest req);
 }
 /code


 Then I'm creating the implementation for this methods:


 code
 public class GeneralImpl implements IGeneral{
 private ActionServlet servlet;
 public GeneralImpl(ActionServlet srv){
 servlet = srv;
 }
 public Connection getConnection() throws SQLException{
 //code here
 }
 ...
 public User getUser(HttpServletRequest req){
 //code here
 }
 }
 /code

 Now I create the base Actions

 code
 public abstract class BaseAction extends Action implements IGeneral {
 private static GeneralImpl general;
 public BaseAction (){
 general = new GeneralImpl(servlet);
 }
 public ActionForward execute(ActionMapping mapping,ActionForm
 form,HttpServletRequest request,HttpServletResponse response){
 return executeAction(ActionMapping mapping,ActionForm
 form,HttpServletRequest request,HttpServletResponse response)
 }
 public abstract executeAction(ActionMapping mapping,ActionForm
 form,HttpServletRequest request,HttpServletResponse response);
 public Connection getConnection() throws SQLException{
 return general.getConnection();
 }
 public User getUser(HttpServletRequest req){
 return general.getUser(req);
 }
 }
 /code
 The same for the DipatchAction.

 The question is anoybody has used something like this ? It this a good thing
 to
 do it ?

 Tanks in advance and sorry if  the text  it's too long
 Ovidiu


 -
 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: Map Backed Action Form

2003-11-20 Thread Ovidiu EFTIMIE
Look here 
http://puneetdelhi.tripod.com/
Designing Screens For Variable Number Of Fields


- Original Message - 
From: Agashivala, Vishal [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, November 20, 2003 7:17 AM
Subject: RE: Map Backed Action Form


 First up all I like to thanks Rick since you have reply. Basically I am new
 here..
 I tried to give all the details-
 Actually, I am trying to implement the common ActionForm which holds the
 value of the JSP/HTML fields. So then I did not need to implement the
 ActionForm for all my jsps. This ActionForm will pass it to common Action
 Class that will be responsible to handle all the events. For of now I need
 this much functionality. 
 To accomplish this I found out in the struts docs that you can use 'MAP
 BACKED ACTIONFORM' so then I have tried that as follows-
 
 //Common ActionForm-
 package com.web.controller;
 
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Iterator;
 import org.apache.struts.action.ActionForm;
 
 public class GenForm extends ActionForm 
 {
 private final Map values = new HashMap();
 
 public void GenForm()
 {
 System.out.println(GenForm Constructor);
 }
 public void setValue(String key, Object value)
 {
 System.out.println(Keys= + key +  ;value= + value);
 values.put(key, value);
 }
 
 public Object getValue(String key) {
 return values.get(key);
 }
 }
 
 //Common Action Class
 package com.web.controller;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.Enumeration;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 
 import org.apache.struts.action.Action;
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.action.ActionMapping;
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.config.impl.ModuleConfigImpl;
 
 import com.web.controller.GenForm;
 
 
 public class CommonEventHandler extends Action
 {
 
 public ActionForward execute(ActionMapping mapping, ActionForm form,
 HttpServletRequest request, HttpServletResponse response) throws Exception
 {
 System.out.println(reached here);
 
 if (form == null)
 {
 System.out.println(Action Form is null);
 }
 else
 {
 System.out.println(Action Form is Filled);
 
 }
  
 System.out.println(((GenForm)form).getValue(username));
 return null;
 }
 
 //struts-config Entries
   form-beans
 !-- Generic form bean --
 form-bean  name=GenForm
 type=com.web.controller.GenForm/
   /form-beans
 
   action-mappings
 actionpath=/button
type=com.web.controller.CommonEventHandler
   name=GenForm
   scope=request
validate=false
input=login.jsp
   forward name=failure path=/mainMenu.jsp/
   forward name=success   path=/jsps/t.jsp/
 /action
 
 //Login JSP
 HTML
 HEAD
 TITLELogin Page/TITLE
 /HEAD
 BODY
 Login
 BR
 FORM METHOD=POST ACTION=button
 Username:INPUT TYPE=text NAME=username
 Password:INPUT TYPE=text NAME=password
 INPUT TYPE=submit value=SignIn
 /FORM
 /BODY
 /HTML
 
 Now, for of now I have not coded forward and all.. If in the Action Class, I
 ll get fields value for username and password then I can go ahead. Control
 has reached upto CommonEventHandler Action class but ActionForm has not
 filled up with the username and password? 
 
 So, now my questions are -
 1. Is am I on a right track???
 2. Is this possible in Struts Framework what I need?
 3. Is there any other way around or any other framwork which I can use to
 accomplish my requirement?
 
 Kindly get back to me If you have any further queries. Expecting some one
 will help me in this struts world.
 
 Thanks and Regards,
 Vishal Agashivala
 
 -Original Message-
 From: Rick Reumann [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, November 19, 2003 10:20 PM
 To: Struts Users Mailing List
 Subject: Re: Map Backed Action Form
 
 
 Agashivala, Vishal wrote:
 
  Hi 
  Can anyone help me to implement MAP BACKED ACTION FORM???
  In this forum, I see 100 of mails but wht I am try to get 
 help on is not
  there..And NO ONE IS HERE TO HELP ME OUT?? AM I ASKING SOME 
 irrelevant info
  here?? If so atleast write to me so that i can think of other 
 way to work
  around..Atlest some one reply to my message
  Regards,
 
 Why don't you explain what you need help with? Like what you have tried 
 so far? What you want to accomplish? What isn't working? Anything would 
 be helpful to give us some direction. My first question would be why do 
 you want to back your form by a Map?
 
 -- 
 Rick
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: 

Re: Map Backed Action Form

2003-11-20 Thread Ovidiu EFTIMIE
In your Action, CommonEventHandler , you'll decide, based on tha value of a
certain field, which should be present in all your jsp and let's call it op,
what you should do . So for example
in your CommonEventHandler you'll have
  public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception
 {
GenForm gform = (GenForm)form;
String op = (String)gform.getValue(op);
if(op.equals(Signin)){
String login = (String)gform.getValue(login);
String password = (String)gform.getValue(password);
//do your stuff here
}else if(op.equals(Signout)){
..
}
}
So based on your op parameter you'll know what you have in your GenForm each
time you're executing CommonEventHandler.
That's a way to do it, but you could also have your CommonEventHandler extends
DispatchAction and implement this in a more clean way

Ovidiu



- Original Message - 
From: Agashivala, Vishal [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, November 20, 2003 10:09 AM
Subject: RE: Map Backed Action Form


 Hi
 I have checked the URL which you have suggested but there I did not find the
 example of accessing a field value of form in Action class. It only gives to
 use it JSP via html:text property=property(1)/.
 Can you give me some more information on the same?

 Thanks and Regards,
 Vishal Agashivala
 Atos Origin India
 O: +91-22-5691 3870


 -Original Message-
 From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
 Sent: Thursday, November 20, 2003 2:18 PM
 To: Struts Users Mailing List
 Subject: Re: Map Backed Action Form


 Look here
 http://puneetdelhi.tripod.com/
 Designing Screens For Variable Number Of Fields


 - Original Message - 
 From: Agashivala, Vishal [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Sent: Thursday, November 20, 2003 7:17 AM
 Subject: RE: Map Backed Action Form


  First up all I like to thanks Rick since you have reply.
 Basically I am new
  here..
  I tried to give all the details-
  Actually, I am trying to implement the common ActionForm
 which holds the
  value of the JSP/HTML fields. So then I did not need to implement the
  ActionForm for all my jsps. This ActionForm will pass it to
 common Action
  Class that will be responsible to handle all the events. For
 of now I need
  this much functionality.
  To accomplish this I found out in the struts docs that you
 can use 'MAP
  BACKED ACTIONFORM' so then I have tried that as follows-
 
  //Common ActionForm-
  package com.web.controller;
 
  import java.util.Map;
  import java.util.HashMap;
  import java.util.Iterator;
  import org.apache.struts.action.ActionForm;
 
  public class GenForm extends ActionForm
  {
  private final Map values = new HashMap();
 
  public void GenForm()
  {
  System.out.println(GenForm Constructor);
  }
  public void setValue(String key, Object value)
  {
  System.out.println(Keys= + key +  ;value= + value);
  values.put(key, value);
  }
 
  public Object getValue(String key) {
  return values.get(key);
  }
  }
 
  //Common Action Class
  package com.web.controller;
  import java.lang.reflect.Field;
  import java.lang.reflect.Method;
  import java.lang.reflect.Modifier;
  import java.util.Enumeration;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
 
 
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.config.impl.ModuleConfigImpl;
 
  import com.web.controller.GenForm;
 
 
  public class CommonEventHandler extends Action
  {
 
  public ActionForward execute(ActionMapping mapping,
 ActionForm form,
  HttpServletRequest request, HttpServletResponse response)
 throws Exception
  {
  System.out.println(reached here);
 
  if (form == null)
  {
  System.out.println(Action Form is null);
  }
  else
  {
  System.out.println(Action Form is Filled);
 
  }
 
  System.out.println(((GenForm)form).getValue(username));
  return null;
  }
 
  //struts-config Entries
form-beans
  !-- Generic form bean --
  form-bean  name=GenForm
  type=com.web.controller.GenForm/
/form-beans
 
action-mappings
  actionpath=/button
 type=com.web.controller.CommonEventHandler
name=GenForm
scope=request
 validate=false
 input=login.jsp
forward name=failure path=/mainMenu.jsp/
forward name=success   path=/jsps/t.jsp/
  /action
 
  //Login JSP
  HTML
  HEAD
  TITLELogin Page/TITLE
  /HEAD

Re: Map Backed Action Form

2003-11-20 Thread Ovidiu EFTIMIE
The jsp you're using for this example should contain the struts taglibs and
should look like this

html:form action=/login
  Login  html:text property=login/
   Password: html:password property=password/
/html:form

Ovidiu
- Original Message - 
From: Agashivala, Vishal [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, November 20, 2003 11:14 AM
Subject: RE: Map Backed Action Form


 See basically currently I am just testing so I know what key/value are there
 in that HASHMAP. So i am just directly querring the username and password
 but it did not show up the value which i v inserted in those field of JSPs
 rather it prints 'null' for both. So i dont know where I am wrong and is
 there any other setting / procedure i v to make. Is anything wrong in
 struts-config

 Regards,
 Vishal Agashivala
 Atos Origin India
 O: +91-22-5691 3870


 -Original Message-
 From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
 Sent: Thursday, November 20, 2003 3:13 PM
 To: Struts Users Mailing List
 Subject: Re: Map Backed Action Form


 In your Action, CommonEventHandler , you'll decide, based on
 tha value of a
 certain field, which should be present in all your jsp and
 let's call it op,
 what you should do . So for example
 in your CommonEventHandler you'll have
   public ActionForward execute(ActionMapping mapping, ActionForm form,
 HttpServletRequest request, HttpServletResponse response)
 throws Exception
  {
 GenForm gform = (GenForm)form;
 String op = (String)gform.getValue(op);
 if(op.equals(Signin)){
 String login = (String)gform.getValue(login);
 String password = (String)gform.getValue(password);
 //do your stuff here
 }else if(op.equals(Signout)){
 ..
 }
 }
 So based on your op parameter you'll know what you have in your
 GenForm each
 time you're executing CommonEventHandler.
 That's a way to do it, but you could also have your
 CommonEventHandler extends
 DispatchAction and implement this in a more clean way

 Ovidiu



 - Original Message - 
 From: Agashivala, Vishal [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Sent: Thursday, November 20, 2003 10:09 AM
 Subject: RE: Map Backed Action Form


  Hi
  I have checked the URL which you have suggested but there I
 did not find the
  example of accessing a field value of form in Action class.
 It only gives to
  use it JSP via html:text property=property(1)/.
  Can you give me some more information on the same?
 
  Thanks and Regards,
  Vishal Agashivala
  Atos Origin India
  O: +91-22-5691 3870
 
 
  -Original Message-
  From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
  Sent: Thursday, November 20, 2003 2:18 PM
  To: Struts Users Mailing List
  Subject: Re: Map Backed Action Form
 
 
  Look here
  http://puneetdelhi.tripod.com/
  Designing Screens For Variable Number Of Fields
 
 
  - Original Message - 
  From: Agashivala, Vishal [EMAIL PROTECTED]
  To: Struts Users Mailing List [EMAIL PROTECTED]
  Sent: Thursday, November 20, 2003 7:17 AM
  Subject: RE: Map Backed Action Form
 
 
   First up all I like to thanks Rick since you have reply.
  Basically I am new
   here..
   I tried to give all the details-
   Actually, I am trying to implement the common ActionForm
  which holds the
   value of the JSP/HTML fields. So then I did not need to
 implement the
   ActionForm for all my jsps. This ActionForm will pass it to
  common Action
   Class that will be responsible to handle all the events. For
  of now I need
   this much functionality.
   To accomplish this I found out in the struts docs that you
  can use 'MAP
   BACKED ACTIONFORM' so then I have tried that as follows-
  
   //Common ActionForm-
   package com.web.controller;
  
   import java.util.Map;
   import java.util.HashMap;
   import java.util.Iterator;
   import org.apache.struts.action.ActionForm;
  
   public class GenForm extends ActionForm
   {
   private final Map values = new HashMap();
  
   public void GenForm()
   {
   System.out.println(GenForm Constructor);
   }
   public void setValue(String key, Object value)
   {
   System.out.println(Keys= + key +  ;value= + value);
   values.put(key, value);
   }
  
   public Object getValue(String key) {
   return values.get(key);
   }
   }
  
   //Common Action Class
   package com.web.controller;
   import java.lang.reflect.Field;
   import java.lang.reflect.Method;
   import java.lang.reflect.Modifier;
   import java.util.Enumeration;
   import javax.servlet.http.HttpServletRequest;
   import javax.servlet.http.HttpServletResponse;
  
  
   import org.apache.struts.action.Action;
   import org.apache.struts.action.ActionForward;
   import org.apache.struts.action.ActionMapping;
   import org.apache.struts.action.ActionForm;
   import

Re: Map Backed Action Form

2003-11-20 Thread Ovidiu EFTIMIE
In fact the link I have sent you tells you, what you should add in the property
attribute :
html:text property=value(username)/
html:password property=value(password)/

try now.

Ovidiu


- Original Message - 
From: Agashivala, Vishal [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, November 20, 2003 11:55 AM
Subject: RE: Map Backed Action Form


 As you have suggested I have updated my jsp as shown below-
 BUT NOW it gives me error No getter method for property username of bean
 org.apache.struts.taglib.html.BEAN.. i think it tries to find the
 getUsername and getPassword.. And in my ActionForm bean has only getValue
 and setValue functions...How do i deal with this now?

 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN
 %@ taglib uri=/WEB-INF/tlds/struts-html.tld prefix=html %
 HTML
 HEAD
 TITLELogin Page/TITLE
 /HEAD
 BODY
 Login
 BR
 logic:equal name=GenForm property=action
 scope=request
 html:form method=post action=/button
 Username:html:text property=username/
 Password:html:password property=password/
 /logic:equal

 INPUT TYPE=submit value=SignIn
 /html:form
 /BODY
 /HTML

 Regards,
 Vishal Agashivala
 Atos Origin India
 O: +91-22-5691 3870


 -Original Message-
 From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
 Sent: Thursday, November 20, 2003 3:46 PM
 To: Struts Users Mailing List
 Subject: Re: Map Backed Action Form


 The jsp you're using for this example should contain the struts
 taglibs and
 should look like this

 html:form action=/login
   Login  html:text property=login/
Password: html:password property=password/
 /html:form

 Ovidiu
 - Original Message - 
 From: Agashivala, Vishal [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Sent: Thursday, November 20, 2003 11:14 AM
 Subject: RE: Map Backed Action Form


  See basically currently I am just testing so I know what
 key/value are there
  in that HASHMAP. So i am just directly querring the username
 and password
  but it did not show up the value which i v inserted in those
 field of JSPs
  rather it prints 'null' for both. So i dont know where I am
 wrong and is
  there any other setting / procedure i v to make. Is anything wrong in
  struts-config
 
  Regards,
  Vishal Agashivala
  Atos Origin India
  O: +91-22-5691 3870
 
 
  -Original Message-
  From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
  Sent: Thursday, November 20, 2003 3:13 PM
  To: Struts Users Mailing List
  Subject: Re: Map Backed Action Form
 
 
  In your Action, CommonEventHandler , you'll decide, based on
  tha value of a
  certain field, which should be present in all your jsp and
  let's call it op,
  what you should do . So for example
  in your CommonEventHandler you'll have
public ActionForward execute(ActionMapping mapping, ActionForm form,
  HttpServletRequest request, HttpServletResponse response)
  throws Exception
   {
  GenForm gform = (GenForm)form;
  String op = (String)gform.getValue(op);
  if(op.equals(Signin)){
  String login = (String)gform.getValue(login);
  String password = (String)gform.getValue(password);
  //do your stuff here
  }else if(op.equals(Signout)){
  ..
  }
  }
  So based on your op parameter you'll know what you have in your
  GenForm each
  time you're executing CommonEventHandler.
  That's a way to do it, but you could also have your
  CommonEventHandler extends
  DispatchAction and implement this in a more clean way
 
  Ovidiu
 
 
 
  - Original Message - 
  From: Agashivala, Vishal [EMAIL PROTECTED]
  To: Struts Users Mailing List [EMAIL PROTECTED]
  Sent: Thursday, November 20, 2003 10:09 AM
  Subject: RE: Map Backed Action Form
 
 
   Hi
   I have checked the URL which you have suggested but there I
  did not find the
   example of accessing a field value of form in Action class.
  It only gives to
   use it JSP via html:text property=property(1)/.
   Can you give me some more information on the same?
  
   Thanks and Regards,
   Vishal Agashivala
   Atos Origin India
   O: +91-22-5691 3870
  
  
   -Original Message-
   From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
   Sent: Thursday, November 20, 2003 2:18 PM
   To: Struts Users Mailing List
   Subject: Re: Map Backed Action Form
  
  
   Look here
   http://puneetdelhi.tripod.com/
   Designing Screens For Variable Number Of Fields
  
  
   - Original Message - 
   From: Agashivala, Vishal [EMAIL PROTECTED]
   To: Struts Users Mailing List [EMAIL PROTECTED]
   Sent: Thursday, November 20, 2003 7:17 AM
   Subject: RE: Map Backed Action Form
  
  
First up all I like to thanks Rick since you have reply.
   Basically I am new
here..
I tried to give all the details-
Actually, I am trying to implement the common ActionForm
   which holds the
value of the JSP/HTML fields. So then I did not need

Simulating multiple inheritance for Action and DispatchAction

2003-11-20 Thread Ovidiu EFTIMIE
Hi,
In my application I need to have my Actions and my DispatchActions.
Each one of this actions must have the same base class in which I have common
methods to both of them.
My solution is to first declare an interface IGeneral in which I'm declaring the
common methods, then create an implementation class,GeneralImpl.Next thind to do
would be to create my base classes BaseAction and BaseDispatchAction and this
two must implement IGeneral, and in their implementation they should delegate to
a private static member of type GeneralImpl, which will handle this methods.
Example:
code
public interface IGeneral{
public Connection getConnection() throws SQLException;
...
public User getUser(HttpServletRequest req);
}
/code


Then I'm creating the implementation for this methods:


code
public class GeneralImpl implements IGeneral{
private ActionServlet servlet;
public GeneralImpl(ActionServlet srv){
servlet = srv;
}
public Connection getConnection() throws SQLException{
//code here
}
...
public User getUser(HttpServletRequest req){
//code here
}
}
/code

Now I create the base Actions

code
public abstract class BaseAction extends Action implements IGeneral {
private static GeneralImpl general;
public BaseAction (){
general = new GeneralImpl(servlet);
}
public ActionForward execute(ActionMapping mapping,ActionForm
form,HttpServletRequest request,HttpServletResponse response){
return executeAction(ActionMapping mapping,ActionForm
form,HttpServletRequest request,HttpServletResponse response)
}
public abstract executeAction(ActionMapping mapping,ActionForm
form,HttpServletRequest request,HttpServletResponse response);
public Connection getConnection() throws SQLException{
return general.getConnection();
}
public User getUser(HttpServletRequest req){
return general.getUser(req);
}
}
/code
The same for the DipatchAction.

The question is anoybody has used something like this ? It this a good thing to
do it ?

Tanks in advance and sorry if  the text  it's too long
Ovidiu


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



Re: Simulating multiple inheritance for Action and DispatchAction

2003-11-20 Thread Ovidiu EFTIMIE
I agree with you regarding the leading I ;
I've implemented the setServlet method after sending the mail :)
Yes you're right about GeneralImpl it must be final .
I'm overiding execute just for BaseAction of course :), and I do it to catch
exception that are not applicational
Something like this
try{

forward = executeAction();
}catch(BaseException bex){
log.error(bex);
//to be catched by the handlers declared in struts-config.xml
throw bex
}catch(Exception ex){
ex.printStackTrace();
log.fatal(e);
}
return forward;

Ovidiu


- Original Message - 
From: Kris Schneider [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, November 20, 2003 2:13 PM
Subject: Re: Simulating multiple inheritance for Action and DispatchAction


The general approach is probably fine, although naming interfaces with a leading
I makes me gag ;-). However, this seems like a bad idea:

public abstract class BaseAction extends Action implements IGeneral {
  private static GeneralImpl general;
  public BaseAction() {
general = new GeneralImpl(servlet);
  }
...
}

Every time an instance of BaseAction is created, the *static* field general
gets reset. Also, where is BaseAction getting the servlet arg to pass to the
GeneralImpl constructor? Instead, perhaps:

public abstract class BaseAction extends Action implements IGeneral {
  private final IGeneral general;
  public BaseAction() {
this.general = new GeneralImpl();
  }
  public void setServlet(ActionServlet servlet) {
super.setServlet(servlet);
this.general.setServlet(sevlet);
  }
...
}

Of course, that means adding a setServlet method to IGeneral and GeneralImpl.
I'm also not sure why you'd override execute just to call executeAction. You
certainly wouldn't want to override DispatchAction's execute method, right?

Quoting Ovidiu EFTIMIE [EMAIL PROTECTED]:

 Hi,
 In my application I need to have my Actions and my DispatchActions.
 Each one of this actions must have the same base class in which I have
 common
 methods to both of them.
 My solution is to first declare an interface IGeneral in which I'm declaring
 the
 common methods, then create an implementation class,GeneralImpl.Next thind to
 do
 would be to create my base classes BaseAction and BaseDispatchAction and
 this
 two must implement IGeneral, and in their implementation they should delegate
 to
 a private static member of type GeneralImpl, which will handle this
 methods.
 Example:
 code
 public interface IGeneral{
 public Connection getConnection() throws SQLException;
 ...
 public User getUser(HttpServletRequest req);
 }
 /code


 Then I'm creating the implementation for this methods:


 code
 public class GeneralImpl implements IGeneral{
 private ActionServlet servlet;
 public GeneralImpl(ActionServlet srv){
 servlet = srv;
 }
 public Connection getConnection() throws SQLException{
 //code here
 }
 ...
 public User getUser(HttpServletRequest req){
 //code here
 }
 }
 /code

 Now I create the base Actions

 code
 public abstract class BaseAction extends Action implements IGeneral {
 private static GeneralImpl general;
 public BaseAction (){
 general = new GeneralImpl(servlet);
 }
 public ActionForward execute(ActionMapping mapping,ActionForm
 form,HttpServletRequest request,HttpServletResponse response){
 return executeAction(ActionMapping mapping,ActionForm
 form,HttpServletRequest request,HttpServletResponse response)
 }
 public abstract executeAction(ActionMapping mapping,ActionForm
 form,HttpServletRequest request,HttpServletResponse response);
 public Connection getConnection() throws SQLException{
 return general.getConnection();
 }
 public User getUser(HttpServletRequest req){
 return general.getUser(req);
 }
 }
 /code
 The same for the DipatchAction.

 The question is anoybody has used something like this ? It this a good thing
 to
 do it ?

 Tanks in advance and sorry if  the text  it's too long
 Ovidiu

-- 
Kris Schneider mailto:[EMAIL PROTECTED]
D.O.Tech   http://www.dotech.com/

-
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: Simulating multiple inheritance for Action and DispatchAction

2003-11-20 Thread Ovidiu EFTIMIE
For BaseException there is not really a need to catch it in BaseAction, because
I'll have a handler, but for Exception I don't know. Is it a good practice to
declare may own handler?

Ovidiu

- Original Message - 
From: Kris Schneider [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, November 20, 2003 4:02 PM
Subject: Re: Simulating multiple inheritance for Action and DispatchAction


Why not just declare handlers for *both* BaseException and Exception in
struts-config?

Quoting Ovidiu EFTIMIE [EMAIL PROTECTED]:

 I agree with you regarding the leading I ;
 I've implemented the setServlet method after sending the mail :)
 Yes you're right about GeneralImpl it must be final .
 I'm overiding execute just for BaseAction of course :), and I do it to
 catch
 exception that are not applicational
 Something like this
 try{

 forward = executeAction();
 }catch(BaseException bex){
 log.error(bex);
 //to be catched by the handlers declared in struts-config.xml
 throw bex
 }catch(Exception ex){
 ex.printStackTrace();
 log.fatal(e);
 }
 return forward;

 Ovidiu


 - Original Message - 
 From: Kris Schneider [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Sent: Thursday, November 20, 2003 2:13 PM
 Subject: Re: Simulating multiple inheritance for Action and DispatchAction


 The general approach is probably fine, although naming interfaces with a
 leading
 I makes me gag ;-). However, this seems like a bad idea:

 public abstract class BaseAction extends Action implements IGeneral {
   private static GeneralImpl general;
   public BaseAction() {
 general = new GeneralImpl(servlet);
   }
 ...
 }

 Every time an instance of BaseAction is created, the *static* field
 general
 gets reset. Also, where is BaseAction getting the servlet arg to pass to
 the
 GeneralImpl constructor? Instead, perhaps:

 public abstract class BaseAction extends Action implements IGeneral {
   private final IGeneral general;
   public BaseAction() {
 this.general = new GeneralImpl();
   }
   public void setServlet(ActionServlet servlet) {
 super.setServlet(servlet);
 this.general.setServlet(sevlet);
   }
 ...
 }

 Of course, that means adding a setServlet method to IGeneral and
 GeneralImpl.
 I'm also not sure why you'd override execute just to call executeAction.
 You
 certainly wouldn't want to override DispatchAction's execute method, right?

 Quoting Ovidiu EFTIMIE [EMAIL PROTECTED]:

  Hi,
  In my application I need to have my Actions and my DispatchActions.
  Each one of this actions must have the same base class in which I have
  common
  methods to both of them.
  My solution is to first declare an interface IGeneral in which I'm
 declaring
  the
  common methods, then create an implementation class,GeneralImpl.Next thind
 to
  do
  would be to create my base classes BaseAction and BaseDispatchAction and
  this
  two must implement IGeneral, and in their implementation they should
 delegate
  to
  a private static member of type GeneralImpl, which will handle this
  methods.
  Example:
  code
  public interface IGeneral{
  public Connection getConnection() throws SQLException;
  ...
  public User getUser(HttpServletRequest req);
  }
  /code
 
 
  Then I'm creating the implementation for this methods:
 
 
  code
  public class GeneralImpl implements IGeneral{
  private ActionServlet servlet;
  public GeneralImpl(ActionServlet srv){
  servlet = srv;
  }
  public Connection getConnection() throws SQLException{
  //code here
  }
  ...
  public User getUser(HttpServletRequest req){
  //code here
  }
  }
  /code
 
  Now I create the base Actions
 
  code
  public abstract class BaseAction extends Action implements IGeneral {
  private static GeneralImpl general;
  public BaseAction (){
  general = new GeneralImpl(servlet);
  }
  public ActionForward execute(ActionMapping mapping,ActionForm
  form,HttpServletRequest request,HttpServletResponse response){
  return executeAction(ActionMapping mapping,ActionForm
  form,HttpServletRequest request,HttpServletResponse response)
  }
  public abstract executeAction(ActionMapping
 mapping,ActionForm
  form,HttpServletRequest request,HttpServletResponse response);
  public Connection getConnection() throws SQLException{
  return general.getConnection();
  }
  public User getUser(HttpServletRequest req){
  return general.getUser(req);
  }
  }
  /code
  The same for the DipatchAction.
 
  The question is anoybody has used something like this ? It this a good
 thing
  to
  do it ?
 
  Tanks in advance and sorry

Re: Simulating multiple inheritance for Action and DispatchAction

2003-11-20 Thread Ovidiu EFTIMIE
In fact, in the catch(Exception ex) branch there should be a return
mapping.findForward(generalError); which I didn't include in the example .
But generally you're approach is better, and more appropriate.
Do yoy have any real examples on Exception handlers, or any links to which you
may point me ?

Thanks,
Ovidiu

- Original Message - 
From: Kris Schneider [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, November 20, 2003 4:36 PM
Subject: Re: Simulating multiple inheritance for Action and DispatchAction


Well, what if you don't provide a handler (or a standard servlet error page)? An
unhandled exception will be propogated to the container which will return a
status code 500 to your users. I wouldn't really call the resulting generic
internal server error user friendly.

BTW, your code for catching Exception just prints a stacktrace, logs a message,
and then falls through to return whatever forward has been set to (null?).

Quoting Ovidiu EFTIMIE [EMAIL PROTECTED]:

 For BaseException there is not really a need to catch it in BaseAction,
 because
 I'll have a handler, but for Exception I don't know. Is it a good practice
 to
 declare may own handler?

 Ovidiu

 - Original Message - 
 From: Kris Schneider [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Sent: Thursday, November 20, 2003 4:02 PM
 Subject: Re: Simulating multiple inheritance for Action and DispatchAction


 Why not just declare handlers for *both* BaseException and Exception in
 struts-config?

 Quoting Ovidiu EFTIMIE [EMAIL PROTECTED]:

  I agree with you regarding the leading I ;
  I've implemented the setServlet method after sending the mail :)
  Yes you're right about GeneralImpl it must be final .
  I'm overiding execute just for BaseAction of course :), and I do it to
  catch
  exception that are not applicational
  Something like this
  try{
 
  forward = executeAction();
  }catch(BaseException bex){
  log.error(bex);
  //to be catched by the handlers declared in struts-config.xml
  throw bex
  }catch(Exception ex){
  ex.printStackTrace();
  log.fatal(e);
  }
  return forward;
 
  Ovidiu
 
 
  - Original Message - 
  From: Kris Schneider [EMAIL PROTECTED]
  To: Struts Users Mailing List [EMAIL PROTECTED]
  Sent: Thursday, November 20, 2003 2:13 PM
  Subject: Re: Simulating multiple inheritance for Action and
 DispatchAction
 
 
  The general approach is probably fine, although naming interfaces with a
  leading
  I makes me gag ;-). However, this seems like a bad idea:
 
  public abstract class BaseAction extends Action implements IGeneral {
private static GeneralImpl general;
public BaseAction() {
  general = new GeneralImpl(servlet);
}
  ...
  }
 
  Every time an instance of BaseAction is created, the *static* field
  general
  gets reset. Also, where is BaseAction getting the servlet arg to pass
 to
  the
  GeneralImpl constructor? Instead, perhaps:
 
  public abstract class BaseAction extends Action implements IGeneral {
private final IGeneral general;
public BaseAction() {
  this.general = new GeneralImpl();
}
public void setServlet(ActionServlet servlet) {
  super.setServlet(servlet);
  this.general.setServlet(sevlet);
}
  ...
  }
 
  Of course, that means adding a setServlet method to IGeneral and
  GeneralImpl.
  I'm also not sure why you'd override execute just to call executeAction.
  You
  certainly wouldn't want to override DispatchAction's execute method,
 right?
 
  Quoting Ovidiu EFTIMIE [EMAIL PROTECTED]:
 
   Hi,
   In my application I need to have my Actions and my DispatchActions.
   Each one of this actions must have the same base class in which I have
   common
   methods to both of them.
   My solution is to first declare an interface IGeneral in which I'm
  declaring
   the
   common methods, then create an implementation class,GeneralImpl.Next
 thind
  to
   do
   would be to create my base classes BaseAction and BaseDispatchAction
 and
   this
   two must implement IGeneral, and in their implementation they should
  delegate
   to
   a private static member of type GeneralImpl, which will handle this
   methods.
   Example:
   code
   public interface IGeneral{
   public Connection getConnection() throws SQLException;
   ...
   public User getUser(HttpServletRequest req);
   }
   /code
  
  
   Then I'm creating the implementation for this methods:
  
  
   code
   public class GeneralImpl implements IGeneral{
   private ActionServlet servlet;
   public GeneralImpl(ActionServlet srv){
   servlet = srv;
   }
   public Connection getConnection() throws SQLException{
   //code here
   }
   ...
   public User getUser(HttpServletRequest req){
   //code here

Re: Simulating multiple inheritance for Action and DispatchAction

2003-11-20 Thread Ovidiu EFTIMIE
Thanks anyway.
In fact it would be a little bit difficult to use ExceptionHandler since it
doesn't have a reference to the servlet. And I'm gonna tell you why I need it
..:).
The so called GeneralImpl, implements a method to retrive error messages (based
on their code) from database(I'm not using any internationalization) using the
servlet context in which I'm storing an oracle connection pool
(OracleOciConnectionPool created using a plugin).

So all my error messages are retrivied from the database using this method (I
know there is DBRessources which can integrates with struts but my  requirements
are to use the same and only OCI connection pool used by the rest of the
application)

The only solution to use ExceptionHandler, as far as I can see, would be to
implement my own RequestProcessor and to modify processException method
something like this

processException(..){
...
 try {
ExceptionHandler handler = (ExceptionHandler)
RequestUtils.applicationInstance(config.getHandler());
if(handler instanceof MyHandler){
((MyHandler)handler).setServlet(servlet);
}
return (handler.execute(exception, config, mapping, form,
request, response));
} catch (Exception e) {
throw new ServletException(e);
}
}
and in MyHandler I'll have a method to get the error messages from the db and
the setServlet method.
What do you think ? It could work ?

Ovidiu

- Original Message - 
From: Kris Schneider [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, November 20, 2003 6:06 PM
Subject: Re: Simulating multiple inheritance for Action and DispatchAction


Sorry, nothing to point you to off the top of my head, except for the
struts-example app that ships with Struts. It illustrates the simplest usage:

action path=/logon
type=org.apache.struts.webapp.example.LogonAction
name=logonForm
scope=session
input=logon
  exception key=expired.password
 type=org.apache.struts.webapp.example.ExpiredPasswordException
 path=/changePassword.jsp/
/action

Here, the default handler (org.apache.struts.action.ExceptionHandler) is used so
the exception element omits the handler attribute. The default handler will
take the value of the key attribute and use it to construct an ActionError
instance. It will also use that key to add the error instance to an ActionErrors
instance that will be stored in either request or session scope under
Globals.ERROR_KEY. The default handler will then create an ActionForward based
on the value of the path attribute (or it will use mapping.getInputForward()
if path is not provided).

Hm, that's a lot of verbage for the simplest case ;-)...

Quoting Ovidiu EFTIMIE [EMAIL PROTECTED]:

 In fact, in the catch(Exception ex) branch there should be a return
 mapping.findForward(generalError); which I didn't include in the example
 .
 But generally you're approach is better, and more appropriate.
 Do yoy have any real examples on Exception handlers, or any links to which
 you
 may point me ?

 Thanks,
 Ovidiu

 - Original Message - 
 From: Kris Schneider [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Sent: Thursday, November 20, 2003 4:36 PM
 Subject: Re: Simulating multiple inheritance for Action and DispatchAction


 Well, what if you don't provide a handler (or a standard servlet error page)?
 An
 unhandled exception will be propogated to the container which will return a
 status code 500 to your users. I wouldn't really call the resulting generic
 internal server error user friendly.

 BTW, your code for catching Exception just prints a stacktrace, logs a
 message,
 and then falls through to return whatever forward has been set to
 (null?).

 Quoting Ovidiu EFTIMIE [EMAIL PROTECTED]:

  For BaseException there is not really a need to catch it in BaseAction,
  because
  I'll have a handler, but for Exception I don't know. Is it a good
 practice
  to
  declare may own handler?
 
  Ovidiu
 
  - Original Message - 
  From: Kris Schneider [EMAIL PROTECTED]
  To: Struts Users Mailing List [EMAIL PROTECTED]
  Sent: Thursday, November 20, 2003 4:02 PM
  Subject: Re: Simulating multiple inheritance for Action and
 DispatchAction
 
 
  Why not just declare handlers for *both* BaseException and Exception in
  struts-config?
 
  Quoting Ovidiu EFTIMIE [EMAIL PROTECTED]:
 
   I agree with you regarding the leading I ;
   I've implemented the setServlet method after sending the mail :)
   Yes you're right about GeneralImpl it must be final .
   I'm overiding execute just for BaseAction of course :), and I do it to
   catch
   exception that are not applicational
   Something like this
   try{
  
   forward = executeAction();
   }catch(BaseException bex){
   log.error(bex);
   //to be catched by the handlers

Re: Simulating multiple inheritance for Action and DispatchAction

2003-11-20 Thread Ovidiu EFTIMIE
Mea culpa ! ;) You're right ! The request 
 I must be very tired (I'm entering in the 11th hour of work now).
 I'll kick myself home now :)

Thanks,
Ovidiu


- Original Message - 
From: Kris Schneider [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Thursday, November 20, 2003 6:56 PM
Subject: Re: Simulating multiple inheritance for Action and DispatchAction


Okay, I'll keep playing ;-). The ExceptionHandler provides the following method:

public ActionForward execute(Exception ex,
 ExceptionConfig ae,
 ActionMapping mapping,
 ActionForm formInstance,
 HttpServletRequest request,
 HttpServletResponse response)
  throws ServletException

Don't you think there might be a way to get a handle to the ServletContext
through one of those args?

Quoting Ovidiu EFTIMIE [EMAIL PROTECTED]:

 Thanks anyway.
 In fact it would be a little bit difficult to use ExceptionHandler since it
 doesn't have a reference to the servlet. And I'm gonna tell you why I need
 it
 ..:).
 The so called GeneralImpl, implements a method to retrive error messages
 (based
 on their code) from database(I'm not using any internationalization) using
 the
 servlet context in which I'm storing an oracle connection pool
 (OracleOciConnectionPool created using a plugin).

 So all my error messages are retrivied from the database using this method
 (I
 know there is DBRessources which can integrates with struts but my
 requirements
 are to use the same and only OCI connection pool used by the rest of the
 application)

 The only solution to use ExceptionHandler, as far as I can see, would be to
 implement my own RequestProcessor and to modify processException method
 something like this

 processException(..){
 ...
  try {
 ExceptionHandler handler = (ExceptionHandler)
 RequestUtils.applicationInstance(config.getHandler());
 if(handler instanceof MyHandler){
 ((MyHandler)handler).setServlet(servlet);
 }
 return (handler.execute(exception, config, mapping, form,
 request, response));
 } catch (Exception e) {
 throw new ServletException(e);
 }
 }
 and in MyHandler I'll have a method to get the error messages from the db
 and
 the setServlet method.
 What do you think ? It could work ?

 Ovidiu

 - Original Message - 
 From: Kris Schneider [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Sent: Thursday, November 20, 2003 6:06 PM
 Subject: Re: Simulating multiple inheritance for Action and DispatchAction


 Sorry, nothing to point you to off the top of my head, except for the
 struts-example app that ships with Struts. It illustrates the simplest
 usage:

 action path=/logon
 type=org.apache.struts.webapp.example.LogonAction
 name=logonForm
 scope=session
 input=logon
   exception key=expired.password

 type=org.apache.struts.webapp.example.ExpiredPasswordException
  path=/changePassword.jsp/
 /action

 Here, the default handler (org.apache.struts.action.ExceptionHandler) is used
 so
 the exception element omits the handler attribute. The default handler
 will
 take the value of the key attribute and use it to construct an
 ActionError
 instance. It will also use that key to add the error instance to an
 ActionErrors
 instance that will be stored in either request or session scope under
 Globals.ERROR_KEY. The default handler will then create an ActionForward
 based
 on the value of the path attribute (or it will use
 mapping.getInputForward()
 if path is not provided).

 Hm, that's a lot of verbage for the simplest case ;-)...

 Quoting Ovidiu EFTIMIE [EMAIL PROTECTED]:

  In fact, in the catch(Exception ex) branch there should be a return
  mapping.findForward(generalError); which I didn't include in the
 example
  .
  But generally you're approach is better, and more appropriate.
  Do yoy have any real examples on Exception handlers, or any links to
 which
  you
  may point me ?
 
  Thanks,
  Ovidiu
 
  - Original Message - 
  From: Kris Schneider [EMAIL PROTECTED]
  To: Struts Users Mailing List [EMAIL PROTECTED]
  Sent: Thursday, November 20, 2003 4:36 PM
  Subject: Re: Simulating multiple inheritance for Action and
 DispatchAction
 
 
  Well, what if you don't provide a handler (or a standard servlet error
 page)?
  An
  unhandled exception will be propogated to the container which will return
 a
  status code 500 to your users. I wouldn't really call the resulting
 generic
  internal server error user friendly.
 
  BTW, your code for catching Exception just prints a stacktrace, logs a
  message,
  and then falls through to return whatever forward has been set to
  (null?).
 
  Quoting Ovidiu EFTIMIE [EMAIL PROTECTED

DTO pattern and WrapDynaBean

2003-11-14 Thread Ovidiu EFTIMIE
 Hi,
I've used until now the DTO pattern to transfer data from action forms to the
bussines layer , but I was wondering if using WrapDynaBean (that I've just
discovered) to wrap the action form an to pass it in a DAO class would have
a major inpact on performance.

For example:
=== in an Action (DocumentAction)

DocumentForm dcForm = (DocumentForm)form;
DynaBean wrp = new WrapDynaBean(dcForm);

DocumentDAO dbo = new DocumentDAO();

dom.insertDocument(getConnection(),wrp);


===and then in the DAO class
public int insertDocument(Connection conn, DynaBean data){
StringBuffer sbf = new StringBuffer();
sbf.append(insert ..).appen(data.get(title)).append(,)
 .append(data.get(author)).append());

}
So the basic ideea is to use the wrapped ActionForm as a DTO.
Anyone has any comments?
Thanx
Ovidiu

ps: I'm reposting this beacause yesterday our mail server had some problems and
I'm not sure it was really posted on the list


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



DTO pattern and WrapDynaBean

2003-11-14 Thread Ovidiu EFTIMIE
 Hi,
I've used until now the DTO pattern to transfer data from action forms to the
bussines layer , but I was wondering if using WrapDynaBean (that I've just
discovered) to wrap the action form an to pass it in a DAO class would have
a major inpact on performance.

For example:
=== in an Action (DocumentAction)

DocumentForm dcForm = (DocumentForm)form;
DynaBean wrp = new WrapDynaBean(dcForm);

DocumentDAO dbo = new DocumentDAO();

dom.insertDocument(getConnection(),wrp);


===and then in the DAO class
public int insertDocument(Connection conn, DynaBean data){
StringBuffer sbf = new StringBuffer();
sbf.append(insert ..).appen(data.get(title)).append(,)
 .append(data.get(author)).append());

}

Anyone has any comments?
Thanx
Ovidiu

ps: I'm reposting this beacause yesterday our mail server had some problems and
I'm not sure it was really posted on the list


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



Re: DTO pattern and WrapDynaBean

2003-11-14 Thread Ovidiu EFTIMIE
Yes, I know it holds the reference, but it could be a reference to any other
JavaBean. The only thing that will be tied with the Bussines Layer will be
commons-beanutils.jar. The ideea is to avoid creating new data transfer objects;
so the real debate here is that if the overhead added by getting the data in the
bussines layer, using reflection/introspection, is smaller than the overhead
added by creating another object and filling it with the data obtained from the
ActionForm and retriving this data in the bussines layer.

Ovidiu

- Original Message - 
From: Sumit S. [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Friday, November 14, 2003 10:07 AM
Subject: RE: DTO pattern and WrapDynaBean


I have'nt benchmarked the perf, but for our app we were not comfortable with
having the struts libs in the Application layer...The WrapDynaBean holds the
instance of the Action form and hence has references to the struts libs.

Sumit

-Original Message-
From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
Sent: Friday, November 14, 2003 2:05 PM
To: Struts Users Mailing List
Subject: DTO pattern and WrapDynaBean


 Hi,
I've used until now the DTO pattern to transfer data from action forms to the
bussines layer , but I was wondering if using WrapDynaBean (that I've just
discovered) to wrap the action form an to pass it in a DAO class would have
a major inpact on performance.

For example:
=== in an Action (DocumentAction)

DocumentForm dcForm = (DocumentForm)form;
DynaBean wrp = new WrapDynaBean(dcForm);

DocumentDAO dbo = new DocumentDAO();

dom.insertDocument(getConnection(),wrp);


===and then in the DAO class
public int insertDocument(Connection conn, DynaBean data){
StringBuffer sbf = new StringBuffer();
sbf.append(insert ..).appen(data.get(title)).append(,)
 .append(data.get(author)).append());

}
So the basic ideea is to use the wrapped ActionForm as a DTO.
Anyone has any comments?
Thanx
Ovidiu

ps: I'm reposting this beacause yesterday our mail server had some problems and
I'm not sure it was really posted on the list


-
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: DTO pattern and WrapDynaBean

2003-11-14 Thread Ovidiu EFTIMIE
Ok, I've understood your concern, and you're right.
Is better to pass the data to a clean DynaBean and this bean to the bussines
layer.
I suppose you're using RowSetDynaClass to create the DynaBeans in the appserver
layer, and I'm planning tu use the same method, but is it really necessary to
use another Value Objet to pass data ?

Ovidiu

- Original Message - 
From: Sumit S. [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Friday, November 14, 2003 11:19 AM
Subject: RE: DTO pattern and WrapDynaBean


The only thing that will be tied with the Bussines Layer will be
commons-beanutils.jar.
What about the struts libs ? The ActionForm will be the Bean that is wrapped
inside the DynaBean and it has refs to the struts as well as servlets
package

Perfromance ..as mentioned we have not yest benchmarked but we have not had any
noticeable impact no the performance of the system when using DynaBeans...We are
using them in the appserver layer though for transferring data from a resultset
into a DynaBean and from there to a Value Object.

Sumit

-Original Message-
From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
Sent: Friday, November 14, 2003 2:54 PM
To: Struts Users Mailing List
Subject: Re: DTO pattern and WrapDynaBean


Yes, I know it holds the reference, but it could be a reference to any other
JavaBean. The only thing that will be tied with the Bussines Layer will be
commons-beanutils.jar. The ideea is to avoid creating new data transfer objects;
so the real debate here is that if the overhead added by getting the data in the
bussines layer, using reflection/introspection, is smaller than the overhead
added by creating another object and filling it with the data obtained from the
ActionForm and retriving this data in the bussines layer.

Ovidiu

- Original Message - 
From: Sumit S. [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Friday, November 14, 2003 10:07 AM
Subject: RE: DTO pattern and WrapDynaBean


I have'nt benchmarked the perf, but for our app we were not comfortable with
having the struts libs in the Application layer...The WrapDynaBean holds the
instance of the Action form and hence has references to the struts libs.

Sumit

-Original Message-
From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
Sent: Friday, November 14, 2003 2:05 PM
To: Struts Users Mailing List
Subject: DTO pattern and WrapDynaBean


 Hi,
I've used until now the DTO pattern to transfer data from action forms to the
bussines layer , but I was wondering if using WrapDynaBean (that I've just
discovered) to wrap the action form an to pass it in a DAO class would have
a major inpact on performance.

For example:
=== in an Action (DocumentAction)

DocumentForm dcForm = (DocumentForm)form;
DynaBean wrp = new WrapDynaBean(dcForm);

DocumentDAO dbo = new DocumentDAO();

dom.insertDocument(getConnection(),wrp);


===and then in the DAO class
public int insertDocument(Connection conn, DynaBean data){
StringBuffer sbf = new StringBuffer();
sbf.append(insert ..).appen(data.get(title)).append(,)
 .append(data.get(author)).append());

}
So the basic ideea is to use the wrapped ActionForm as a DTO.
Anyone has any comments?
Thanx
Ovidiu

ps: I'm reposting this beacause yesterday our mail server had some problems and
I'm not sure it was really posted on the list


-
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]


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



Re: DTO pattern and WrapDynaBean

2003-11-14 Thread Ovidiu EFTIMIE
Thanks for clearing this out for me.
I don't have complex forms, so I'll stick to using BasicDynaBeans as VO.

thanks,
Ovidiu
- Original Message - 
From: Sumit S. [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Friday, November 14, 2003 11:45 AM
Subject: RE: DTO pattern and WrapDynaBean


We have nested level of objects on the UI...For eg ...each Form has an ArrayList
that holds Objects with properties...If we were to use DynaForms, displaying
data was okay but bringing it back from the browser was a problem because Struts
would construct a DynaBean with an ArrayList with no clue whatsoever about the
objects that need to be inside the ArrayList.

So we had to write our own ValueObjects that we embedded inside the
actionForms..and since we anyways had the VOs we decided to avoid the overhead
of Introspection/reflection.

On the read from DB in order to avoid writing code like
resultSet.getInt(age) we are using the RowSetDynabeans to populate data from
the resultSet and then use the PropertyUtils to transfer the data to our VO.
Slightly expensive but the tradeoff point was the reduced level of effort.

Sumit



-Original Message-
From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
Sent: Friday, November 14, 2003 4:07 PM
To: Struts Users Mailing List
Subject: Re: DTO pattern and WrapDynaBean


Ok, I've understood your concern, and you're right.
Is better to pass the data to a clean DynaBean and this bean to the bussines
layer.
I suppose you're using RowSetDynaClass to create the DynaBeans in the appserver
layer, and I'm planning tu use the same method, but is it really necessary to
use another Value Objet to pass data ?

Ovidiu

- Original Message - 
From: Sumit S. [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Friday, November 14, 2003 11:19 AM
Subject: RE: DTO pattern and WrapDynaBean


The only thing that will be tied with the Bussines Layer will be
commons-beanutils.jar.
What about the struts libs ? The ActionForm will be the Bean that is wrapped
inside the DynaBean and it has refs to the struts as well as servlets
package

Perfromance ..as mentioned we have not yest benchmarked but we have not had any
noticeable impact no the performance of the system when using DynaBeans...We are
using them in the appserver layer though for transferring data from a resultset
into a DynaBean and from there to a Value Object.

Sumit

-Original Message-
From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
Sent: Friday, November 14, 2003 2:54 PM
To: Struts Users Mailing List
Subject: Re: DTO pattern and WrapDynaBean


Yes, I know it holds the reference, but it could be a reference to any other
JavaBean. The only thing that will be tied with the Bussines Layer will be
commons-beanutils.jar. The ideea is to avoid creating new data transfer objects;
so the real debate here is that if the overhead added by getting the data in the
bussines layer, using reflection/introspection, is smaller than the overhead
added by creating another object and filling it with the data obtained from the
ActionForm and retriving this data in the bussines layer.

Ovidiu

- Original Message - 
From: Sumit S. [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Friday, November 14, 2003 10:07 AM
Subject: RE: DTO pattern and WrapDynaBean


I have'nt benchmarked the perf, but for our app we were not comfortable with
having the struts libs in the Application layer...The WrapDynaBean holds the
instance of the Action form and hence has references to the struts libs.

Sumit

-Original Message-
From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
Sent: Friday, November 14, 2003 2:05 PM
To: Struts Users Mailing List
Subject: DTO pattern and WrapDynaBean


 Hi,
I've used until now the DTO pattern to transfer data from action forms to the
bussines layer , but I was wondering if using WrapDynaBean (that I've just
discovered) to wrap the action form an to pass it in a DAO class would have
a major inpact on performance.

For example:
=== in an Action (DocumentAction)

DocumentForm dcForm = (DocumentForm)form;
DynaBean wrp = new WrapDynaBean(dcForm);

DocumentDAO dbo = new DocumentDAO();

dom.insertDocument(getConnection(),wrp);


===and then in the DAO class
public int insertDocument(Connection conn, DynaBean data){
StringBuffer sbf = new StringBuffer();
sbf.append(insert ..).appen(data.get(title)).append(,)
 .append(data.get(author)).append());

}
So the basic ideea is to use the wrapped ActionForm as a DTO.
Anyone has any comments?
Thanx
Ovidiu

ps: I'm reposting this beacause yesterday our mail server had some problems and
I'm not sure it was really posted on the list


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

Dynamic bean in a result list

2003-11-12 Thread Ovidiu EFTIMIE
Hi,
I have a jsp page where I must diplay a list of results like this
logic:present  name=DOCUMENTS
logic :iterate id='laliste' name='DOCUMENTS'

   tr

   tdbean :write name='liste' property='author'/td

   tdbean :write name='liste' property='title'/td

   tdbean :write name='liste' property='domain'/td

   /tr

/logic :iterate

   /logic:present

/logic :present

DOCUMENTS is an Array List which contains JavaBeans. The thing is that I want to
use a dynamic JavaBean, so I could have an ArrayList of objects like this
public class DynamicOT implements Serializable{

private HashMap property;


public DynamicOT(){

property = new HashMap();

}

public void setProperty(String nm, String val){

property.put(nm,val);

}

public String getProperty(String nm){

String str = (String) property.get(nm);

return str;

}

}

But then how could I retrive them in my jsp page ?
Using
 tdbean :write name=liste property=property('author')/td
would be enough?

Has anyone an idee of how I could do this ?

Thanx in advance,
Ovidiu


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



Re: Dynamic bean in a result list

2003-11-12 Thread Ovidiu EFTIMIE
Ok,
I've found the answer : Mapped properties
http://jakarta.apache.org/struts/faqs/indexedprops.html


- Original Message - 
From: Ovidiu EFTIMIE [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Wednesday, November 12, 2003 11:47 AM
Subject: Dynamic bean in a result list


 Hi,
 I have a jsp page where I must diplay a list of results like this
 logic:present  name=DOCUMENTS
 logic :iterate id='laliste' name='DOCUMENTS'

tr

tdbean :write name='liste' property='author'/td

tdbean :write name='liste' property='title'/td

tdbean :write name='liste' property='domain'/td

/tr

 /logic :iterate

/logic:present

 /logic :present

 DOCUMENTS is an Array List which contains JavaBeans. The thing is that I want
to
 use a dynamic JavaBean, so I could have an ArrayList of objects like this
 public class DynamicOT implements Serializable{

 private HashMap property;


 public DynamicOT(){

 property = new HashMap();

 }

 public void setProperty(String nm, String val){

 property.put(nm,val);

 }

 public String getProperty(String nm){

 String str = (String) property.get(nm);

 return str;

 }

 }

 But then how could I retrive them in my jsp page ?
 Using
  tdbean :write name=liste property=property('author')/td
 would be enough?

 Has anyone an idee of how I could do this ?

 Thanx in advance,
 Ovidiu


 -
 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: ActionError.

2003-11-12 Thread Ovidiu EFTIMIE
In your default application.properties file you have errors.detail = {0} so
using this, you can have
new ActionError(errors.detail,deepak);
And the message shown will be deepak

Ovidiu



- Original Message - 
From: deepaksawdekar [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Wednesday, November 12, 2003 12:44 PM
Subject: ActionError.


Hi All,
Please help me how to do this. I want to create a instance of ActionError, but i
don't want to the messages to be taken from applicationresource.properties file.
I have to give some other message which will be hard coded.

sample code
I want some thing like this,

err = new ActionError(deepak);
Errors = new ActionError(000, err);

Where deepak is not a key in applicationResource.properties file.



Thanks and Regards
Deepak.

-
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: Connection pool and MessageRessources

2003-10-31 Thread Ovidiu EFTIMIE
Hi James,
I've studied your solution, and I've noticed that you use a different connection
to the database and not the one that should be availble in an struts
application, and I think that could be a point of failure. That is why I'm
trying tu use the same connection pool as the rest of the application.

Ovidiu

- Original Message - 
From: James Mitchell [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Thursday, October 30, 2003 7:18 PM
Subject: RE: Connection pool and MessageRessources


 Hi Ovidiu

 I also wrote my own DBMessageResources.  With a simple hack, I was able
 to overcome the limitations of the existing API.

 The source code and example are available for download at:


 http://sourceforge.net/project/showfiles.php?group_id=49385release_id=1
 54972



 --
 James Mitchell
 Software Engineer / Struts Evangelist
 http://www.struts-atlanta.org
 678.910.8017 (c)
 770.822.3359 (h)
 AIM:jmitchtx




  -Original Message-
  From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
  Sent: Thursday, October 30, 2003 1:07 PM
  To: [EMAIL PROTECTED]
  Subject: Connection pool and MessageRessources
 
 
  Hi,
  I'm working with Struts 1.1 and I have a problem with the
  MessageRessource and I
  don't know to handle it  the right way.
  In my application I have two constraints,among others :) ,
  - i must use an oci connection to the database
  - the error messages will be stored in the database
  For that I took two aproaches :
  ## One ##:  I have written a Struts plugin which builds the
  connection pool, and
  I've extended MessageRessourceFactory and MessageRessources
  with my own classes
  DBRessourceFactory and DBRessource to have my own mechanism
  for message
  retrivial. My problem is now how can I get a connection to
  the database from the
  connection pool I've just made ? Is there a way to
  communicate between my plugin
  and my DBRessource class ?
 
 
  ## Two ##: I make a class which will handle the connection
  pool creation and the
  retrivial of messages from the database.
  It will look like this :
  public class MessagesDBPool extends MessageRessources implements
  PlugIn,Serializable {
  public MessageDBPool (){
  super();
  }
  public MessageDBPool(MessageRessourcesFactory
  factory,String config){
  this(factory,config,false);
  }
  public MessageDBPool(MessageRessourcesFactory
  factory,String config,boolean
  returnNull){
  super(factory,config,returnNull);
  }
  public void init(ActionServlet servlet, ModuleConfig
  config) throws
  ServletException{
  //pool initialisation here
  }
  public void destroy(){
  //destroy pool here
  }
  }
  Can I do this in the first place ?
 
  Now the question is which one of this two solutions can work?
  Is there another
  way to do this ?
  Any suggestions are welcome .
 
  Thanks,
  Ovidiu EFTIMIE
 
 
 
 
  -
  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: Connection pool and MessageRessources

2003-10-31 Thread Ovidiu EFTIMIE
I think I've found a solution.
I'll make an object (eventualy a struts PlugIn), DBMessage which receivies a
connection from my connection pool and retrives the error messages from the
database, and this object will not extend MessageRessources.
Then in my actions I'll have :

DbMessage dbmesg = (DbMessage)servlet.getAttribute(DBMESG);
String  message = dbmesg.getMessage(error_code);
ActionErrors errors = new ActionError();
errors.add(code,new ActionError(foo,message));

where foo is defined in my application.properties as
foo = {0}

How that sounds ?


Ovidiu

- Original Message - 
From: James Mitchell [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Thursday, October 30, 2003 7:18 PM
Subject: RE: Connection pool and MessageRessources


 Hi Ovidiu

 I also wrote my own DBMessageResources.  With a simple hack, I was able
 to overcome the limitations of the existing API.

 The source code and example are available for download at:


 http://sourceforge.net/project/showfiles.php?group_id=49385release_id=1
 54972



 --
 James Mitchell
 Software Engineer / Struts Evangelist
 http://www.struts-atlanta.org
 678.910.8017 (c)
 770.822.3359 (h)
 AIM:jmitchtx




  -Original Message-
  From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
  Sent: Thursday, October 30, 2003 1:07 PM
  To: [EMAIL PROTECTED]
  Subject: Connection pool and MessageRessources
 
 
  Hi,
  I'm working with Struts 1.1 and I have a problem with the
  MessageRessource and I
  don't know to handle it  the right way.
  In my application I have two constraints,among others :) ,
  - i must use an oci connection to the database
  - the error messages will be stored in the database
  For that I took two aproaches :
  ## One ##:  I have written a Struts plugin which builds the
  connection pool, and
  I've extended MessageRessourceFactory and MessageRessources
  with my own classes
  DBRessourceFactory and DBRessource to have my own mechanism
  for message
  retrivial. My problem is now how can I get a connection to
  the database from the
  connection pool I've just made ? Is there a way to
  communicate between my plugin
  and my DBRessource class ?
 
 
  ## Two ##: I make a class which will handle the connection
  pool creation and the
  retrivial of messages from the database.
  It will look like this :
  public class MessagesDBPool extends MessageRessources implements
  PlugIn,Serializable {
  public MessageDBPool (){
  super();
  }
  public MessageDBPool(MessageRessourcesFactory
  factory,String config){
  this(factory,config,false);
  }
  public MessageDBPool(MessageRessourcesFactory
  factory,String config,boolean
  returnNull){
  super(factory,config,returnNull);
  }
  public void init(ActionServlet servlet, ModuleConfig
  config) throws
  ServletException{
  //pool initialisation here
  }
  public void destroy(){
  //destroy pool here
  }
  }
  Can I do this in the first place ?
 
  Now the question is which one of this two solutions can work?
  Is there another
  way to do this ?
  Any suggestions are welcome .
 
  Thanks,
  Ovidiu EFTIMIE
 
 
 
 
  -
  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: Connection pool and MessageRessources

2003-10-31 Thread Ovidiu EFTIMIE
The think is we're not using OJB for this application, but your struts extension
is very interesting  and i'll keep it in my mind for future projects.

Thanks for yout response
Ovidiu

- Original Message - 
From: James Mitchell [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Friday, October 31, 2003 4:13 PM
Subject: RE: Connection pool and MessageRessources


  -Original Message-
  From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
  Sent: Friday, October 31, 2003 5:34 AM
  To: Struts Users Mailing List
  Subject: Re: Connection pool and MessageRessources
 
 
  Hi James,
  I've studied your solution, and I've noticed that you use a
  different connection
  to the database and not the one that should be availble in an struts
  application, and I think that could be a point of failure.

 No, actually you have that part wrong.  See, my extension uses OJB which
 is configured from it's own xml file and not from the struts-config.xml.

 Using the existing API (without any special hacks), you have no
 way to pass a connection, the DataSourceConfig, or even get at
 the ModuleConfig from any subclass of MessageResources.  That's why my
 solution works without requiring any special coding.

 My extension is designed to run independently of your application's
 persistence mechanism(s), but if you happen to be using OJB, it's
 all good.

 Somewhere on my todo list, is to implement the same extension using each
 of the major ORM frameworks.  But like all things, it takes time, and
 since I can't put food on the table writing Struts extensions, it'll
 have to wait.


 
  That is why I'm
  trying tu use the same connection pool as the rest of the application.

 If your app used OJB, you could do exactly that.

 
  Ovidiu
 


 --
 James Mitchell
 Software Engineer / Struts Evangelist
 http://www.struts-atlanta.org
 678.910.8017 (c)
 770.822.3359 (h)
 AIM:jmitchtx



 -
 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: Connection pool and MessageRessources

2003-10-31 Thread Ovidiu EFTIMIE
Yes I know it is very tighly integrated with Struts, and actualy  we're comply
with all things you've enumerated below.
The validator will not be used because all validation will be done with
javascript already present in the jsp page, and the only server side validation
we'll have will be to find out if the client has disabled javascript, and  we'll
not be using bean:message beacause we'll not have a multi language site.

I know that my solution cannot be universally applied, and it's just a way to
overcome Struts limitations regarding the MessageRessources.
I'll hope that in future versions something similar with your extension could be
integrated into Struts, because is a little bit frustrating to manage error
messages(for example) in two separate places (an Oracle table and
application.properties as in my case).

Thanks for your response, and I hope Id didn't took a lot of your time

Ovidiu

- Original Message - 
From: James Mitchell [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Friday, October 31, 2003 4:13 PM
Subject: RE: Connection pool and MessageRessources


 You might not be realizing just how deeply the MesageResources is
 integrated with Struts.

 Your solution won't work if:

   * your app is using the validator

   * any of your jsp pages are using bean:message

   * any of your jsp pages use tags that use MessageResources
 (which are any that use xyzKey such as srcKey,
  pageKey, altKey, etc)


 As far as application modification goes, the extension I
 created is a simple config change in struts-config, and voila!


 --
 James Mitchell
 Software Engineer / Struts Evangelist
 http://www.struts-atlanta.org
 678.910.8017 (c)
 770.822.3359 (h)
 AIM:jmitchtx




  -Original Message-
  From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
  Sent: Friday, October 31, 2003 7:23 AM
  To: Struts Users Mailing List
  Subject: Re: Connection pool and MessageRessources
 
 
  I think I've found a solution.
  I'll make an object (eventualy a struts PlugIn), DBMessage
  which receivies a
  connection from my connection pool and retrives the error
  messages from the
  database, and this object will not extend MessageRessources.
  Then in my actions I'll have :
 
  DbMessage dbmesg = (DbMessage)servlet.getAttribute(DBMESG);
  String  message = dbmesg.getMessage(error_code);
  ActionErrors errors = new ActionError();
  errors.add(code,new ActionError(foo,message));
 
  where foo is defined in my application.properties as
  foo = {0}
 
  How that sounds ?
 
 
  Ovidiu
 
  - Original Message - 
  From: James Mitchell [EMAIL PROTECTED]
  To: 'Struts Users Mailing List' [EMAIL PROTECTED]
  Sent: Thursday, October 30, 2003 7:18 PM
  Subject: RE: Connection pool and MessageRessources
 
 
   Hi Ovidiu
  
   I also wrote my own DBMessageResources.  With a simple
  hack, I was able
   to overcome the limitations of the existing API.
  
   The source code and example are available for download at:
  
  
  
  http://sourceforge.net/project/showfiles.php?group_id=49385re
  lease_id=1
   54972
  
  
  
   --
   James Mitchell
   Software Engineer / Struts Evangelist
   http://www.struts-atlanta.org
   678.910.8017 (c)
   770.822.3359 (h)
   AIM:jmitchtx
  
  
  
  
-Original Message-
From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 30, 2003 1:07 PM
To: [EMAIL PROTECTED]
Subject: Connection pool and MessageRessources
   
   
Hi,
I'm working with Struts 1.1 and I have a problem with the
MessageRessource and I
don't know to handle it  the right way.
In my application I have two constraints,among others :) ,
- i must use an oci connection to the database
- the error messages will be stored in the database
For that I took two aproaches :
## One ##:  I have written a Struts plugin which builds the
connection pool, and
I've extended MessageRessourceFactory and MessageRessources
with my own classes
DBRessourceFactory and DBRessource to have my own mechanism
for message
retrivial. My problem is now how can I get a connection to
the database from the
connection pool I've just made ? Is there a way to
communicate between my plugin
and my DBRessource class ?
   
   
## Two ##: I make a class which will handle the connection
pool creation and the
retrivial of messages from the database.
It will look like this :
public class MessagesDBPool extends MessageRessources implements
PlugIn,Serializable {
public MessageDBPool (){
super();
}
public MessageDBPool(MessageRessourcesFactory
factory,String config){
this(factory,config,false);
}
public MessageDBPool(MessageRessourcesFactory
factory,String config,boolean
returnNull){
super(factory,config,returnNull);
}
public void init(ActionServlet servlet, ModuleConfig
config) throws

Connection pool and MessageRessources

2003-10-30 Thread Ovidiu EFTIMIE
Hi,
I'm working with Struts 1.1 and I have a problem with the MessageRessource and I
don't know to handle it  the right way.
In my application I have two constraints,among others :) ,
- i must use an oci connection to the database
- the error messages will be stored in the database
For that I took two aproaches :
## One ##:  I have written a Struts plugin which builds the connection pool, and
I've extended MessageRessourceFactory and MessageRessources with my own classes
DBRessourceFactory and DBRessource to have my own mechanism for message
retrivial. My problem is now how can I get a connection to the database from the
connection pool I've just made ? Is there a way to communicate between my plugin
and my DBRessource class ?


## Two ##: I make a class which will handle the connection pool creation and the
retrivial of messages from the database.
It will look like this :
public class MessagesDBPool extends MessageRessources implements
PlugIn,Serializable {
public MessageDBPool (){
super();
}
public MessageDBPool(MessageRessourcesFactory factory,String config){
this(factory,config,false);
}
public MessageDBPool(MessageRessourcesFactory factory,String config,boolean
returnNull){
super(factory,config,returnNull);
}
public void init(ActionServlet servlet, ModuleConfig config) throws
ServletException{
//pool initialisation here
}
public void destroy(){
//destroy pool here
}
}
Can I do this in the first place ?

Now the question is which one of this two solutions can work? Is there another
way to do this ?
Any suggestions are welcome .

Thanks,
Ovidiu EFTIMIE




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