RE: No Of rows in a Table

2002-06-09 Thread Vikram Goyal01

There is a jsp tag library for pagination. Search this mailing list and I think you 
should find it. That will give you a start on it.

Vikram

-Original Message-
From: Sudhir S. Shetty [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 12:18 PM
To: Struts Users Mailing List
Subject: No Of rows in a Table


Hi Everybody,
   I have a rquirement in which I have a Table
displayed, For this I retrieve The table rows from the database, But the
table should just list the first 20 records, a functionality should be
proivided via which on clicking the NExt Button the user is displayed the
next 20 records and so on, I would be greatful if you could provide me with
adequate resources for it.
Thanks in advance,
Sudhir


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




No Of rows in a Table

2002-06-09 Thread Sudhir S. Shetty

Hi Everybody,
   I have a rquirement in which I have a Table
displayed, For this I retrieve The table rows from the database, But the
table should just list the first 20 records, a functionality should be
proivided via which on clicking the NExt Button the user is displayed the
next 20 records and so on, I would be greatful if you could provide me with
adequate resources for it.
Thanks in advance,
Sudhir


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Is there a cleaner way to get this information?

2002-06-09 Thread Rick Reumann



I have a select option list that is populated by a Collection of
"UserType" beans. At the very least my Action Form( DynaActionForm
actually) will need to get populated with the "userTypeId" and the
"userTypeName" of the UserType selected from this selection list.

I know this should be easy but what is the cleanest way to accomplish
getting this userTypeId and userTypeName information?

The way it set now is I gave my Form Bean an indexId attribute and
this is what I pass to my Action. Then in the Action I pull the
correct UserType from the collection based on this index value and
then I manually set the DynaActionForm properties in my action and put
this DynaActionForm into request scope, so the next forwarded page can
add to the DynaActionForm.

Although the above works, I'm wondering if there are better ways to
handle what I'm trying to accomplish. My Action form (which extends
DispatchAction) is going to start getting REALLY big awfully quick if
I have to this kind of stuff a lot:

//get the UserTypeDTO selected from drop down based on the index
//in drop down
UserTypeDTO userTypeDTO = 
(UserTypeDTO)userTypesList.get( userTypeIndex );
int userTypeId = userTypeDTO.getId();

//set the dyna form attributes with DTO attributes
f.set( "userTypeId", String.valueOf( userTypeId ) );
f.set( "userTypeName", userTypeDTO.getDisplayName() );

//add form to request and pass on to choose unit information page
request.setAttribute( "userTypeForm", f );

//forward to appropriate page for choosing information
if ( userTypeId == 1 || userTypeId == 2 || userTypeId == 3 ) {
return mapping.findForward( "unitStoreOrJvp" );
}
if ( userTypeId == 4 ) {
return mapping.findForward( "rvp" );
}
if ( userTypeId == 5 ) {
return mapping.findForward( "other" );
}
else {
//add some ActionError stuff here first
return mapping.findForward( "error" );
}

--

Rick

mailto:[EMAIL PROTECTED]

"Instead of studying for finals, what about just going to the Bahamas
and catching some rays? Maybe you'll flunk, but you might have flunked
anyway; that's my point."
  -Jack Handey


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Accessing ActionErrors in jsp????

2002-06-09 Thread James Mitchell

Take a look at the source code for the ErrorsTag:
org.apache.struts.taglib.html.ErrorsTag.java

This would be your best bet for doing what you require.


James Mitchell
Software Engineer\Struts Evangelist
Struts-Atlanta, the "Open Minded Developer Network"
http://struts-atlanta.open-tools.org

> -Original Message-
> From: Pete Serafin [mailto:[EMAIL PROTECTED]]
> Sent: None
> To: [EMAIL PROTECTED]
> Subject: Accessing ActionErrors in jsp
> 
> 
> I am writing a custom tag to format my form errors.  The problem I am 
> having is I dont understand how to retrieve the ActionErrors that are 
> created in my Action class and added to the request object that 
> forwards to my jsp pages.  Can someone explain how to get access to 
> this object in the jsp so I can pass it to my custom tag?   Thanks,
> 
> 
> Pete Serafin
> 
> 
> --
> To unsubscribe, e-mail:   
> 
> For additional commands, e-mail: 
> 
> 
> 

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Accessing ActionErrors in jsp????

2002-06-09 Thread Pete Serafin

I am writing a custom tag to format my form errors.  The problem I am 
having is I dont understand how to retrieve the ActionErrors that are 
created in my Action class and added to the request object that 
forwards to my jsp pages.  Can someone explain how to get access to 
this object in the jsp so I can pass it to my custom tag?   Thanks,


Pete Serafin


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: User Authentication

2002-06-09 Thread @Basebeans.com

Subject: Re: User Authentication
From: "Vic C." <[EMAIL PROTECTED]>
 ===
This is  web container or a JAAS question.
It is hard to say based on your e-mail if you already did it or you are 
asking how.
Typically, after the Struts application is constructed, JAAS is added. 
Any Servlet 2.2 or Servlet 2.3 container has container based security.
What container are you using?
You would specify the JDBC relm table where the user id is stored.
In web xml you add a ,  and 
. It will intercept request to a protected resource, 
authenticate and then forward to requested page for you. 0 code!
http://www.onjava.com/pub/a/onjava/2001/07/24/tomcat.html
After you read up on JAAS and implement above feel free to ask again.

To extend JAAS is easy. You can use a Servlet API to find the users role 
and or name. (Based on that, you can enable and disable menu items in 
Struts-menu. If there is more info, I create a bean in session that is 
populated based on users role or name).
The thing about row based security is that it is the same screen and 
fields that display different information. So the thing to do is have 
your action send the users role or name to the model. The model would 
then, in addition to your regular where, append a where user_id = ?, 
thus only hits would return.
basebeans.com/book.jsp chapter 16 shows how to do row based security.

This is  web container or a JAAS question.
Did I say that already? Everyone ends up following the very old example 
of the Struts sample application and writing the login screen when the 
web container does it for you. CRUFT.

Hth,
Vic


David Bolsover wrote:
> Hi all
> 
> I have a Struts based app to which I need to add some moderately complex
> user access privileges.
> 
> At present, users log-in using  form based authentication and I then place a
> User object in session scope which is checked when a user requests a
> particular set of data to find out if the request is legal.  Currently, the
> checks are just on product codes but this needs to be extended - see below.
> 
> All data is held in a centura database
> 
> Each user can access an individual customer account; each customer has
> several product codes, each product code may have several products - I need
> to be able to control the access each user has to the system in a reasonably
> fine-grained manner.
> 
> Also, there are users who can access supplier accounts in similar fashion
> and there may be a future requirement for file access privilileges to be
> defined.
> 
> Does anyone have any experience of systems that feature this type of access
> control?
> 
> If so, any hints and tips would be welcome.
> 
> regards
> 
> David Bolsover
> [EMAIL PROTECTED]
> 
> 


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




User Authentication

2002-06-09 Thread @Basebeans.com

Subject: User Authentication
From: "David Bolsover" <[EMAIL PROTECTED]>
 ===
Hi all

I have a Struts based app to which I need to add some moderately complex
user access privileges.

At present, users log-in using  form based authentication and I then place a
User object in session scope which is checked when a user requests a
particular set of data to find out if the request is legal.  Currently, the
checks are just on product codes but this needs to be extended - see below.

All data is held in a centura database

Each user can access an individual customer account; each customer has
several product codes, each product code may have several products - I need
to be able to control the access each user has to the system in a reasonably
fine-grained manner.

Also, there are users who can access supplier accounts in similar fashion
and there may be a future requirement for file access privilileges to be
defined.

Does anyone have any experience of systems that feature this type of access
control?

If so, any hints and tips would be welcome.

regards

David Bolsover
[EMAIL PROTECTED]



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: getServlet()?

2002-06-09 Thread Ted Husted

The ActionServletWrapper class was provided as a security patch. As
such, it takes the stances that we should start by shutting everything
down, and then open things up as needed. 

Off-hand, wanting to access servlet initialization parameters in
validate() sounds like a reasonable use-case. If you want to post a
patch to bugzilla, I'll see if we can do something about a 1.0.3
release.

-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services


Geoffrey Corb wrote:
> 
> I have been attempting to update a project from Struts 1.0 to 1.0.2 to
> resolve some file upload problems.  Now, I've found that the ActionForm's
> getServlet() method no longer exposes the ActionServlet.  This is especially
> problematic to me, since a fair number of our ActionForm-derived classes use
> the ActionServlet to get at the ServletContext in their validation scripts.
> Is there a workaround possible?  I'm trying to retrieve initialization
> parameters from the ServletContext in the validate() methods of my
> ActionForm-derived classes.
> 
> Another question:  What good is the ActionServletWrapper when it *barely*
> wraps the ActionServlet class?  I understand wanting to "prevent public
> String properties of ActionServlet from being changed via a query string"
> (quoted from release notes), but why not provide access to other, relatively
> important, methods, like getServletContext()?
> 
> - G. Corb
> 
> This communication, including attachments, is for the exclusive use of
> addressee and may contain proprietary, confidential  or privileged
> information. If you are not the intended recipient, any use, copying,
> disclosure, dissemination or distribution is strictly prohibited. When
> addressed to our clients any opinions or advice contained in this email are
> subject to the terms and conditions expressed in the governing Synergenic
> client Agreement.

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re[2]: best way to put index of collection in option(s) tag ?

2002-06-09 Thread Rick Reumann

On Sunday, June 9, 2002, 11:10:21 AM, Sandeep Takhar wrote:

ST> It seems to me that having the index is very similar to having a
ST> primary key.  So maybe what you add to the collection should be
ST> given a primary key which may just be the index into the
ST> collection.

I'm not so sure it's really like a primary key, since it's only
the index of place in the Collection the bean resides. (It
obviously could vary when the sort changes).

Also another issue is the Collection is populated in the business
layer in the DAO, so does it really make sense for the bean to
have a field for an index that 'might' get populated if it's used
in a Collection? (I'm not saying it doesn't make sense, just
thinking aloud ).

[original post below:]

ST> --- Rick Reumann <[EMAIL PROTECTED]> wrote:

>> What is the best way to put the index value of a
>> collection in a
>> select options list? I'm currently doing this:
>> 
>> > property="userTypeId">
>>   > indexId="index" >
>> 
>>   > property="displayName"/>
>> 
>>   
>> 
>> 
>> I don't like the above since it requires the
>> scriplet. I suppose I
>> could give my form bean an indexId attribute so when
>> it's populated
>> into the collection I later could do:
>> 
>> > property="userTypeId">
>>   >   property="indexId"
>> labelProperty="displayName"/>
>> 
>> 
>> The later seems cleaner in the presentation view but
>> for some reason
>> it doesn't sit right with me for a bean to have to
>> keep a field for
>> knowing what place it might hold in a Collection. I
>> take it I'd also
>> have to call setIndexId( i++ ) or something similar
>> whenever I add
>> these beans to the collection. Seems like that
>> shouldn't be something
>> a bean should have to worry about, but I'm probably
>> wrong:)
>> 
>> How do you guys handle this?
>> 
>> TIA
>> 
>> --
>> 
>> Rick
>> 
>> mailto:[EMAIL PROTECTED]
>> 
>> 

--

Rick

mailto:[EMAIL PROTECTED]

"If you go parachuting, and your parachute doesn't open, and you
friends are all watching you fall, I think a funny gag would be to
pretend you were swimming."
  -Jack Handey


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Cannot get html:select working with collections stored in request

2002-06-09 Thread Craig Laverty

In all of the examples that showed html:select it never said that you must
use the struts html:form on the jsp.  I fixed my problem by putting this on
the page.

Craig.


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




[ANN] Powered by Struts / Struts Consultants

2002-06-09 Thread Ted Husted

Regarding the Struts Resources page


Please note that as of 2002-Jul-15, pages linked as Struts Consulants
must specifically mention that their services include Struts consulting.
Listings that do not reference Struts will be removed.

As of 2002-Jul-31, pages linked as Powered by Struts must credit Struts
using the product's logo (or equivalent) OR credit the Apache Software
Foundation pursuant to item 3 of the Apache Software License
 ("This product includes software developed
by the Apache Software Foundation (http://www.apache.org/).

-Ted.

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Struts PowerPoint presentation

2002-06-09 Thread Roman Rytov

Is there a way to map image's url and alt text into a resource file (like messages)? 

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: best way to put index of collection in option(s) tag ?

2002-06-09 Thread Sandeep Takhar

It seems to me that having the index is very similar
to having a primary key.  So maybe what you add to the
collection should be given a primary key which may
just be the index into the collection.

sandeep
--- Rick Reumann <[EMAIL PROTECTED]> wrote:
> What is the best way to put the index value of a
> collection in a
> select options list? I'm currently doing this:
> 
>  property="userTypeId">
>indexId="index" >
> 
>property="displayName"/>
> 
>   
> 
> 
> I don't like the above since it requires the
> scriplet. I suppose I
> could give my form bean an indexId attribute so when
> it's populated
> into the collection I later could do:
> 
>  property="userTypeId">
>  property="indexId"
> labelProperty="displayName"/>
> 
> 
> The later seems cleaner in the presentation view but
> for some reason
> it doesn't sit right with me for a bean to have to
> keep a field for
> knowing what place it might hold in a Collection. I
> take it I'd also
> have to call setIndexId( i++ ) or something similar
> whenever I add
> these beans to the collection. Seems like that
> shouldn't be something
> a bean should have to worry about, but I'm probably
> wrong:)
> 
> How do you guys handle this?
> 
> TIA
> 
> --
> 
> Rick
> 
> mailto:[EMAIL PROTECTED]
> 
> 
> --
> To unsubscribe, e-mail:  
> 
> For additional commands, e-mail:
> 
> 


__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Struts PowerPoint presentation

2002-06-09 Thread Ted Husted

There is also 

http://www.computer-programmer.org/articles/struts/

Anders Rosén wrote:
> 
> Hi,
> 
> I will teach JSP for a group of ASP developers next week. Nice challenge
> ;-) I have the Java and JSP material ready to go, but I would like to
> introduce MVC as good way of building (web) applications. And what could
> be better than to use Struts as a reference for the architecture.
> 
> Preparing and compiling training material is tedious, and that's why I
> post here. Has anyone on the list compiled a PowerPoint on Struts?
> Covering the basics, including some basics about coding and
> configuration of Struts? And who wants to share the work?
> 
> "Every PowerPoint presentation is true, for certain values of true"
> 
> Regards,
> /Anders
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 

-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: XML/XSLT Question - Help!

2002-06-09 Thread Ted Husted

You might want to check this out:

http://www.openroad.ca/opencode/

Spencer Smith wrote:
> 
> I have a question regarding the use of XML/XSLT.  Please correct me if I am
> wrong, but it is my understanding that XML does not directly support
> graphics.  Apparently, a new XML standard called SVG is currently being
> reviewed by w3 for approval (hasn't been adopted yet) which uses scalable
> vector graphics to display a page, which is pretty cool, but even that
> doesn't directly support the use of gifs and jpgs unless you convert all the
> graphics to vector graphics (svg format)
> 
> Is this true, or can I place graphics in XML and then define them in the XSL
> doc?  If so, is this an acceptable technique?
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 

-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Cannot get html:select working with collections stored in request

2002-06-09 Thread Craig Laverty

I forgot to say I am using struts-b1.1.



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Cannot get html:select working with collections stored in request

2002-06-09 Thread Craig Laverty


In my jsp I cannot get the following to work:






In the exact same jsp this does work:






In my action I am setting the keywords attribute to the request scope.
request.setAttribute("keywords",keywordlist);

The error I get is:
javax.servlet.ServletException: Cannot find bean under name
org.apache.struts.taglib.html.BEAN


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Advice: how strutty should I be??

2002-06-09 Thread Andrew Hill

I had a bit of a look at a the javaworld example, and had also seen the stxx
example. Alas as is too often the case I simply didnt have enough time to
fully examine them (especially stxx - which is a pity as I rather liked the
look of it.) :-(
XSLT has many advantages but didnt seem intuitively suited to what I was
doing, and perhaps more importantly I lacked sufficient time to learn the
syntax of XSLT.

Our project is a quite complex application as opposed to say a website and
xslt and things such as velocity seemed better suited to more static
content - though Im probably wrong about that right? ;-)
I also wanted to make use of resource bundles as we will be targeting
markets in languages other than English. Didnt immediately see how best to
do that using xslt though Im sure its possible.

I noticed a few posts a month or so ago about problems with certain
characters in BIG5 causing problems when used in resource bundles. Any good
places I should look  for info on this?


I ended up deciding to use xmlc (which Barracuda leverages to great effect)
and ended up ditching it halfway through our second iteration due to a whole
bunch of showstopping bugs I was unable to find a way to workaround

However, I found myself still rather enamoured of the idea of doing DOM
manipulation  on the server end to insert dynamic content
into the layout document and hence went and developed my own code to obtain
the Documents from xhtml files.
We are following a somewhat iterative approach of prototyping our look &
feel as we go along which is one of the reasons I didnt want my dynamic
content rendering mixed in too much with the more static layout much of
which is chrome.
The ultimate goal of course is to have the dynamic rendering very
independant of the structure of the layout xhtml, however in practice my
rendering code still knows more than I would like about the structure of the
document (ie: is something a table cell node or a span node etc...).
As I go along Im factoring out wherever I can and so my rendering framework
is starting to get quite a library of generic methods.

-Original Message-
From: Ted Husted [mailto:[EMAIL PROTECTED]]
Sent: Sunday, June 09, 2002 20:34
To: Struts Users Mailing List
Subject: Re: Advice: how strutty should I be??


If you haven't seen them already, be sure to check out

http://www.javaworld.com/javaworld/jw-02-2002/jw-0201-strutsxslt.html

and

http://www.openroad.ca/opencode/

Right now, stxx extends ActionForward, ActionServlet, and Action to help
with XLM/XLS transformations. The ActionForward extension is a block of
transform tags that specify which xls to use. This gives you a chance to
swap in another xls for a given user-agent. So, you have something like
this

 
  
  
  
 

It would be even neater, I think, if the transformation code in the stxx
ActionServlet were moved to it's own servlet, that loaded the
transformation tags from its own config. The ActionForward could then
refer to an URI like "login.stx". On the xls-servlet side, you would
then have something like



  
  
  



Since Struts exposes its resources through the standard contexts, any
servlet can gain access to them, the same way the custom tags do through
the RequestUtils. While a lot of Struts developer use JSPs, they have no
special preference within the core framework. Any servlet in the
application has the same access to Struts as a JSP custom tag does.

The stxx Action extension adds a function that you can use to save a XML
document to the request, for later processing. But I believe you could
do the same thing with a static class.

The Struts website is written using XML and XLS. It would be neat to see
more tools that would let us do XML/XLS transforamtions dynamically,
instead of only using static HTML pages tranformed in an Ant build
process.

Another worthy XLS implementation for web apps is Maverick.

http://mav.sourceforge.net/

-T.


Andrew Hill wrote:
>
> Thanks for the response Ted :-)
>
> I ended up implementing it using a servlet which will call my renderers
> (helper classes that perform 'DOM surgery') and this rendering servlet
takes
> care of the code to output the dom tree as xhtml to the browser.
> The action chooses which renderers to use (Im still rather uneasy about
the
> amount of knowledge this implies the actions having about the view, but
alas
> my tight schedule prohibits me from giving it too much more thought at
this
> stage) and forwards them to the rendering servlet.
>
> Im glad to see I had chosen the option you recommend. :-)
>
> thanks
> Andrew
>
> -Original Message-
> From: Ted Husted [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, June 09, 2002 18:36
> To: Struts Users Mailing List
> Subject: Re: Advice: how strutty should I be??
>
> The Action can render the response when convenient. The Struts reload
> Action in 1.0.x does this to print "OK" after its complete. It can also
> be convenient to have an Action do something like render XML for use by
> another sy

Re: Advice: how strutty should I be??

2002-06-09 Thread Ted Husted

If you haven't seen them already, be sure to check out 

http://www.javaworld.com/javaworld/jw-02-2002/jw-0201-strutsxslt.html

and 

http://www.openroad.ca/opencode/

Right now, stxx extends ActionForward, ActionServlet, and Action to help
with XLM/XLS transformations. The ActionForward extension is a block of
transform tags that specify which xls to use. This gives you a chance to
swap in another xls for a given user-agent. So, you have something like
this 

  
  
   
   
   

It would be even neater, I think, if the transformation code in the stxx
ActionServlet were moved to it's own servlet, that loaded the
transformation tags from its own config. The ActionForward could then
refer to an URI like "login.stx". On the xls-servlet side, you would
then have something like 



   
  
   
   



Since Struts exposes its resources through the standard contexts, any
servlet can gain access to them, the same way the custom tags do through
the RequestUtils. While a lot of Struts developer use JSPs, they have no
special preference within the core framework. Any servlet in the
application has the same access to Struts as a JSP custom tag does.

The stxx Action extension adds a function that you can use to save a XML
document to the request, for later processing. But I believe you could
do the same thing with a static class. 

The Struts website is written using XML and XLS. It would be neat to see
more tools that would let us do XML/XLS transforamtions dynamically,
instead of only using static HTML pages tranformed in an Ant build
process. 

Another worthy XLS implementation for web apps is Maverick.

http://mav.sourceforge.net/

-T.


Andrew Hill wrote:
> 
> Thanks for the response Ted :-)
> 
> I ended up implementing it using a servlet which will call my renderers
> (helper classes that perform 'DOM surgery') and this rendering servlet takes
> care of the code to output the dom tree as xhtml to the browser.
> The action chooses which renderers to use (Im still rather uneasy about the
> amount of knowledge this implies the actions having about the view, but alas
> my tight schedule prohibits me from giving it too much more thought at this
> stage) and forwards them to the rendering servlet.
> 
> Im glad to see I had chosen the option you recommend. :-)
> 
> thanks
> Andrew
> 
> -Original Message-
> From: Ted Husted [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, June 09, 2002 18:36
> To: Struts Users Mailing List
> Subject: Re: Advice: how strutty should I be??
> 
> The Action can render the response when convenient. The Struts reload
> Action in 1.0.x does this to print "OK" after its complete. It can also
> be convenient to have an Action do something like render XML for use by
> another system.
> 
> It's just that using Actions to render the presentation is not resusable
> in an another environment. In most cases, it's just as easy and much
> cleaner to use another servlet to render the response. The coding effort
> is equivalent, and you then have the ability to use the servlet outside
> of Struts.
> 
> This also corresponds to how Struts works with other presentation
> systems. JSPs are glorified servlets, and JSPs are not part of Struts.
> The framework just provides some tags that interact with framework.
> Likewise, Velocity provided a servlet and toolset that works with the
> framework but acts as an independently. If you are using your own
> presentation system with Struts, I'd recommend following the same
> approach and using your own servlet rather than tweaking-out an Action.
> 
> But, again, it's a matter of degree. If you just need to pop out some
> text or XML, go for it. But if there is other processing to do be done
> on the stream before it is rendered, get it out where it can be reused.
> 
> -- Ted Husted, Husted dot Com, Fairport NY US
> -- Developing Java Web Applications with Struts
> -- Tel: +1 585 737-3463
> -- Web: http://husted.com/about/services
> 
> Andrew Hill wrote:
> > 
> > While Im on the subject, Ive got a generic servlet that does 'rendering'
> (or
> > more precicely invokes the render() method on a bunch of objects that the
> > action selects and forwards to it). However in this case , having a
> servlet
> > to do it seems a bit redundant, as an action already has access to all the
> > goodies a servlet gets - the most important of course being the response
> > object. Is there any particular reason I shouldnt simply invoke the
> > rendering code that is in my rendering class straight from my action and
> > write to the response there instead of forwarding to a servlet?
> > Or to rephrase it, - do we forward to a jsp or servlet from our action
> > because the action(s helper classes) are unable to execute the rendering
> > code (such as in the case of a jsp implemented view) or because its good
> > design to do it th

RE: Struts Validator

2002-06-09 Thread Robert Taylor

Thanks Peter and Raffy,

Using DispatchAction and the same ActionForm for common events helps reduce
the number of presentation framework classes and also allows me to reuse
business components.

After looking more closely at the code, it appears that validation for a
bean
is bound to the name attribute of the form element in the validation.xml
file.

It also appears that the bean field validation rules are extracted using the
name attribute of the form element in validation.xml and the the validation
is
performed on those fields defined in the bean that exists in the resources
under the Validator.BEAN_KEY key.

If this is the case, then it is possible to override
ValidationForm.validate() and pass the action mapping path as the "form
name"
and then validation for a bean could be bound to the action path instead of
the form name.


public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request) {

ServletContext application = getServlet().getServletContext();
ActionErrors errors = new ActionErrors();
Validator validator = StrutsValidatorUtil.initValidator(
mapping.getPath(), //mapping.getAttribute(),  <
use path instead of form name
this, application, request, errors, page);

try {

validator.validate();

} catch (ValidatorException e) {

   log.error(e.getMessage(), e);

}

return errors;

}

In this manner I could use the same form and apply different validation
according to the action mapping. I could further qualify validation for
fields using the page identifier.


This, of course, is speculation since I haven't tested it.


Is this possible?


robert

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 07, 2002 6:00 PM
> To: Struts Users Mailing List
> Subject: Re: Struts Validator
>
>
>
> I tend to think it's either you NOT use DispatchAction if you have
> different validation requirements for the same form. The validator ties to
> only one form per action and since DispatchAction is still considered a
> single action (with different delegated methods), then you are still bound
> to use only one set of validation rules for that form.
>
> Option 1
>
>  Use DispatchAction and implement your own validate() method for that
> form
>
> Option 2
>
>  Split your operations into different actions using the same form,
> define different rules in the validation.xml and have your form extend
> ValidatorActionForm like Peter suggested
>
>
>
>
>
> Peter Onthrops <[EMAIL PROTECTED]> on 06/07/2002 02:34:40 PM
>
> Please respond to "Struts Users Mailing List"
>   <[EMAIL PROTECTED]>
>
> To:   Struts Users Mailing List <[EMAIL PROTECTED]>
> cc:
> Subject:  Re: Struts Validator
>
>
>
> I think what you are looking for is handled by configuring validation.xml
> in this way:
> 
>   (maps to action path)
> 
>
>  
> 
>
> 
>
>
> Your Form bean should extend ValidatorActionForm. The Validator will only
> validate fields configured for the given action. Hope this helps.
>
> P.
>
>
>
>   Robert Taylor <[EMAIL PROTECTED]> wrote: I want to leverage the
> declarative validation functionality offered by the
> Struts Validator package, but I have some reservations about how it works.
> In my particular configuration, my application will use DispatchActions to
> process common events.
> In many cases I will use one ActionForm for all events being
> processed by a
> particular ActionForm. Since I won't be validating all fields in
> all cases,
> I want to only validate certain fields for a particular action
> mapping. The
> only way I can tell how to do this is to use the page data member of
> ValidatorActionForm to identify those fields that need be validated.
>
> The problem I see with this, is ...
> - for mapping A, I may want to validate field1, field2, and field3, and
> - mapping B, I only want to validate field1, but
> - mapping C, I want to validate field1 and field3.
>
> Is this possible to do using the validation.xml file. That is, can you do
> something like the following:
>
> ...
> ...
> ...
>
> where 1 = mapping for A,
> 2 = mapping for B,
> 3 = mapping for C
>
> If not, how is this possible? Is there a validator DTD I can reference?
>
>
> robert
>
>
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:
>
>
>
> -
> Do You Yahoo!?
> Sign-up for Video Highlights of 2002 FIFA World Cup
>
>
>
>
>
> **
> Please Note:
> The information in this E-mail message, and any files transmitted
> with it, is confidential and may be legally privileged.  It is
> intended only for the use of the individual(s) named above.  If you
> are the intended recipient, be aware that your use of any confidential
> or personal information may be restricted by state and federal
> privacy laws.  If you, the reader of this message, are not the
> int

RE: Advice: how strutty should I be??

2002-06-09 Thread Andrew Hill

Thanks for the response Ted :-)

I ended up implementing it using a servlet which will call my renderers
(helper classes that perform 'DOM surgery') and this rendering servlet takes
care of the code to output the dom tree as xhtml to the browser.
The action chooses which renderers to use (Im still rather uneasy about the
amount of knowledge this implies the actions having about the view, but alas
my tight schedule prohibits me from giving it too much more thought at this
stage) and forwards them to the rendering servlet.

Im glad to see I had chosen the option you recommend. :-)

thanks
Andrew

-Original Message-
From: Ted Husted [mailto:[EMAIL PROTECTED]]
Sent: Sunday, June 09, 2002 18:36
To: Struts Users Mailing List
Subject: Re: Advice: how strutty should I be??


The Action can render the response when convenient. The Struts reload
Action in 1.0.x does this to print "OK" after its complete. It can also
be convenient to have an Action do something like render XML for use by
another system.

It's just that using Actions to render the presentation is not resusable
in an another environment. In most cases, it's just as easy and much
cleaner to use another servlet to render the response. The coding effort
is equivalent, and you then have the ability to use the servlet outside
of Struts.

This also corresponds to how Struts works with other presentation
systems. JSPs are glorified servlets, and JSPs are not part of Struts.
The framework just provides some tags that interact with framework.
Likewise, Velocity provided a servlet and toolset that works with the
framework but acts as an independently. If you are using your own
presentation system with Struts, I'd recommend following the same
approach and using your own servlet rather than tweaking-out an Action.

But, again, it's a matter of degree. If you just need to pop out some
text or XML, go for it. But if there is other processing to do be done
on the stream before it is rendered, get it out where it can be reused.

-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services


Andrew Hill wrote:
>
> 
> Nah. JSPs are definately evil. They arent real (x)html, and they arent
real
> Java. (And of course as anything that isnt Java is by definition evil , so
> it follows that jsps... heheh)
> My main objection to JSPs is that they are inelegant (yes - I know thats
> strong language , but its true!). The struts taglibs make them a lot less
> inelegant and make developing apps with them a lot more straightforward,
but
> they remain ugly. I have a strong distaste for the idea of mixing the code
> and layout like that. html, scriptlets, tags that you have to rtfm before
> you know what they do..., all very messy and most it definately offends my
> artistic appreciation of the code.
> I feel it is much better to have the dynamic rendering be done using
proper
> clean java code, and the layout be done using good pure xhtml (with no non
> xhtml tags! (not that notepad really cares about tags anyhow hehe ;-> ))
> 
>
> We were making use of XMLC to achieve this, however Ive had to ditch it as
> the DOMs it creates have a very dodgy structure and dont even maintain the
> original nesting of elements correctly (not to mention still being glued
to
> a hacked version of xerces1.2 !). (I suppose this is what one gets for
> making use of stuff from Barracuda. At this point Im very glad I only
> decided to use the xmlc stuff, and stuck to good ol' struts for my
> controller framework!)
> Ive now written my own (well its not actually mine - the company owns
> everything we write) code which does lots of fun stuff to allow me to
obtain
> an org.w3c.Document (without having to type too much code or for the user
to
> wait forever for the parser to do its thing) and by manipulating this dom
I
> can insert the dynamic content in much the same way as one does it using
> XMLC.
>
> Its actually quite a good way to learn the inner workings of struts, as
> since Im not using jsps, Im finding myself taking lots of looks at the way
> the taglib source is coded so I can get similar functionality in my code.
> ;-)
>
> 
> While Im on the subject, Ive got a generic servlet that does 'rendering'
(or
> more precicely invokes the render() method on a bunch of objects that the
> action selects and forwards to it). However in this case , having a
servlet
> to do it seems a bit redundant, as an action already has access to all the
> goodies a servlet gets - the most important of course being the response
> object. Is there any particular reason I shouldnt simply invoke the
> rendering code that is in my rendering class straight from my action and
> write to the response there instead of forwarding to a servlet?
> Or to rephrase it, - do we forward to a jsp or servlet from our action
> because the action(s helper classes) are unable to execute the rendering
> code (such as in the case of a jsp 

Re: Advice: how strutty should I be??

2002-06-09 Thread Ted Husted

The Action can render the response when convenient. The Struts reload
Action in 1.0.x does this to print "OK" after its complete. It can also
be convenient to have an Action do something like render XML for use by
another system. 

It's just that using Actions to render the presentation is not resusable
in an another environment. In most cases, it's just as easy and much
cleaner to use another servlet to render the response. The coding effort
is equivalent, and you then have the ability to use the servlet outside
of Struts. 

This also corresponds to how Struts works with other presentation
systems. JSPs are glorified servlets, and JSPs are not part of Struts.
The framework just provides some tags that interact with framework.
Likewise, Velocity provided a servlet and toolset that works with the
framework but acts as an independently. If you are using your own
presentation system with Struts, I'd recommend following the same
approach and using your own servlet rather than tweaking-out an Action.

But, again, it's a matter of degree. If you just need to pop out some
text or XML, go for it. But if there is other processing to do be done
on the stream before it is rendered, get it out where it can be reused.

-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services


Andrew Hill wrote:
> 
> 
> Nah. JSPs are definately evil. They arent real (x)html, and they arent real
> Java. (And of course as anything that isnt Java is by definition evil , so
> it follows that jsps... heheh)
> My main objection to JSPs is that they are inelegant (yes - I know thats
> strong language , but its true!). The struts taglibs make them a lot less
> inelegant and make developing apps with them a lot more straightforward, but
> they remain ugly. I have a strong distaste for the idea of mixing the code
> and layout like that. html, scriptlets, tags that you have to rtfm before
> you know what they do..., all very messy and most it definately offends my
> artistic appreciation of the code.
> I feel it is much better to have the dynamic rendering be done using proper
> clean java code, and the layout be done using good pure xhtml (with no non
> xhtml tags! (not that notepad really cares about tags anyhow hehe ;-> ))
> 
> 
> We were making use of XMLC to achieve this, however Ive had to ditch it as
> the DOMs it creates have a very dodgy structure and dont even maintain the
> original nesting of elements correctly (not to mention still being glued to
> a hacked version of xerces1.2 !). (I suppose this is what one gets for
> making use of stuff from Barracuda. At this point Im very glad I only
> decided to use the xmlc stuff, and stuck to good ol' struts for my
> controller framework!)
> Ive now written my own (well its not actually mine - the company owns
> everything we write) code which does lots of fun stuff to allow me to obtain
> an org.w3c.Document (without having to type too much code or for the user to
> wait forever for the parser to do its thing) and by manipulating this dom I
> can insert the dynamic content in much the same way as one does it using
> XMLC.
> 
> Its actually quite a good way to learn the inner workings of struts, as
> since Im not using jsps, Im finding myself taking lots of looks at the way
> the taglib source is coded so I can get similar functionality in my code.
> ;-)
> 
> 
> While Im on the subject, Ive got a generic servlet that does 'rendering' (or
> more precicely invokes the render() method on a bunch of objects that the
> action selects and forwards to it). However in this case , having a servlet
> to do it seems a bit redundant, as an action already has access to all the
> goodies a servlet gets - the most important of course being the response
> object. Is there any particular reason I shouldnt simply invoke the
> rendering code that is in my rendering class straight from my action and
> write to the response there instead of forwarding to a servlet?
> Or to rephrase it, - do we forward to a jsp or servlet from our action
> because the action(s helper classes) are unable to execute the rendering
> code (such as in the case of a jsp implemented view) or because its good
> design to do it this way or becuase of some other gotcha I havent noticed
> yet?
> 

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Request attributes and frame sets.

2002-06-09 Thread Adam Hardy

Hi Keith,

I'm starting a project using frames so I'd be happy to try to help, but 
I don't quite understand what you are having a problem with. If I run 
through the probably obvious facts about frames & requests etc, I'll get 
to the point in your message I don't understand:

frames in a frameset send totally seperate requests and the only 
connection between them would be the session (or app.) scope

the request attributes are set only on the server side by application code

ActionErrors can only be stored in the request (you didn't mean session, 
did you?) otherwise the html:errors tag won't find them

You want the ActionErrors from the frameset request (& from all frame 
requests?) to appear in just one particular frame together

You are going to have a problem with timing which frame loads last, but 
you must manually save your frameset's & frames' errors into the session 
instead of the request, and then in the frame where they are meant to be 
shown, you will have to get them manually out of the session and save 
them into its request.

If my assumptions were correct, that should work, if that was what you 
really were asking!

Best regards

Adam



Paap, Keith wrote:

>I have a problem with request attributes when used with a frameset.  The
>design of the application I'm working with requires frames.  I'm not a fan
>of framesets but am trying to overcome some of the limitations...
>
>Many of the actions are actually targeted to _top to allow bookmarking, etc.
>The frameset then accesses request attributes to determine what JSP pages
>need to be loaded in what frames.  This all works fine.   However when the
>additional requests are made to the server to pull in the JSP pages that
>request does not carry along the request attributes for the JSP pages that
>load in the pages.
>
>For general application stuff we've worked around this by coming up with
>some custom objects to set attributes on the session and clean them out
>after they are used.  However I want to use the ActionErrors and
> tag.  From what I can tell this can only be set as a session
>attribute and given the design the tag cannot see that attribute on the JSP
>page since it's done as a separate request from the frameset. 
>
>Anyone have any ideas on how to make the request attributes available to the
>pages loaded in the frames?
>
>Keith
>
>--
>To unsubscribe, e-mail:   
>For additional commands, e-mail: 
>
>
>  
>



--
To unsubscribe, e-mail:   
For additional commands, e-mail: