RE: DTO pattern and WrapDynaBean

2003-11-14 Thread Sumit S.
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]



RE: DTO pattern and WrapDynaBean

2003-11-14 Thread Sumit S.
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]


-
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: Dreaming of a constant value that can be available in all of my actions

2003-11-14 Thread Sumit S.
Thanks for setting the context Amine..You can extend the ActionServlet, read the param 
from Web.xml and then access the Servlet instance from your Action class by using the 
context key Globals.ACTION_SERVLET_KEY...see the javadoc below from the Action 
class.

/**
 * The context attributes key under which our codeActionServlet/code
 * instance will be stored.
 * @deprecated Use Globals.ACTION_SERVLET_KEY instead.
 * @since Struts 1.1
 */
public static final String ACTION_SERVLET_KEY = Globals.ACTION_SERVLET_KEY;



Sumit

-Original Message-
From: Amine Bousta [mailto:[EMAIL PROTECTED]
Sent: Friday, November 14, 2003 4:21 PM
To: Struts Users Mailing List
Subject: RE: Dreaming of a constant value that can be available in all
of my actions


Thanks Sumit for such a quick answer!

That's a good idea but I'd like to have a different constant for each of my
application.
Concretely I've made kind of generic actions that uses Class and
MethodUtils to perform basic actions on beans.
These actions are commonly shared by all of my applications but the thing is
that these actions need a package prefix to create objects with
Class.forName.
This package prefix is different from an application to another.

If I implement your concept I'd have the same constant value (package
prefix) for all my apps.

So basically I need a constant value initialised in the web.xml and
accessible from any action.

Thank you again
Amine



-Message d'origine-
De : Sumit S. [mailto:[EMAIL PROTECTED]
Envoyé : vendredi 14 novembre 2003 11:26
À : Struts Users Mailing List
Objet : RE: Dreaming of a constant value that can be available in all of
my actions


U can define  use a base Action class  that has a static block that sets
the constantderive all your actions from the base...the base class can
read the value from the envrionment or context.



Hope this helps...

Sumit

-Original Message-
From: Amine Bousta [mailto:[EMAIL PROTECTED]
Sent: Friday, November 14, 2003 3:43 PM
To: [EMAIL PROTECTED]
Subject: Dreaming of a constant value that can be available in all of my
actions


Hello,

I want a constant value that I could use in all of my Struts action.

I already have a MyActionMapping that extends the ActionMapping and owns a
parameter.
I would like to initialise this parameter with a constant value. Then I
would access it with a getXXX in every actions.
It's like if I'd do a myActionMapping.set just once for all my
application.

Is there a way to configure web.xml so that it initialises a MyActionMapping
parameter while initialising my app?

If you know another way to do that (extending ServletAction? if so, how to
access the parameter from within an action?) I'd be happy to read you.

Regards
Amine



-
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: Checkbox values

2003-11-14 Thread Sumit S.
Geert,
 this would create BookListKey[i].selectedBook = 1 for Checked Books

When you have to render this info try

logic:present name=BookListKey
logic:iterate id=book name=BookListKey
logic:equal name=book property=selectedBook value=1 
brselected index = bean:write name=book property=id/
/logic:equal
/logic:iterate
/logic:present


hope this helps

Regards
Sumit


-Original Message-
From: Geert Van Landeghem [mailto:[EMAIL PROTECTED]
Sent: Friday, November 14, 2003 4:56 PM
To: Struts Users Mailing List
Subject: Checkbox values


Hello all,
 
I'm trying to show the selected rows in a html table by using check
boxes. I'm using the same jsp to show the selected row indexes of the table.

What am I'm doing wrong because I'm not able to see the selected indexes:

logic:present name=selectedBook
logic:iterate id=sel name=selectedBook
brselected index = bean:write name=sel/
/logic:iterate
/logic:present

logic:iterate id=book name=BookListKey scope=request 
tr 
tdhtml:checkbox property=selectedBookbean:write name=book 
property=id//html:checkbox/td
tdbean:write name=book property=authorLastName/nbsp;/td
tdbean:write name=book property=authorFirstName/nbsp;/td 
tdbean:write name=book property=title/nbsp;/td   
/tr
/logic:iterate

tia,

met vriendelijke groeten,
salutations sincères,
kind regards,

Geert Van Landeghem
Reynders Etiketten NV
tel: +32 3 460.32.81
gsm: +32 477.75.95.33
mailto:[EMAIL PROTECTED]

Give me 
the power to accept the things i cannot change,
the strength to change the things i can change,
and the insight to tell the difference


-
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: Problem of nested logic:iterate

2003-11-13 Thread Sumit S.
Here u go...I have a userForm that has a list of users. Each User further has a list 
of orders...here's the logic:iterate code to do what u want to do ...

 logic:iterate name=userForm property=users id=user
  bean:write name=user property=firstname/  
logic:iterate name=user property=orders id=order
  bean:write name=order property=orderdesc/
/logic:iterate   
  /logic:iterate 

Sumit

-Original Message-
From: Raman Garg [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 13, 2003 2:46 PM
To: Struts Users Mailing List
Subject: Problem of nested logic:iterate


Hi,

I have a problem regarding struts logic:iterate

I need to show  category wise listing of products. so can anybody advice me how to 
create nested logic iterate loops to accomplish this.

what i need is  there will be two nested logic iterates 

logic:iterate 
!--this is for listing of catergory--
logic:iterate 
!--this is for products under a catergory--
/logic:iterate  
/logic:iterate 

How can populate the inner loop variable???


Thanks in advance,
Raman Garg

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



Null DynaActionForm

2003-11-12 Thread Sumit S.
Hi,
   How do I create a new instance of a DynaActionForm when the form passed to my 
Action.execute() method is null ?

public ActionForward execute(ActionMapping mapping,
 ActionForm form,
 HttpServletRequest request,
 HttpServletResponse response)
throws Exception 
{
try
{
DynaActionForm userForm = null;
if (null != form)
{
userForm = (DynaActionForm) form;
System.out.println(IT IS NOT NULL);
}
else
  { 
/*NEED TO CREATE A NEW INSTANCE HERE*/
  System.out.println(IT IS NULL);
  }




RE: Dynamic bean in a result list

2003-11-12 Thread Sumit S.
You could use a DynaActionForm that contains a property of type ArrayList ...

Something like...

   form-bean name=bookForm type=org.apache.struts.action.DynaActionForm
form-property name=books type=java.util.ArrayList/
   /form-bean

This arraylist can contain DynaBeans inside it and you can access these from your 
Struts based JSP

logic:iterate name=bookForm property=books id=book
  bean:write name=book property=author/
  bean:write name=book property=title/
  bean:write name=book property=domain/
/logic:iterate  

Struts handles DynaActionForms  typical Action forms seamlessly..However DynaBeans 
and Custom beans should not be mixed up..


Sumit

-Original Message-
From: Ovidiu EFTIMIE [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 12, 2003 4:17 PM
To: Struts Users Mailing List
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: new to struts

2003-11-11 Thread Sumit S.

http://jakarta.apache.org/struts/learning.html is a good place to start.


Sumit



-Original Message-
From: sanjay paithankar [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 11, 2003 2:47 PM
To: [EMAIL PROTECTED]
Subject: new to struts


Hello 

can any one point the basic document 
regarding Struts which has given small examples.

thnx
-cs..


__
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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



ResultSetDynaClass etc...

2003-11-11 Thread Sumit S.
The ResultSetDynaClass  ResultSetDynaBeans are a powerful way of encapsulating 
ResultSets in DynaClasses. However, when we need to transfer the data from such a 
DynaClass to a ValueObject (say a structs ActionForm), the 
PropertyUtils.copyProperties looks for a property name match.

So now my ActionForm attributes get tied to the DB Column namesand if at a later 
point in time, the column names are changed, it means a change in code.

One option is to store the mapping information in a simple configuration file and 
override the copyProperties to take this mapping info as an input parameter as well...

something like

copyProperties (Object dest, Object src, Map map)
{
for each property in src
read the value from source.
get the corresponding property name in dest from the map
set the property value in the dest
}

I have written a small class to do the above
Is there a more elegant way of doing it.The config might be XML or Text based 
which can be converted into Map objects  cached.

Thanks
Sumit




RE: ResultSetDynaClass etc...

2003-11-11 Thread Sumit S.
Yeah...but look at the following scenario


1. Call Database. Get back result set.
2. Create a DynaBean array list from the result set.
3. Use PropertyUtils.copyProperties() to transfer data from the result set into a 
value object.
 3.1  At this stage my ValueObject property names have to be the same as the Database 
column names.
4. Do some business processing.
5. Pass the value objects to the Action Class.
6. Populate the DynaFormBean at the struts layer.

How to avoid 3.1 in a clean manner ? Is the approach outlined in my first message 
clean enough?

Sumit

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 11, 2003 9:04 PM
To: [EMAIL PROTECTED]
Subject: RE: ResultSetDynaClass etc...


I think the dynaFormBean is there for exactly same purpose

-Original Message-
From: Sumit S. [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 11, 2003 4:17 PM
To: [EMAIL PROTECTED]
Subject: ResultSetDynaClass etc...


The ResultSetDynaClass  ResultSetDynaBeans are a powerful way of encapsulating 
ResultSets in DynaClasses. However, when we need to transfer the data from such a 
DynaClass to a ValueObject (say a structs ActionForm), the 
PropertyUtils.copyProperties looks for a property name match.

So now my ActionForm attributes get tied to the DB Column namesand if at a later 
point in time, the column names are changed, it means a change in code.

One option is to store the mapping information in a simple configuration file and 
override the copyProperties to take this mapping info as an input parameter as well...

something like

copyProperties (Object dest, Object src, Map map)
{
for each property in src
read the value from source.
get the corresponding property name in dest from the map
set the property value in the dest
}

I have written a small class to do the above
Is there a more elegant way of doing it.The config might be XML or Text based 
which can be converted into Map objects  cached.

Thanks
Sumit



-
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: ResultSetDynaClass etc...

2003-11-11 Thread Sumit S.
Yup...did think of that approach but felt that any change in the alias (for some 
reason DBA decides to change a stored proc ) means a change in the code...which means 
compile, test, redeploy.

Using the map approach we just change the config file and we are done...

We are using the framework for the development of a pretty huge enterprise class app 
where the expectation is that the things might change more frequently than 
normal...hence the need to mantain the disconnect.

Thanksthis was a good thread...

Sumit 

-Original Message-
From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 11, 2003 11:49 PM
To: Struts Users Mailing List
Subject: Re: ResultSetDynaClass etc...


Quoting Sumit S. [EMAIL PROTECTED]:

 The ResultSetDynaClass  ResultSetDynaBeans are a powerful way of
 encapsulating ResultSets in DynaClasses. However, when we need to transfer
 the data from such a DynaClass to a ValueObject (say a structs ActionForm),
 the PropertyUtils.copyProperties looks for a property name match.
 
 So now my ActionForm attributes get tied to the DB Column namesand if at
 a later point in time, the column names are changed, it means a change in
 code.
 
 One option is to store the mapping information in a simple configuration file
 and override the copyProperties to take this mapping info as an input
 parameter as well...
 
 something like
 
 copyProperties (Object dest, Object src, Map map)
 {
 for each property in src
 read the value from source.
 get the corresponding property name in dest from the map
 set the property value in the dest
 }
 
 I have written a small class to do the above
 Is there a more elegant way of doing it.The config might be XML or Text
 based which can be converted into Map objects  cached.
 

The method you suggest for disconnecting your DynaBeans from column names works,
but you can accomplish the same thing in SQL directly as well:

  select account_id as account, customer_name as name, street_address as
address
from customers where (credit_limit  500.00);

creates three properties in the result set named account, name, and
address that are totally independent of the names used in the underlying
database schema.  To me, it seems easier to let the database queries maintain
the naming independence than to do it separately in code.

 Thanks
 Sumit
 

Craig


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