RE: which method is better

2006-02-28 Thread R.Vijayaraghavan
I do something like:

public class ProductAction extends Action
{
execute()
{
String name = (String)PropertyUtils.getSimpleProperty(form, 
"name");
String age = (String)PropertyUtils.getSimpleProperty(form, 
"age");
ProductModel model = new ProductModel();
model.setName(name);
model.setAge(age);
model.saveToPersistentStore();
}
}

I was wondering if the ActionForm can be used as a DTO. Something like this,

public class ProductAction extends Action
{
execute()
{
ProductModel model = new ProductModel();
model.setForm(form);//  action form reference which the 
execute method
gets
model.saveToPersistentStore();
}
}

I do not know which method will be better. I don't even know if there is any
other technique we should follow as Oshima pointed it.

regards,
vijay.


> -Original Message-
> From: Oshima Tlholoe [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 28, 2006 2:53 PM
> To: Struts Users Mailing List
> Subject: Re: which method is better
>
>
> With my rudimentary knowledge,I dont think its advisable for your Action
> classes to talk directly to your business layer/model classes,
> Why don't you
> have a business delegate/session facade or Service Locator sitting between
> your Action Classes and the model classes, this insulates your action
> classes from your business layer and it even makes testing
> simpler. You not
> going to have test cases that span multiple layers.
> Let your Actions pull out data from the ActionForm, wrap it and pass it to
> the Service Locator, then the Service Locator then handles the
> rest, calling
> all the related model classes.
>
>
>
> On 2/28/06, R.Vijayaraghavan <[EMAIL PROTECTED]> wrote:
> >
> > Hello,
> >
> > I usually have set and get methods for all properties in my Model class.
> > After submitting a form, I pull out all the property values
> (form fields)
> > in
> > the Action class from the ActionForm object, set the values of all
> > properties in the model from the action class and then call a particular
> > method in the model class for final submission to the database.
> >
> > I wanted to know thether the above mentioned method is better or is it
> > better to pass the form reference itself to the Model class which then
> > sets
> > the values.
> >
> > In situation 2, I do not have to take care of the various String
> > references
> > that I create. I simply will pass the ActionForm object to the Model
> > class.
> >
> > regards,
> > vijay.
> >
> >
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> Regards
> Name : Oshima Tlholoe
> Cell No: +2773 342 4393
> Tel No : +2712 841 4355(w)
> E-mail : [EMAIL PROTECTED]
> simplicity is the ultimate sophistication
>



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



RE: which method is better

2006-02-28 Thread R.Vijayaraghavan
I am not using EJB. The model is made using simple JDBC that gets the
database connection from a helper class which uses JNDI to get the JDBC data
source.

How can I apply Session Facade here. Is there any text or code examples
which I can read that talks the same with relation to struts.

regards,
vijay.

> -Original Message-
> From: Oshima Tlholoe [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 28, 2006 2:53 PM
> To: Struts Users Mailing List
> Subject: Re: which method is better
>
>
> With my rudimentary knowledge,I dont think its advisable for your Action
> classes to talk directly to your business layer/model classes,
> Why don't you
> have a business delegate/session facade or Service Locator sitting between
> your Action Classes and the model classes, this insulates your action
> classes from your business layer and it even makes testing
> simpler. You not
> going to have test cases that span multiple layers.
> Let your Actions pull out data from the ActionForm, wrap it and pass it to
> the Service Locator, then the Service Locator then handles the
> rest, calling
> all the related model classes.
>
>
>
> On 2/28/06, R.Vijayaraghavan <[EMAIL PROTECTED]> wrote:
> >
> > Hello,
> >
> > I usually have set and get methods for all properties in my Model class.
> > After submitting a form, I pull out all the property values
> (form fields)
> > in
> > the Action class from the ActionForm object, set the values of all
> > properties in the model from the action class and then call a particular
> > method in the model class for final submission to the database.
> >
> > I wanted to know thether the above mentioned method is better or is it
> > better to pass the form reference itself to the Model class which then
> > sets
> > the values.
> >
> > In situation 2, I do not have to take care of the various String
> > references
> > that I create. I simply will pass the ActionForm object to the Model
> > class.
> >
> > regards,
> > vijay.
> >
> >
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> Regards
> Name : Oshima Tlholoe
> Cell No: +2773 342 4393
> Tel No : +2712 841 4355(w)
> E-mail : [EMAIL PROTECTED]
> simplicity is the ultimate sophistication
>



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



which method is better

2006-02-28 Thread R.Vijayaraghavan
Hello,

I usually have set and get methods for all properties in my Model class.
After submitting a form, I pull out all the property values (form fields) in
the Action class from the ActionForm object, set the values of all
properties in the model from the action class and then call a particular
method in the model class for final submission to the database.

I wanted to know thether the above mentioned method is better or is it
better to pass the form reference itself to the Model class which then sets
the values.

In situation 2, I do not have to take care of the various String references
that I create. I simply will pass the ActionForm object to the Model class.

regards,
vijay.



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



html:file clears after validate returns error

2006-02-21 Thread R.Vijayaraghavan
Hello,

The html:file field clears after there is an error in the form's validate()
method. The user then has to again select the file for upload. How do I
retain the file selected by the user even after a validate error. I searched
the internet but could not find anything.

regards,
vijay.



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



fill combo box based onClick of previous combo box

2006-01-19 Thread R.Vijayaraghavan
Hello,

I have an application where I have 3-4 combo boxes. After selecting a
particular value from the first combo box, the second combo box should be
filled with values from the database. Likewise for other combo boxes. How
can this be implemented in Struts.

Will this be feasible:

Call form.submit on combo box's onClick, then get the value in Action, go to
the Model, get the corrosponding values, fill the form bean in Action class
and open the same page.

regards,
vijay.



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



RE: logout/Back Button problem

2005-11-23 Thread R.Vijayaraghavan
> -Original Message-
> From: Michael Jouravlev [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, November 15, 2005 9:18 PM
> To: Struts Users Mailing List
> Subject: Re: logout/Back Button problem
> 
> 
> Firefox? Add "no-store":

This does not work in IE. Any other thing which can be tried?

regards,
vijay.

> 
> response.setHeader("Cache-Control", "no-cache, no-store");
> 
> On the other hand, SSL + "no-cache" should work for Firefox as 
> well, hmm...
> 


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



RE: query string parameters problem

2005-10-22 Thread R.Vijayaraghavan


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Saturday, October 22, 2005 12:25 PM
> To: Struts Users Mailing List
> Subject: RE: query string parameters problem
>
>
>
> The scope of the ActionForm is session means that the last submitted
> ActionForm will remain in the session till the session ends. In you case,
> even though the ActionForm is getting populated with the values for the
> first time, those are getting overridden by the second request and the
> second request is not taking the values of name and age in the query
> string (As the querystring URL is getting overridden by "/submit.do").

True. It does not re-instantiate the bean but it calls the reset() method on
submitting the form. So the only way it can be done is to use the hidden
fields ??

regards,
vijay.



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



RE: query string parameters problem

2005-10-21 Thread R.Vijayaraghavan

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Saturday, October 22, 2005 12:08 PM
> To: Struts Users Mailing List
> Subject: RE: query string parameters problem
>
>
>
> Are you able to see the 'age' and 'name' attributes in the address bar
> after submitting the form ? If not, the action="/submit.do" in your
>  is overwriting the URL you wanted to post. IN this case you
> can use the hidden variables for age and name and set the required values
> in the Javascript.

Yes it overwrites the address bar with just /submit.do. But why should the
name and age attributes be null when the ActionForm is in session scope.
Shouldn't the values be re-used.

>
> Regards,
> Rajasekhar Cherukuri
>

regards,
vijay.



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



RE: query string parameters problem

2005-10-21 Thread R.Vijayaraghavan
struts-config.xml









ActionForm has the setter and getter methods for name, age and description.

Action:
public final class QueryParamsAction extends Action {

public ActionForward execute(ActionMapping mapping,
ActionForm form1,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

QueryParamsForm form = (QueryParamsForm)form1;

//String name = (String) 
PropertyUtils.getSimpleProperty(form, "name");
String name = (String) request.getParameter("name");
//String age = (String) 
PropertyUtils.getSimpleProperty(form, "age");
String age = (String) request.getParameter("age");
String description = (String) 
PropertyUtils.getSimpleProperty(form,
"description");

out.println(name);
out.println(age);
out.println(description);

return (mapping.findForward("nextPage"));
}

My initial query string is:

http://localhost:8080/vijay/QueryParams.do?name=vijay&age=26

This instantiates the ActionForm, sets age and name, comes to teh Action,
print age and name correctly, prints description as null(as expected), goes
to "nextPage" whcih is QueryParams.jsp. In QueryParams.jsp, I print name,
age and assign a textbox for the atribute 'description' which when submitted
should set description in the ActionForm. It does so. When it comes back to
Action, description gets printed but name and age are now null.

> It should work the way you want (session scoped forms retain
> their values.)
>
> Post the relevant parts of struts-config (the form bean and action)
> and the part of the Action code where you're trying to access the form
> properties, and see if someone can spot a problem.  Also describe
> the flow
> of your app.
>
> My guess is that you're dealing with two different form beans,
> but I need to
> see the config file.
>
> --
> Wendy Smoak
>



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



RE: query string parameters problem

2005-10-21 Thread R.Vijayaraghavan


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Saturday, October 22, 2005 8:36 AM
> To: Struts Users Mailing List
> Subject: Re: query string parameters problem
>
>
>
> Hi,
> You should use
> request.getParameter("name")
> request.getParameter("age")

It does not work.

> to get the values from the request. I don't think the values set
> through through query string will be set to ActionForm automatically. In
> this case you should explicitly call the setter methods of the ActionForm
> and then set the new ActionForm object to session with the same name that
> was used in the action element attribute "attribute" in struts-config.xml.

No, the values are set even while passing the values through the query
string. Why should not this work. The URL with the query string will call
teh appropriate ActionForm, set the values that it gets from the Http GET
request.

The problem I face is that when I submit the html page, the name and age do
not get added to the query string(and thats fine, it should not). The
description goes via the Http POST request, ActionForm sets the value of
description, comes to the Action. Its here that I am not able to get the
values of name and age.

regards,
vijay.



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



RE: query string parameters problem

2005-10-21 Thread R.Vijayaraghavan
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: Friday, October 21, 2005 7:01 PM
> To: user@struts.apache.org
> Subject: RE: query string parameters problem
>
>
> R.Vijayaraghavan asked:
>   [snip]
> > The action is set to /submit.do. Since I am only sending the
> > description in the http request, only the setDescription()
> > method should be called and it happens so. The problem is
> > when I try to access the age and name variables from the
> > ActionForm in the Action class, I get null. Why so? I am not
> > setting age and name after submitting the form, they are
> > already set. The form is in session scope, so shouldn't it be re-used.
>
> You might want to add hidden fields in your HTML form so that the name
> and age get resubmitted.

This can be done.

> Or, if the data you want is already in session
> scope, have your Action read that data from there.

When I say that the form is in session scope, does it mean that the
attributes in the form bean will hold their values until modified. If yes,
then why in my case it does not work.

regards,
vijay.



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



RE: Load datasource config without action classes

2005-10-21 Thread R.Vijayaraghavan
Configure a JNDI data-source. Different application servers do it
differently.

regards,
vijay.

> -Original Message-
> From: M4RC0 [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, October 18, 2005 4:22 PM
> To: Struts Users Mailing List
> Subject: Load datasource config without action classes
>
>
> Hi
> i'm thinking about loading struts-config datasources configuration
> directly to my business classes, but i appears to be necesary to use
> action clases (by calling getDataSource method). is it  possible to
> use a load-on-startup servlet to get struts configured datasources (or
> something similar, instead action clases)??
> I really like the form how struts configure databases but i preffer to
> link those databases directly to my business tier.
>
> I'm opened to other options instead :)
>
> Any idea? thanks all!
>
> --
> M4RC0
>
> -
> 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]



query string parameters problem

2005-10-21 Thread R.Vijayaraghavan
Hello,

I have 3 variables, namely age, name and description. I have the values for
name and age before sending the request. That is, my URL would look like
http://localhost:8080/vijay/submit.do?name=xyz&age=22

I have a form that sets the values of age and name which is then accessed in
a html page using bean:write. In the html page, the user will enter the
description in the corrosponding textarea.

The action is set to /submit.do. Since I am only sending the description in
the http request, only the setDescription() method should be called and it
happens so. The problem is when I try to access the age and name variables
from the ActionForm in the Action class, I get null. Why so? I am not
setting age and name after submitting the form, they are already set. The
form is in session scope, so shouldn't it be re-used.

Or am I understanding it in-correctly.

regards,
vijay.

Sorry if the subject of the mail is not proper, I couldn't think of any
other subject.



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



[OT] how actually to make a shoping cart

2005-10-10 Thread R.Vijayaraghavan
Hello,

I am very new to struts, moreover new to web development. I have to make a
shopping cart and I am using displaytag to display the search results.
Problems I am facing:

1. What actually should happen when a user selects a set of products and
then clicks on the 'add to cart' button. Should the search page be
re-displayed with the selected items already-checked? Or should the cart
with the products be shown and tell the user to search again using the same
search string?

Has anyone made a shopping cart using displaytag in particular. I wanted to
know how to mend it all together.

regards,
vijay.



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



RE: Display checkbox

2005-09-30 Thread R.Vijayaraghavan
> Hi all,
> 
> I've this JSP code:
> 
>  requestURI="wul_search.do?method=search" pagesize="10" 
> export="true" defaultsort="8" defaultorder="ascending">
>   
>   select
>   
>href="wul_search.do?method=load" paramId="id" sortable="true" 
> headerClass="sortable" media="html excel"/>

Do you have a corrosponding property for id in the ActionForm.

regards,
vijay.


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



display checkbox with unique value using displaytag

2005-09-29 Thread R.Vijayaraghavan
Hello,

I am using displaytag to display a table of records. I am able to add a
checkbox as the first column using:





The problem is that I am not able to set a unique value for each checkbox. I
am having a column in the recordset stored in a RowSetDynaClass that has the
unique values for all the checkboxes. I just need to assign them
appropriately.

regards,
vijay.



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



RE: e-mail address validator

2005-09-28 Thread R.Vijayaraghavan

>
> Never mind.  I found this one on an ASP.Net page:
>
> [EMAIL PROTECTED],3}

This wont verify the mailid:  [EMAIL PROTECTED]

This will. This can be made more strict by checking the length, like Bryon
has done.
(\\S+)(@)(\\S+)(\\.)(\\S+)((.)(\\S+))*

regards,
vijay.



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