Re: Digester: How to read the body of a tag?

2001-02-10 Thread Jens Rehpöhler

Hello Craig,

as always you gave the conclusive hint. Perhaps you should add an example of the usage 
of
this methods to the documentation. It would make things much more clearer.

thanks,

Jens

"Craig R. McClanahan" wrote:

 Jens Rehphler wrote:

  Hello Steven,
 
  I think I didn't described my problem correctly. Parsing the properties of a tag 
works
  well. But I want to parse the content between some tags. For example:
 
  database
  user propertie="name"
  textthis is the value i want to initialize my class with/text
  /user
  /database
 
  With the addSetProperties method I can parse the propertie of the user tag, but I
  can't parse the content between the text tag.

 The rules that are *supposed* to work for this would be:

 digester.addCallMethod("database/user/text", "setText", 1);
 digester.addCallParam("database/user/text", 0);

 Translated into English, these rules state that, whenever the specified pattern is
 encountered:
 * Set up a call to the setText(String text) method of the
   object on the top of the call stack
 * Set the zeroth parameter (i.e. the only one) to the
   body content of this element

 With other variations of the addCallParam() method, you can take parameter values 
from
 certain attributes of this element as well.

 Craig McClanahan






Re: bean-cookie.jsp

2001-02-10 Thread Matthias Kerkhoff

Hello Hal,

 The jsp 1.1 spec implies that the jsp:useBean tag does not need to be used
 before using jsp:getProperty.

That's correct. The 1.1 errata and the 1.2 spec make this even more explicit.

 Either the struts documentation should be changed to be less emphatic about
 the use of jsp:useBean or the bean-cookie.jsp should be changed to be nice
 to Weblogic. It could use bean:write only and not use jsp:getProperty. I
 have always assumed the bean:cookie tag didn't work in Weblogic 6.0 because
 the bean:cookie test page didn't work. Maybe there should be a separate test
 page to assess the ability of a jsp engine to use jsp:getProperty for beans
 defined by means other than jsp:useBean. That seems like something the J2EE
 certification suite should test for rather than struts. 

bean:cookie does not work, because Weblogic does not implement the spec
correctly. There are a couple of things that should be done from my point
of view:

a) Notify BEA and request a fix
  (done three months ago for WLS 5.1, unsure what's with WLS6.0)

b) Until Bea supplies a fix, fix it on your own
  (done for WLS 5.1, see my mails from yesterday)
  
c) Change the test page(s) (applies to bean-cookie; logic-match; logic-present)
  They will fail on any container, if no cookie is present. The tag should use
  the value="FOO" attribute to get a default for missing cookies.
  (supplied updated JSPs yesterday to STRUTS-DEV, see my mail titled
   "struts-test w/ URLRewriting (Patch to enable...)" )

d) Change the test page, if you don't like a) and b) to gracefully catch,
  print and explain exceptions to the user.
  I think that a test-suite should not fail completly on a known bug. Either
  the bug should be fixed, or the suite should catch the error, print and
  explain it. People new to Struts may otherwise immediatly stop looking
  further into it, because it really doesn't matter to them where the
  exception comes from.

Matthias(mailto:[EMAIL PROTECTED])





RE: [Q] TRANSACTION_TOKEN_KEY

2001-02-10 Thread Neal Kaiser

How does this work when they are registering for the first time, not
editing. I can
see that in EditRegistrationAction the token is set... but if they are
registering
for the first time where is the token set? It seems that it would fail when
it hits
the token check in SaveRegistrationAction, but I know it doesn't, so it must
be set
somewhere, right?



 -Original Message-
 From: Rob Leland [mailto:[EMAIL PROTECTED]]
 Sent: Friday, February 09, 2001 9:52 AM
 To: [EMAIL PROTECTED]
 Subject: Re: [Q] TRANSACTION_TOKEN_KEY


 EditRegistrationAction.java  SaveRegistrationAction.java
 provide examples.

 You would probably never use generateToken().

 It is used whenever you want to prevent the user
 from bookmarking a page, or from using the browser
 back arrow and then posting a second time.

 In the EditRegistrationAction, once the data is loaded
 from a database a call to saveToken() is made. It should
 probably be named 'setToken()' to be consistent with
 'resetToken()'. This sets a variable in both the session
 and request scope of the app. Control is then forwarded
 to the edit jsp. When the user 'posts' the page the
 Token is validated in SaveRegistrationPage, then it is
 destroyed by the 'resetToken call. Then the next page is
 'forwarded' to. If at this time the user hits the 'back'
 button and hits 'post' again, when SaveRegistrationAction
 checks to see if the token is valids it finds can find
 one of two things:
   1) Either the 'Token' variable didn't exist in the session scope.
  This happen if 'resetToken' was the last method called
   2) Or it will find that the "request" and "session" scope
 Token do not
 match.
  This happen if 'saveToken' was the last method called.


 Alexander Staff wrote:
 
  Hello,
  does anyone here have any examples/explanations about using the
  TRANSACTION_TOKEN_KEY feature in struts ?
  I am not sure using the generateToken(), isTokenValid(),
 resetToken() and
  saveToken() functions properly and in the right place.
 
  Thanks in advance
  Ciao
  Alexander
 
  --
  Sent through GMX FreeMail - http://www.gmx.net




JspException

2001-02-10 Thread Allamsetty, Venkata


Hi,

I am trying to get my first Struts application work. 
I have created defaultTime.jsp which contains a text input for time,
DefaultTimeForm , EditDefaultTimeAction and SaveDefaultTimeAction classes.
Defined web.xml and struts-config.xml and deployed them appropriately.

But when I try loading it, I get Error 500.
and the message is 


Venkata Allamsetty




RE: JspException

2001-02-10 Thread Allamsetty, Venkata


 Hi,
 
 I am trying to get my first Struts application work. 
 I have created defaultTime.jsp which contains a text input for time,
 DefaultTimeForm , EditDefaultTimeAction and SaveDefaultTimeAction classes.
 Defined web.xml and struts-config.xml and deployed them appropriately.
 
 But when I try loading it, I get Error 500.
 and the message is 
 
 javax.servlet.jsp.JspException: No bean found under attribute key
 defaultTimeActionForm
 at
 org.apache.struts.taglib.logic.CompareTagBase.condition(CompareTagBase.jav
 a:214)
 at
 org.apache.struts.taglib.logic.EqualTag.condition(EqualTag.java:90)
 at
 org.apache.struts.taglib.logic.ConditionalTagBase.doStartTag(ConditionalTa
 gBase.java:218)
 at jsp_servlet._defaulttime._jspService(_defaulttime.java:85)
 at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
 
If I try loading the editDefaultAction.do directly, I get the
follwing error.

javax.servlet.jsp.JspException: Exception accessing property action
for bean defaultTimeActionForm: java.lang.NoSuchMethodException: Unknown
property 'action'
at
org.apache.struts.taglib.logic.CompareTagBase.condition(CompareTagBase.java:
234)
at
org.apache.struts.taglib.logic.EqualTag.condition(EqualTag.java:90)
at
org.apache.struts.taglib.logic.ConditionalTagBase.doStartTag(ConditionalTagB
ase.java:218)
at
jsp_servlet._defaulttime._jspService(_defaulttime.java:85)


Any hints or suggestions?

thanks

 Venkata Allamsetty
 



Struts/Motif

2001-02-10 Thread Dan Connelly


Struts for Motif.  Okay, wash my mouth out with SOAP!

But, look, lots of neat, old X/Motif applications were written using the MVC
architecture.

What good did it do X, Motif, ... or MVC?

And, don't try blaming it all on the X Server being such a heavy "client".
On the other hand, don't try to claim that the Web-way is the only way.

[We could also consider Struts for Swing, but that clouds the argument I am
about to make.]

A Motif MVC app I recently worked on had MVC features similar to Struts,
like an action map "digester".  Well, the Motif app digester was written in
awk and it was a preprocessor.  The mappings got compiled into the code.
But it was similar, a nice high level view of the internal data
architecture.


Unfortunately, I also see some disturbing similarities between the
weaknesses of MVC Motif (as commonly programmed) and Struts, such as



1.   A difficult and impoverished widget set.

For instance, do we have a high-level Tree widget to plug into Struts?
Having third-party Tree widgets and scripting hacks for Trees didn't make
Motif competitive with the Win-mill.  ( ?? "COMpetitive"  ??)

 2.  Ad hoc Database-to-Model mappings.

For instance, if a number of browser sessions, perhaps hierarchically
related browser sessions, are looking at the same Persistent EJBs, how do
these sessions coordinate their separate (hierarchical) Models?  Their
database updates?  Their screen Updates?   Is this to be left to the realm
of "Business Logic"?   It's system logic, for sure.It invites trouble to
let the bit jockeys be responsible for getting this right, for buggering the
MVC.


The Motif MVC app I worked on used the windowing hieirachy in X/Motif to
build a Model hierarchy of database views.  This was very ad hoc, very
quirky and quite buggy, but nice.  Or so I thought.   The nuances escaped
many in the user community.  And, eventually the programmers also lost track
of the ad hoc programming needed to sustain the Model hierarchy.   So it
goes.

But, jeez, it did make for a very lively GUI when it all went well, with
model changes rippling from window to window.  Made Win-doze apps look
absolutely static in comparison.  Unfortunately, I don't see much (yet) in
Struts to make a more dynamic display out of (hierarchical) web browser
sessions.   Or, is this just a feature in search of an audience??


Dan Connelly





I18n

2001-02-10 Thread Sean Giles

How can I set the locale for each individual user session before the first
page displays?

I've tried putting the session.setAtttribute(Action.Locale_key,locale) but
it always displays in the default locale of the machine?  Changing the
machine locale causes the correct properties file to be used so I know that
is not the problem.

Thanks
Sean Giles



Re: [Q] TRANSACTION_TOKEN_KEY

2001-02-10 Thread Craig R. McClanahan

Neal Kaiser wrote:

 How does this work when they are registering for the first time, not
 editing. I can
 see that in EditRegistrationAction the token is set... but if they are
 registering
 for the first time where is the token set? It seems that it would fail when
 it hits
 the token check in SaveRegistrationAction, but I know it doesn't, so it must
 be set
 somewhere, right?


You will note that the "Register with the MailReader Demonstration Application"
link (on index.jsp) goes through "EditRegistration.do" as well, so that the
token gets saved even in this case.  The "?action=Create" request parameter is
used to distinguish this from the editing case ("?action=Edit").

This is a design pattern that I like a lot -- use the same Action to initialize
the input form when you are creating a new record or when editing an existing
one, and use a request parameter to define which type of transaction is
occurring.  You will also find that the "action" request parameter gets included
as a property of the form bean, and is passed in (as a hidden variable) on the
input form so that SaveRegistrationAction knows what to do as well.

Craig





Re: Digester: How to read the body of a tag?

2001-02-10 Thread Craig R. McClanahan

Jens Rehphler wrote:

 Hello Craig,

 as always you gave the conclusive hint. Perhaps you should add an example of the 
usage of
 this methods to the documentation. It would make things much more clearer.


Good idea.  I'm adding an example of using this technique to the Developer's Guide 
page on the
Digester module.  The example will be based on processing a web application deployment
descriptor (web.xml) file, where almost everything is passed as body content rather 
than XML
attributes.

Look for this in tonight's nightly build.


 thanks,

 Jens


Craig





Re: JspException

2001-02-10 Thread Craig R. McClanahan

"Allamsetty, Venkata" wrote:

  Hi,
 
  I am trying to get my first Struts application work.
  I have created defaultTime.jsp which contains a text input for time,
  DefaultTimeForm , EditDefaultTimeAction and SaveDefaultTimeAction classes.
  Defined web.xml and struts-config.xml and deployed them appropriately.


You are not showing us the JSP page or struts-config.xml file that is running,
but I suspect the problem is one of the following:

* You are creating the bean in one scope, but looking for it in a different
scope.

* You are creating the bean in request scope, and looking for it on a
  later request (request scope beans only survive through the current
  request).


 
  But when I try loading it, I get Error 500.
  and the message is
 
  javax.servlet.jsp.JspException: No bean found under attribute key
  defaultTimeActionForm
  at
  org.apache.struts.taglib.logic.CompareTagBase.condition(CompareTagBase.jav
  a:214)
  at
  org.apache.struts.taglib.logic.EqualTag.condition(EqualTag.java:90)
  at
  org.apache.struts.taglib.logic.ConditionalTagBase.doStartTag(ConditionalTa
  gBase.java:218)
  at jsp_servlet._defaulttime._jspService(_defaulttime.java:85)
  at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
 
 If I try loading the editDefaultAction.do directly, I get the
 follwing error.

 javax.servlet.jsp.JspException: Exception accessing property action
 for bean defaultTimeActionForm: java.lang.NoSuchMethodException: Unknown
 property 'action'

If your bean includes property="action", the tag is going to try to call the
getAction() method on whatever bean was selected by the "name" (and optional
"scope") attributes.  Does the bean have such a method?


 at
 org.apache.struts.taglib.logic.CompareTagBase.condition(CompareTagBase.java:
 234)
 at
 org.apache.struts.taglib.logic.EqualTag.condition(EqualTag.java:90)
 at
 org.apache.struts.taglib.logic.ConditionalTagBase.doStartTag(ConditionalTagB
 ase.java:218)
 at
 jsp_servlet._defaulttime._jspService(_defaulttime.java:85)

 Any hints or suggestions?

 thanks

  Venkata Allamsetty
 

Craig





Re: I18n

2001-02-10 Thread Craig R. McClanahan

Sean Giles wrote:

 How can I set the locale for each individual user session before the first
 page displays?

 I've tried putting the session.setAtttribute(Action.Locale_key,locale) but
 it always displays in the default locale of the machine?  Changing the
 machine locale causes the correct properties file to be used so I know that
 is not the problem.


In the Struts example app, this is done by including the following tag on the
index.jsp page (actually, on every page):

%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %
html:html locale="true"
... page content ...
/html:html

This causes that html:html tag to consult the "Accept-Language" header sent by
the browser, and set up a Locale in the user's session if it is not already
there -- exactly the same way that the controller servlet does this if you
configure it to.

NOTE:  There are currently problems with this on servlet containers that do not
correctly implement the JSP 1.1 requirements for converting custom tag attribute
values.  I have heard problem reports about JRun 3.0 and ATG in this regard.


 Thanks
 Sean Giles

Craig





Re: [Q] TRANSACTION_TOKEN_KEY

2001-02-10 Thread Dan Malks



"Craig R. McClanahan" wrote:

 Dan Malks wrote:

  Craig,
 
  "Craig R. McClanahan" wrote:
 
   Neal Kaiser wrote:
  
How does this work when they are registering for the first time, not
editing. I can
see that in EditRegistrationAction the token is set... but if they are
registering
for the first time where is the token set? It seems that it would fail when
it hits
the token check in SaveRegistrationAction, but I know it doesn't, so it must
be set
somewhere, right?
   
  
   You will note that the "Register with the MailReader Demonstration Application"
   link (on index.jsp) goes through "EditRegistration.do" as well, so that the
   token gets saved even in this case.  The "?action=Create" request parameter is
   used to distinguish this from the editing case ("?action=Edit").
 
  Would 'ModifyRegistration.do' or 'ProcessRegistration.do' be more clear, then?
 

 Or even something more generic like "StartRegistration.do"?  Can you tell that I 
wrote
 the "edit" use case first?  :-)

 I had a Comp Sci prof that said the most critical design decision you will ever make
 is naming things.

And often, surprisingly, one of the harder ones.


 And, even when you get the initial name correct, it is important to
 review your names after the program has evolved a bit.

Amen ;-)

Thanks,
-dm


  Sounds like it is time to do
 that exercise on the example app.

 
  -dm
 

 Craig

--
Dan Malks Sun Java Center
Enterprise Java Architect703.208.5794





Re: I18n

2001-02-10 Thread Sean Giles


Thanks Craig I'm using Jrun 3.0 and downloaded the service pak and the session.setAtttribute(Action.Locale_key,locale now seems to be working. 

From a design standpoint what is the best way to set the locale information regardless of browser or machine settings to build the initial Accept-language header? Another servlet that reads a cookie and builds the headers before directing the request to the struts action servlet?

Basically I have a requirement for a user to be able to switch between languages on the fly but also being able to set an initial locale preference when they log in. The struts framework handles the switching without a problem (which is really cool) its the initial display that I'm wondering about since they may have us_english for a machine setting, browser setting for spanish and an initial application locale preference for French.

Thanks again,
Sean


On Sat, 10 Feb 2001 12:38:24 -0800, Craig R. McClanahan wrote:
Sean Giles wrote:

How can I set the locale for each individual user session before the first
page displays?

I've tried putting the session.setAtttribute(Action.Locale_key,locale) but
it always displays in the default locale of the machine? Changing the
machine locale causes the correct properties file to be used so I know that
is not the problem.


In the Struts example app, this is done by including the following tag on the
index.jsp page (actually, on every page):

%@ taglib uri=/WEB-INF/struts-html.tld prefix=html %
html:html locale=true
... page content ...
/html:html

This causes that html:htmltag to consult the Accept-Language header sent by
the browser, and set up a Locale in the user's session if it is not already
there -- exactly the same way that the controller servlet does this if you
configure it to.

NOTE: There are currently problems with this on servlet containers that do not
correctly implement the JSP 1.1 requirements for converting custom tag attribute
values. I have heard problem reports about JRun 3.0 and ATG in this regard.


Thanks
Sean Giles

Craig



-- Sean Giles, [EMAIL PROTECTED] on 02/10/2001