I think this issue is very well explained by Ted in his book Struts In Action..
As he says,Forms sghould be just treated as carriers of data till the data is
validated and hold the data till in case same is required to be returned to the
user.
So we should not waste too much time to design form
U will have some thing like following ..
The action classes are handlers...So when u need to get some data to the
screen,U will call the action class and the action class will then call a
Busines Layer class to perform the database access logic and return the
result.And action will then put
go through the struts documentation carefully..It will help u clarify lot of
doubts..:-))
It specifically says Action classes are multithreaded..Means same action
instance is used for all the requests..so thats why u have to be careful not to
have any attributes in the action...So long as they
I think what u need is a good primer on MVC architecture...
Search on google..U will find plenty..Or more specifically go to suns site and
u will find the information...
Then struts doc will be easy to follow..
-Original Message-
From: jadestone [mailto:[EMAIL PROTECTED]]
Sent: Tuesday,
Hi Ted,
This explanatation has set to rest most of my doubts about action
chainning..And I think the way Most of us use actions(One action to serve the
request like save action)and another to display the page (like getAccountsList
Action )is not action chainning but action relay which is
can u please elaborate?
-Original Message-
From: Sangeetha.Nagarjunan [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 03, 2003 2:23 PM
To: struts-user
Subject: Values not populated correctly from JSP
Hi,
Values from my JSP are not getting initialized properyt to my Form
bean.
Is
Hi,
I agree with u that u can have another layer of abstraction(like helper beans)
between action and Service layer.So that same code ecan be reused.
But this some disadvangates.
Firstly U are then not really using the power of Struts Configuration file
which allows you to use logical mappings
Hi,
Does this mean that using action forwards To point another action is not action
chainning?So we can call this action relay and its in line with Struts design
principles?
And as u said,We have really abstracted away all error handling etc to
Abstract Action class.But the point is if we go
Hi All,
I received quite a few mails asking me for sample code for the code generation
of DAO layer..I would love to share the same ..But as the code is too tightly
coupled with some of project classes and directory structure (it has evolved
over a period of time...) and will not be useful as
Hi,
I am not exactly clear about u r requirement.But we have achieved some thing
similar in one of my previous project.We had a protal where employees of
different companies will be logging in and the information about the company
will be provided in the http header.and we were required to
Hi All,
I have a very basic design question about struts action design..We have been
developing a fairly large and complex web application involving struts and
struts has proved to be a great help :-)) But after reading the book by Mr.
Husted et al., Struts in action,I have some basic
Can you see the originating class for all those struts loggings messages in the
logged messages?
I mean in log4j ,u can disable the logging per class or package level..And if
struts is using log4j, then it must be creating those log4j loggers which
generally have the class name...So may be u
.U can specify log level per logger as well.SO if u want to exclude logging for
some packages,U specify a higher log level for that..some thing like
log4j.logger.org.apache.struts=ERROR
So for all loggers whose name starts with org.apache.struts , only errors wil
be logged..For other named
a bit out of context but after looking at u r jsp it seems that u are packing
too much logic in u r jsp..cant u prepare the link parameers in u r action and
set them on the form...
and then in the jsp just acces that property of form...
-Original Message-
From: modena [mailto:[EMAIL
Hi,
We have used folowing approach..
To access db , we use DAO pattern(refer to Sun's blue prints for more
details).The DAOs return value objects And all calls to the DAO must go through
service layer..
So in action classes u get Instance of appropriate service from service factory
and call
It means Runtime expression...
So for example for bean write tag the message attribute is marked as RT, u can
write somethign like this..
bean:write message=%=someUrl...%/
regards,
Shirish
-Original Message-
From: sundar [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 29, 2003
Hi,
If i understand u right u are saying that same request will be handled by more
than one action..
e.g. Some thing like if user logs in, check his login credentials and then give
him the list of his accounts in a banjking app.So u wil like to have a
LoginAction(which just checks login) and a
No..Not at all...I think this is the way struts application is supposed to
work..Define actions as pure handlers..And then call them from any context by
just using different mappings...
I think action chainning as referred to on this list referes to using one
action inside another action by
Hi,
We have implemented some thing similar using a custome tag(NLS tag..)The
approach we have used is we have a abstract action..And in abstract action ,
we strore the last action called url...So every time the last action called is
in the session...along with the request uri ...
So when user
Hi,
Do u have any sample code of a servlet that does the same?I tried to use the
FOP servlet given with FOP distribution..But i keep on getting null pointer
exceptions...
Any help will be appreciated..
regards,
Shirish.
-Original Message-
From: madhavan [mailto:[EMAIL PROTECTED]]
Hi,
I had faced similar problem.And as U said, soem versions of IE give preference
to file extension over content type it seems.But the following works..
response.addHeader(Content-Disposition, attachment;filename=+ fileName
+.pdf);
where file name is any name u want the save as dialogue box
Hi ,
The general solution that we have used in our web application is to srite a
BootStrap Servlet...And load all the configurations in the init method of this
servlet...
Also in web.xml, U speciry the highest priority for this servlet Using the
load on startup
element..
Example:
servlet
Easiest way to pass multiple parameters on a html link.
Use the standard anchor tag.
eg:
a href=SomeAction.do?empid=bean:write
name=myForm
property=%=\emp[\+i+\].empId\%/salary
nce=bean:write name=myForm
property=%=\empList[\+i+\].salary\%/
Here the myForm should have indexed
just change u r indexed method getPermissionLanguage as follows...
public PermissionLanguageData getPermissionLanguage(int index) {
while(index =records().size() ){
this.records.add(new PermissionLanguageData());
}
return
Thanks Oliver for the reply..I did look into this and as u said, this is the
way...But I have another question..
Is there any way to directly convert from HTML or JSP to pdf?I mean why do i
have to write xsl again just to create the page layout when I do already have
the page layout created
Hi all,
I have following requirement in our struts application.
.After user does a query on database,a set of records is returned to him on
screen in a table format.He can then ask the same data to be given in PDF
format so that he can print it.
My question is what is the best way to do this?
Hi Amit,
The clear way of doing this would be in the action class.So the action class
should retrieve the data from session and set it on the beanThe bean itself
should not have the logic of retrieving the data
-Original Message-
From: amit [mailto:[EMAIL PROTECTED]]
Sent:
HI,
From the stack trace it seems that it is not finding the core classes for
catalina...I had similar problems with my laptop and I solved it somehow..I
dont remember exactly but vaguely this is what i did.(But i am using tomcat
4.1.12 and Eclipse 2.0 )
Go to wnodow-preferences-plugin
use html:image tag...
And generate the path dynamically something like...
%!String imagePath=; %
%imagePath=session.getAttribute(path);//can be any logic u have to generate
the image path...Better if u can put this logic in action and put just the path
attribute on form:-)) ...%
html:img
there are some example jsps with struts 1.0.2 download..It has examples of
usage of most of the tags including texttag..
regards,
shirish.
-Original Message-
From: usha [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 19, 2002 7:01 AM
To: struts-user
Cc: usha
Subject: html tablib
yes..the form bean which was submitted contains the previous data..But the data
which u are going to put on screen will not necessarily be in same form
bean(mostly in another form bean)and also will be rendered by another
actionso the data processing action and data populating action are
U r first Q ,I dont know ...But abt 2nd may be i have some suggestion form my
experience with struts ..
2. What is the standard way to pass data from Action objects to the JSP
(view)? Should the data be sent as a) Session properties, b) Some bean
objects, or c) Data members of the Action object?
aabe breakpoint set hoto ka bagh bare ..tomcat cha source code aahe ka?
mi pan baghato ethe kahi milate ka te..
-Ojava.lang.NullPointerException
at java.util.Hashtable.get(Hashtable.java:329)
at
org.apache.commons.logging.LogFactory.getCachedFactory(LogFactory.java:502)
check documentation for html:form tag...
-Original Message-
From: Mohammed.Rafeeq [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 18, 2002 1:44 PM
To: struts-user
Subject: how to give form name in struts?
hi all ,
i'm a newbie.
how to give the form name when using struts-html.tld
do some thing like...
public static void logErrorOnce(ActionErrors errors, String errorKey) {
if (errors.get(errorKey).hasNext() == false) {
logError(errors, errorKey);
}
}
-Original Message-
From: vasilenko
Should I use request.getSession(false) to check if session is
timeout? If so, that means for every request, it will check if session is
invaildate. Will it cause performance problem? If not, which methods
should I call to check it?
That is the only way to know if the session is invalid..(or
Hi Doug/Justin,
Actually we had similar problem..We wanted to use a global forward if the user
is not logegd in so that he can be thrown to login page or any other page which
is configurable..And that is the reason we choose to include the login check in
our applications abstract action as you
struts 1.1 already supports that.But I am not sure if u want to use struts 1.1
as of yet as its not that stable
But we are using struts 1.0 for a fairly large application (some 300 pages and
150 actions).As u said, struts config becomes big and managing it in a big team
is a bit of problem
Hi,
Struts uses HTTpRequest object as it is.So it behaves exactly the same like a
httpRequest(VAlid for one http transaction...Available form the time the client
sends a request to the server till the response is commited).Also it will be
available if u do any forwards etc.
What is it exactly
Cannot find bean null in request scope
Where do u get this message?Do u mean when the validation fails u get this
message after forwarding to the jsp?
In using System.out.printlns() to debug the application, the validate
receives
the ActionMapping object and HttpServletRequest objects as
no..The request object is no0t modified in any way apart from the fact that the
errors object is kept in the request object so that it can be resued laeter by
errors tag
-Original Message-
From: jrgermany [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 16, 2002 5:57 PM
To:
Hi,
The problem has to do with java beans specification 1.01 section 8.8
The mechanism used by java beans introspection to derive method names from
property names is like this.
1.Append get/set to peoperty name and capitilise first letter of property.(e.g.
for a property name, method names
Also i dont understand why u need to access the request directly.I mean why are
u setting all the collections as request attributes.GEnerally I think the good
design is when u r FormBEan represents the screen data.So in this case whatever
u need on screen will become attribute of form.
I know
Hi,
There are many ways of doing this.So first is as the collection is being
displayed on screen,make it an attribute of form and popolate it in action on
form.So in jsp u will access like a form attribute.
But the problem with this approach is If u get an error and forward back the
user to
search the mailing list archive for Token mechanism in Struts:
U will find teh answers...a few very good mails...
-Original Message-
From: akriger [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 13, 2002 4:09 PM
To: struts-user
Cc: akriger
Subject: a question about transaction tokens
Hi Gopi,
Why do u need to use the same instance of form bean as from BAsicSearch.jsp?
DO u mean that, when u get search results, U still want to maintain what the
search creteria was and allow the user to search again by modifying some or all
of the search creteria?
BEcause generalayy U dont
try using html:options instead..and supply it with the collection or array of
indexes...
because if in html:select u specify property attribute, and the property is
there in the request(which should be the case when u forward the request back
to same jsp with errors..),the same is used to
Hi,
If I'm understanding what you are doing correctly, doesn't this make
the logging level global to all logging in your application? The
approach Struts uses internally (essentially a category name per
class) lets you make much more fine grained decisions about wanting
DEBUG messages from
Hi,
There was a problem in the sample FOrm Bean code I have given.
The getEmployee (int Index){
}method should be modified as follows
/*
instead of if(index = beanList.size()){
beanList.add(new Employee());
}
now I have made it
while(index =
I had not checked this.Had taken what log4j documentation says about
performance verbatim...
BTW,I didnt get your comment about
**
In particular, under a Tag library for Tomcat 4.0.X [where tags are not
reused]
*
Are the tags reused on other servers?
And what do u mean by
Hi,
I had similar functionality.But I will advice u not to use html:text
disable=true/ because it does not work with Netscape.
So instead i used logic:equal tag and bean write.
logic:equal name=OrganizationSession property=isProvider value=true
html:text name= property=/
If u dont want to wory about netscape then i think u can go the other way.And i
Am talking about netscape 4.77.
So in the other case u can use logic equla in just one place as u said.
%!String isDisbled=false%
logic:equal name=OrganizationSession property=isProvider value=0
The property can be used if you want to display the error message next to a
specific field on the jsp page.
So after the form adds the errors, on the resulting jsp, if u have something
like
html:errors property=CG_Branch html:text blah blah.. wil make the error
to be displayed next to the
I think the errors are saved in session not in form.
-Original Message-
From: MohanR [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 09, 2002 7:27 AM
To: struts-user
Cc: MohanR
Subject: RE: Question about adding ActionErrors
Hi,
We are validating against the database in the
Just some addition to this logging discussion.
If u are using log4j , then in any case,there wil be 1 instance per class and
not per object.BEcause logger instances are named entities and they are
cached.So if u ask for the same logger again(same class name I mean), u will
retrieve same
What do u mean by executing the jsp?
The way u have done configuration, there will not be any problem if u are
calling the CustomerAction and the CustomerAction action is doing a forward to
the jsp.
BEcause then only the form bean will be available.
How u are executing the jsp?
-Original
No.U are not getting it right.
U should understand the flow of struts for this.
For the bean to get instantiated, it has to associated with some action.
And from u r config file, it looks that u have mapped the form to /customer
action.So if u call this customer action first, then in the action
if u cans end sample code(the form classs relavent code and jsp), may be
somebody can help u...
But there is no reason for struts to impose any such restriction ..
-Original Message-
From: dwang [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 09, 2002 3:28 PM
To: struts-user
Cc: dwang
I think u should use struts tags only when there is no corresponding jstl tag..
reason being jstl is THE STANDARD tag library...SO stick to it as far as
possible ...
-Original Message-
From: agrawalanuj [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 09, 2002 3:29 PM
To: struts-user
there are some posts in the mailing list archive on struts:el tags which
discuss the same..
-Original Message-
From: agrawalanuj [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 09, 2002 3:45 PM
To: struts-user
Cc: agrawalanuj
Subject: RE: newbie question - tags in JSTL vs Struts
There are 2 approaches to this problem .
For the perticular action, change the input mapping to the action u want to
forward control to in case of error(which in your case will be the error
handler action which repopulates the data in the form from database and sends
back to same jsp).
And in
Hi,
U can definately do this.BEcause forward is nothing else but another java
object.So u can put it in session scope(i will prefer request scope if its just
to share between 2 actions which are handling same request).Also about handling
it in servlet i dont think it is a good idea as this is
I forgot to add one more thing.
U had also mentioned that the form has the logic to get the list data from
database.
In our project we had lot of problems because some of the forms were directly
getting data from database to populate lists etc in case of errors.
So i will say that you should
Hi,
If u are displaying the screen as text fields(using html:text tag),what ever u
show on screen will be retained as all the data gets resubmitted back and
struts repopulates teh form again with the data.
But if u are showing a read only data on screen using bean:write tag,then the
data will
use logic iterate tag.
And use the indexid attribute to decide whether its even or odd row..
I think the type of IndexId Bean is Integer (or BigDecimal).So get value from
it.
%!int index=0;%
%!boolean show=false;%
logic:iterate name=myForm property=beanList indexId=i
% show = (index ==
Ok.I got your problem.
But as U dont want to put the collection in session , the only way out is to
get it back from model and populate it in the form before sending it to jsp.
I think in such case if u dont want to keep the list in session but repopulate
it on validation error(Like a country
Hi,
To ensure that The same form is being shared,u neeed to make sure that the name
and scope attributes for both the actions are same.
And in As the second point VEDRE mentioned, u dont ned to keep the form in
the session scope as the actions are directly called one after another so are
Hi,
I have implemented pretty much the same functionality in our application.
U can do this using Struts actions.When the user presses a button,call an
action.In the action add an empty row to the form(add a empty object to the
list on form).And then call the same jsp which will just iterate
yes..U are right...
-Original Message-
From: donl34 [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 03, 2002 2:57 PM
To: struts-user
Cc: donl34
Subject: Multibox
Hello,
I'm using struts 1.0.2.
I would like to present an input form on a jsp and part of that would be to
display a
What u mean by dynamically generating a form?
Its a normal form(Extends ActionForm).
And the action to deal with will be what ever action u define to achieve this
functionality.It will be a very simple action.
Home this clarifies the confusion.
regards,
Shirish
-Original Message-
From:
Can you please explain how to use this attribute of action mapping?Do u mean
that if same form is defined with two diferent scopes and same name, still u
can reuse same instance,using attribute?
I checked the javadoc for attribuite of ActionMapping class.It does not give
much idea about how to
Hi,
Refer to yesterdays similar problem..Include an Action in a page.
I think if u want to include the result of a action in another jsp, using
jsp:inlude to call the action should work.But I have not tried this.But as
using jsp include U can call a servlet as well(Thats what the documentation
But how do i access Those different forms in The jsps ?because as far as i
know,I use the name attribuite from action mapping of action to get the
Formbean in jsps.And because of this, my understanding was that the forms are
stored using the name as key in thier required scopes.
So in this
Can u specify u r requirement please?
Because if U need to show the output of 2 actions on the screen , still they
can use the forwards and use request as a shared container to pass along any
data beans.
but hwy a template needs to include action?
-Original Message-
From:
I have not tried this but think this should work..
1: In Action 1, after getting the data,U say return
maping.findForward(success);
2: success forward does a forward to u jsp1...
In jsp1,U first display data given by action1.
3: thenm after that u do a jsp:inlude which calls action 2.
4:action
Hi Amit,
I think the struts way will be to define 3 different mappings to call the
action class from the 3 different jsps.And in each mapping define
parameter=jsp1 ,parameter =jsp2 etc.
In actiin class u can do,
String reqSource = mapping.getParameter();So this helps u to decide the request
U need to put the scriptlet code also in double quotes...
logic:iterate name=causeCodeTable
property=causeCodeTable
offset=%=causeCodeTable.getCurrentIndex()%
length=%=causeCodeTable.getMaxDisplayValue()%
If you are sure that 0 or 0.0 is never a valid value, one way of avoiding this
will be to use struts logic:notEqual tag.
logic:notEqual name=FromBeanA property=age value=0
Age = html:text name=FromBeanA property=age /
logic:notEqual
-Original Message-
From: kpbhat [mailto:[EMAIL
can you please explain the problem preperly?
If u are showing the list using html:text and pressing submitting button then
there is no reason why the values will not be passed over.But as u are on the
same form , all the rows will be submitted instead of just the one from where
the button is
HI,
I think u are suggesting that every form has to be in session scope which is
dangerous and will unnecessarily clog the session object.
If u have problems when calling setters on u r form because the list on form is
smaller, i will suggest following approach.
public class MyForm {
Hi,
I didnt understand your problem very well.But some points U should know.
I use the log4j, and the constructor of the ActionForm isn't
called. The set for the ArrayList isn't called too.
Struts uuses Class.forName() .newInstance() to instantiate new form objects.
So the default
81 matches
Mail list logo