Re: How to display the size of an Collection attribute of a bean?

2001-04-10 Thread Michael McCallister

At 03:33 AM 4/10/2001, you wrote:
I want to display the size of an Collection attribute of a Bean using 
Struts taglibs.  I can use scriptlet but are there any other ways to do that?

Regards,
Thai

Based on a response from [EMAIL PROTECTED] to a bug I filed, it 
appears you can use the bean:size tag to do what you want.  Here is a 
snipped from the bug tracking system that should illustrate getting the 
number of elements into a bean.  For your problem, you would then use 
bean:write to display this item count in your HTML (instead of using 
logic:equal to check the size).

! --- Additional Comments From [EMAIL PROTECTED] 2001-03-30 16:20 
---
! I had a similar problem awhile ago and Craig created the bean:size tag. This
! can be used along with logic tags to do what you want.
!
! bean:size id="numlineitems" name="userorderdetail" 
property="orderLineItems"
! scope="request" /
! logic:equal name="numlineitems" value="0" 
! bean:message key="emptylist.noitemsinorder"/
! /logic:equal
! logic:greaterThan name="numlineitems" value="0" 
! ...
! /logic:greaterThan




Re: Getting the html:errors tag to display on multiple lines

2001-03-13 Thread Michael McCallister

Just specify the property attribute of the html:errors tag.  So, for 
example, in your validate function you might have something like:

 errors.add("roles", new 
ActionError("error.reqaccess.role.invalid"));

to indicate an error in the "roles" field.  Using:

 html:errors property="roles"/

in your JSP will show only the errors associated with the roles 
field.  Repeat this for as many fields as you have and use the appropriate 
parameters to errors.add(), and you should be able to place errors in the 
appropriate locations.


Mike

At 02:12 PM 3/13/2001, you wrote:
Hello,

I guess this is kind of a trivial question, but I'm having a problem getting
the
"html:errors" tag to display on multiple lines for multiple errors. Am I
overlooking
something obvious, or do I have to use the iterator tag and parse the errors
myself if
I want them on separate lines? If you could respond directly to me at:

[EMAIL PROTECTED]

Thanks
Justin




Mismatch Between html:options and logic:iterate

2001-03-13 Thread Michael McCallister

Am I the only one who finds it odd that while both logic:iterate and 
html:options take a "collection" attribute, one expects a run-time 
expression that evaluates to a Collection and the other takes a String that 
names a bean in some scope that is a Collection?

Shouldn't these two tags play according to the same rules when it comes to 
identically named attributes?  Should I file a bug for this?  Should one 
behavior "win-out" over the other?  In my opinion, the behavior of naming 
bean with a String attribute feels the most "Struts like".

Unfortunately, changing things one way or the other will break code, but 
better to do so before cutting a release than after.


Mike





Re: Question about struts application model (DataSource, Business Log ic beans)

2001-03-12 Thread Michael McCallister

I resolved this by creating two pieces:

First is a class in your business logic package that manages the context 
required by the business logic beans.  This class should be a Singleton and 
should manage access to resources needed by your business logic beans such 
as configuration parameters and your DataSource.  I modeled my context 
object after the Servlet session API, but you could make it much more 
structured if you like.

Second, depending on your servlet environment, create some mechanism to 
initialize your application context object.  Using Tomcat, you could do 
this using something like the DatabaseServlet from the Struts example.  In 
this case, your DatabaseServlet gets started by the servlet container and 
it initializes your application context object (using servlet 
initialization parameters, things like a GenericDataSource object, 
etc.).  Now when your business logic beans are called, they retrieve the 
application context, ask it for a DataSource, and use it to get a connection.

When you decide to re-implement your application as a two-tier 
Client/Server application with a Swing front-end, all you need to do is 
implement some alternate method for your application context object to be 
initialized and your business logic beans are shielded from the change.

I'm not sure this is the best way to decouple your layers, but it's what 
I've come across so far.


Mike

At 12:22 PM 3/12/2001, you wrote:

Hi,

I'm using Struts for a new application that I'm developing. I have a 
question about the separation between the Action classes and the Business 
Logic beans.

My Business Logic beans are making database accesses to manipulate the 
underlying data model. I am planning on using the struts db connection 
pool, which is supplied through the DataSource. My problem is that access 
to the DataSource is through the servlet.getDataSource() call. How do I 
make the Business Logic beans unaware of the servlet/http layer (as 
suggested in the developers guide) while still making the DataSource 
available to the Business Logic beans? Do I have to pass a reference to 
the DataSource on every call the Business Logic beans (not an option that 
I like), or is there a cleaner way to do this? I also have a similar 
issues with logging services.

I believe that a common way to solve this problem is to bind the 
DataSource to a jndi service. I am using tomcat 3.2.1, and I don't believe 
that this functionality is supplied in either Tomcat or Struts.

Thank You,
Carles




Business Object Bean Persistence Strategies

2001-03-08 Thread Michael McCallister

What strategies or patterns do people use to manage persistence of business 
object data in a Struts application when there is no EJB layer and there is 
a desire to keep the business objects as independent of the web portion of 
the application as possible?  Do you use the Struts DataSource and pass 
either it or a Connection as a parameter to bean methods that take 
responsibility for managing persistence?  Do you follow the J2EE blueprint 
and create separate Data Access Objects to support persistence?  Are you 
using an open-source framework to manage persistence?  This seems like a 
common problem, but I haven't seen much talk about common solutions.


Mike




Re: URGENT RE: token issue in hyperlink

2001-03-07 Thread Michael McCallister

Here is what I do in a similar situation:

html:link paramId="role" paramName="role"
   page='%="/user/saveUser.do?action=Removeorg.apache.struts.taglib.html.TOKEN=" 
+
session.getAttribute("org.apache.struts.action.TOKEN")%'
  Removenbsp;Role  /html:link

It's ugly, but it works for now.  Notice the single quotes around the page 
argument.  Very important or the JSP parser will get confused by the 
embedded double quotes in the expression.

I've submitted an enhancement request (Bug #874 
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=874) to add an optional 
parameter to the html:link tag that would do this magic without the need 
for the expression shown above.  If I can get Struts set up to build 
locally, I will probably give implementing this a go myself so I can submit 
a patch rather than just a request.  Using the link above, you can vote for 
the implementation of this enhancement.


Mike

At 07:43 AM 3/7/2001, you wrote:

Hello,

 I have posted this before. This is extremely urgent for me. I know that
the token support exists for posting Form(s). How can i ensure that this
same token will be issued to a hyperlink so that i can validate that the
user will click on the hyperlink only once ? Any help is greatly
appreciated. Thanks a lot.

cheers,
Amar..


-Original Message-
From: Nanduri, Amarnath [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 06, 2001 2:23 PM
To: '[EMAIL PROTECTED]'
Subject: token issue in hyperlink



Hello All ,

  I am using the Action class saveToken() method to ensure that a token
is created and set (so that the user has proper screen flow). My question is
... how can i add this token to a hyperlink ?

  I have a hyperlink in a jsp page, which takes me to a different Action
class. I am checking for this token in the second Action class. Any help is
greatly appreciated. Thanks.

cheers,
Amar..




RE: URGENT RE: token issue in hyperlink

2001-03-07 Thread Michael McCallister

I can't speak about the address bar (different browsers probably behave 
differently), but if you aren't seeing it in the generated source then 
there is a problem.  To confirm, you don't see the

 org.apache.struts.taglib.html.TOKEN=4bb7c9e6084fbf88acc2aa976ea9e3

string in your generated hyperlink href?  Do you see the 
"org.apache...TOKEN" part but not the hex string after the equals sign?  If 
so, maybe you are not doing a saveToken(request) in an Action before you 
forward to your JSP page.


Mike

At 10:58 AM 3/7/2001, you wrote:

Mike,

Thanks a lot. It works. I did vote for this enhancement to take
place. One question i have is...how come i don't see the session id in the
address bar ? Is it because GET limits the number of characters that can be
kept in the Address Bar ? Also i did not see the sessionid when i did a
'view source' and checked the source of my generated page. Clarification on
this issue is greatly appreciated.

cheers,
Amar..




Re: Problem in Struts example (struts-example.war)

2001-03-06 Thread Michael McCallister

Is this really true?  I have an Action that doesn't define an input 
attribute, but does specify a request scope ActionForm.  According to the 
log messages, Struts creates an instance of the form and stores it under 
the appropriate key before calling my Action.perform() method.  In 
addition, the code I have to handle the form == null case never seems to 
get called.


At 11:40 PM 3/4/2001, Craig McClanahan wrote:
The "form" object passed to an Action will indeed be null if the
struts-config.xml file does not define an "input" attribute for this 
particular
action.

Although that is not the case currently for the Struts example app, 
consider me
an old paranoid programmer about double checking the "it can never happen" 
cases
... :-)


Mike




Re: form initialization using session

2001-02-27 Thread Michael McCallister

The way this is typically handled is to use an Action to populate the 
bean.  So instead of linking your user directly to the JSP page, you link 
them to an Action.  This Action typically loads the bean and then returns 
the success mapping, which, in struts-config.xml, you've mapped to the JSP 
that displays the values from the bean.

The example application that comes with struts shows how to do this.  The 
walking tour that accompanies the example explains it better than I 
have.  Look at the relationship between EditSubscriptionAction.java, 
subscription.jsp, and SaveSubscriptionAction.java.


Mike

At 11:46 AM 2/27/2001, you wrote:
Hi all,

I am working on an application where form fields need to default to
values that depend on the user's profile, which is stored in the
session.  Unfortunately, it seems like struts forms are created
automatically without any hooks that allow access to the session to
initialize these fields.

The only thing that I can think of is to have our application
proactively place the forms into the session with values initialized,
possibly to have the form page link through an action which creates and
initializes the form.  However this abandons the utility of having
struts automatically create the forms for us - one of the many nice
things about struts!

This seems to me like it would be a common problem.  Does anyone have a
good solution for it?

Cheers,

Simon.




Re: My weblogic 5.1 sp8 isn't able to find web-app_2_2.dtd

2001-02-23 Thread Michael McCallister

No, this doesn't work in Tomcat 3.2.1 either (at least, not in all 
cases).  Here's my situation:

Normally, I am behind a firewall that prevents direct connection to the 
Internet.  I can't even resolve external domain names.  Now when I start up 
Tomcat with the struts-example deployed (using the Feb 22 nightly build), I 
get the following exception in my servlet.log:

2001-02-23 09:46:44 - path="/struts-example" :action: Initializing 
configuration
  from resource path /WEB-INF/struts-config.xml
2001-02-23 09:46:47 - path="/struts-example" :action: null - 
org.xml.sax.SAXPars
eException: External entity not found: 
"http://java.sun.com/j2ee/dtds/web-app_2_
2.dtd".
 at com.sun.xml.parser.Parser.fatal(Parser.java:2817)
 at 
 com.sun.xml.parser.Parser.externalParameterEntity(Parser.java:2506)
 at com.sun.xml.parser.Parser.maybeDoctypeDecl(Parser.java:1137)
 at com.sun.xml.parser.Parser.parseInternal(Parser.java:481)
 at com.sun.xml.parser.Parser.parse(Parser.java:284)
 at javax.xml.parsers.SAXParser.parse(SAXParser.java:155)
 at javax.xml.parsers.SAXParser.parse(SAXParser.java:77)
 at org.apache.struts.digester.Digester.parse(Digester.java:716)
 at 
 org.apache.struts.action.ActionServlet.initServlet(ActionServlet.java
:1390)
 at 
 org.apache.struts.action.ActionServlet.init(ActionServlet.java:469)
 at javax.servlet.GenericServlet.init(GenericServlet.java:258)
 at 
 org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
 at org.apache.tomcat.core.Handler.init(Handler.java:215)
 at 
 org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:296)
 at 
 org.apache.tomcat.context.LoadOnStartupInterceptor.contextInit(LoadOn
StartupInterceptor.java:130)
 at 
 org.apache.tomcat.core.ContextManager.initContext(ContextManager.java
:491)
 at 
 org.apache.tomcat.core.ContextManager.init(ContextManager.java:453)
 at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:195)
 at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:235)

2001-02-23 09:46:47 - path="/struts-example" :action: Mapping for servlet 
'actio
n' = 'null'
2001-02-23 09:46:48 - path="/test" :jsp: init
2001-02-23 09:47:46 - path="/struts-example" :jsp: init
2001-02-23 09:48:08 - path="/struts-example" :jsp: init

When I am connected to the Internet, here is what I get instead:

2001-02-23 09:54:17 - path="/struts-example" :action: Initializing 
configuration
  from resource path /WEB-INF/struts-config.xml
2001-02-23 09:54:24 - path="/struts-example" :action: Process 
servletName=action
, urlPattern=*.do
2001-02-23 09:54:24 - path="/struts-example" :action: Mapping for servlet 
'actio
n' = '*.do'
2001-02-23 09:54:24 - path="/test" :jsp: init
2001-02-23 09:54:43 - path="/struts-example" :jsp: init
2001-02-23 09:55:12 - path="/struts-example" :jsp: init

So for some reason, Tomcat isn't looking at the local web.dtd file in the 
tomcat\conf directory.  Do I have something configured incorrectly?


Mike


At 09:19 AM 2/23/2001, you wrote:
Please, excuse me if I am not correct. Your application try to get a file 
web-app_2_2.dtd from java.sun.com/j2ee/dtds site. And for some reason this 
site was unreachable
(http://java.sun.com/j2ee/dtds/web-app_2_2.dtdhttp://java.sun.com/j2ee/dtds/web-app_2_2.dtd)
 
- see below highlighted with blue color. As Craig M. explained, in this 
case Weblogic has to read its own local file. But it did not!??? Maybe 
this works only on Tomcat.

Maya

Pablo Estades Fernndez wrote:
Hi all,

I'm using this great framework for a few weeks and it
seems fantastic, but I have experimented a problem
with the last nightly versions;

Weblogic doesn't find the http://http://
java.sun.com/j2ee/dtds/web-app_2_2.dtd.

I already have read the Vincent Massol reply to this
problem, telling we have to change

!DOCTYPE web-app PUBLIC "-//Sun Microsystems,
Inc.//DTD Web Application
2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtdhttp://java.sun.com/j2ee/dtds/web-app_2_2.dtd"
 


to

!DOCTYPE web-app PUBLIC "-//Sun Microsystems,
Inc.//DTD Web Application
1.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtdhttp://java.sun.com/j2ee/dtds/web-app_2_2.dtd"
 


and this doesn't works for my.

With the 02/05 version doesn't happen, but fails the
redisplay of a password field which I need it.

I've tryed with the earlier nightly version (02/16)
and also fails.

Do you any suggestions?

Thanx a lot!

PD: This this the exception:

resolveEntity('-//Sun Microsystems, Inc.//DTD Web
Application 2.2//EN', 'http://http://
java.sun.com/j2ee/dtds/web-app_2_2.dtd')
  Not registered, use system identifier
vie feb 23 15:48:27 CET 2001:E
WebAppServletContext-uni2 action: null
java.net.NoRouteToHostException: Host unreachable: no
further information
 at
java.net.PlainSocketImpl.socketConnect(Native Method)
 at
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:312)