Re: RE: Populating form in the action

2001-12-06 Thread Joey Gibson

 The form passed in is a null because that Action is
 called the first time I type in the URL (.do), not
 after a form has been submited.
 
 In other words, I would like to pre-populate the
 form before displaying it.

If you have associated the action with a form in your struts-config.xml, then any time 
your perform() method is executed, there should be a form instance present. I use this 
on my site. I do a GET on the action to, for example, edit my account record. I fetch 
the user record, prepopulate the form, and then forward to the jsp. Here's a code 
snippet:

public void perform(..., ActionForm form, ...)
{
 UserForm userForm = (UserForm) form;

 if (request.getMethod().equalsIgnoreCase(get))
 {
   userForm.setName(...)
   // ...
 }
}

--
Sent via jApache.org

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




Re: RE: Populating form in the action

2001-12-05 Thread Joey Gibson

 
 For instance, I create a ActionForm in the perform
 method of the Action class, and then forward the
 control to a jsp page.  How does the JSP page know
 that the form that it gets is the form that just get
 populated in the Action before?  

Don't create an instance of the form, use the one that is passed in to your 
perform(...) method. You will need to cast it, of course.

Joey

--
Sent via jApache.org

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




Re: Icons next to form elements with validation errors

2001-12-03 Thread Joey Gibson

 logic:messagesPresent property=username
 // insert image here
 /logic:messagesPresent
 html:text property=username size=20
 maxlength=100/

What about using html:errors next to the field in question and having the error 
message contain an img tag to the icon? 

In your action, set the error message:

ActionError err = new ActionError(error.search.crit);
errors.add(searchCrit, err);

Then in your jsp:
html:text.../html:errors property=searchCrit/

And in your AppRsrs.properties:
error.search.crit = img src=/images/nocrit.gif/

This works for me.
Joey

--
Sent via jApache.org

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




Re: Directory structure of a Struts project

2001-11-30 Thread Joey Gibson

 WEB-INF/classes/com/iamtestdomain/testproject -(1)
 
 and my taglibs in a the directory
 
 WEB-INF/classes/taglib -(2)
 
 Is this a good way to organize things? 

The project I'm working on is organized thusly under a com.foo. package:

actions
entities
forms
servlets
taglibs
utils

with actions in actions, struts forms in forms, etc. Entities is my business entity 
classes and servlets currently only contains my subclass of ActionServlet.

Joey

--
Sent via jApache.org

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




Re: Passing information to the jsp

2001-11-30 Thread Joey Gibson

 If you want to pass data to a jsp, where the
 information will not be in
 an HTML form, do I need to pass it through the
 ActionForm that is in the
 mapping, or should I just put a bean in the request
 and use it on the
 jsp?

If you need to pass info that won't be in the form, then I would think it perfectly 
acceptable to send it in the request using setAttribute(). There's no reason to 
clutter up your form code with getters/setters for data that your actions don't need. 

Joey

--
Sent via jApache.org

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




Re: Help with perform method

2001-11-29 Thread Joey Gibson

 What I would like to do is that if there is some type
 of error in this
 method, I want to be able to do a
 mapping.findForward(failure) and at the
 same time be able to include some type of error
 message to the user in the
 failure page. My failure page is probably the same
 form the user filled out,
 but the second time around I would like to display
 the error message.

This is what ActionError, ActionErrors and html:errors/ is for. 

perform(...)
{
   // ... processing ...
   ActionErrors errors = new ActionErrors();
   ActionError err = new ActionError(error.username.taken);
   errors.add(ActionErrors.GLOBAL_ERROR, err);

   saveErrors(request, response);

   return new ActionForward(mapping.getInput());
}

Then in the jsp page, you can simply add:

html:errors/

somewhere conspicuous to get the errors to display.

Joey

--
Sent via jApache.org

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




Re: check for null collection

2001-11-29 Thread Joey Gibson

If the collection is truly null, then logic:present will be false so you won't get 
into the tag body. To see if the collection is just an empty collection:

Inside your logic:present you can use a combo of tags from the bean and logic 
taglibs:

bean:size id=mySize name=myArray/
logic:equal name=mySize value=0
   No records.
/logic:equal
logic:notEqual name=mySize value=0
   bean:write name=mySize/ record(s)
/logic:notEqual

And you don't have to do the bean:define since most of the tags will be able to find 
the collection in whichever scope it is in. In my sample program that I wrote to test 
this information, I created a List and shoved it into the request. I never mentioned 
which scope it is in, though you can specify.

Joey

--
Sent via jApache.org

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




Re: relatively complicated iterate problem.

2001-11-27 Thread Joey Gibson

 My problem is. I don't want to use Roll class, since
 it only contains a string. I have just created this Roll class, since I
 couln't find any way to make it run with struts. What do you think? 
 is there any other way to do
 same thing?

If you don't specify the property attribute, the tag will do a string comparison. I've 
got code like this in a working project:

logic:equal name=resultsSize value=0

that works with a variable created by bean:size earlier in the page.
--
Sent via jApache.org

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




Re: JSP page without form bean ?

2001-11-21 Thread Joey Gibson

What exactly are you trying to do? I have several actions that have no forms that work 
fine. I do GETs to them, do some processing, and then forward to a jsp. 

Sent via jApache.org

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




Re: RE: Dynamic anchor

2001-11-20 Thread Joey Gibson

This might be a wee bit cleaner:

%@ taglib uri=struts-bean.tld prefix=bean %
%@ taglib uri=struts-html.tld prefix=html %

bean:define id=foo value=xxx/

html:link page=/index.jsp anchor=%= foo %Foo/html:link

This produces this link:

http://localhost/foo/index.jsp#xxx

(the page was deployed in a webapp called 'foo')

I tried putting a bean:write in the anchor attribute, but it goes through 
unadulterated, which is not what we want. I really wish some of these tags could nest 
more easily.

Joey

--
Sent via jApache.org

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




Re: Beginner Question :How to use Ant with struts ?

2001-11-20 Thread Joey Gibson

On Tue, 20 Nov 2001 09:37:06 -0500, Lily Zou [EMAIL PROTECTED] wrote:

||| I am new to struts. I am currently using apache-tomcat-cocoon framework
||| with ant and preparing swithing to apache-tomcat-struts.We now use ant to
||| build and deploy applications.  I wonder if anybody could tell me how to use
||| ant to do the similiar build for struts ?  And how to implement struts with
||| Apache and tomcat ? Any suggestion  is welcome !

Using Struts with Ant is no different than using any other library with
Ant. You just need to add the struts.jar to your classpath for compilation,
and then make sure the struts jars are in your WEB-INF/lib, and the struts
taglib tld files are in your WEB-INF. Ant has the war task that will help
with both of those.

Joey

-- Sun Certified Java2 Programmer
-- My Pocket Smalltalk Stuff: www.joeygibson.com/st
--
-- We thought about killin' him, but we kinda 
--  hated to go that far - Briscoe Darling


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




Re: RE: RE: Dynamic anchor

2001-11-20 Thread Joey Gibson

 html:link
 html:pagebean:write
 name=beanContainingMyPage//html:page
 html:anchorbean:write
 name=beanContainingMyAnch//html:page
 linkText
 /html:link
 
 This would avoid many ugly %...% hacks IMHO.
 
 I'm still not sure whether the tld syntax allows for
 nesting. Anybody
 has links for tld ?
 
 tomK

That would be really nice to be able to do it like that. There are several tags that 
could benefit from this ability.

--
Sent via jApache.org

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




Re: Struts with SilverStream

2001-10-02 Thread Joey Gibson

On Tue, 02 Oct 2001 10:19:20 +0200, Wolfgang Frank [EMAIL PROTECTED]
wrote:

||| Hi there,
||| 
||| does anybody have experienece how to integrate STRUTS in the SilverStream J2EE
||| Server?
||| I uploaded my struts WAR ... i can see the jsp if i directly link up to them but
||| i get an
||| bad request error when i call an action. The same application ran without
||| failure on tomcat ...

Did you create a deployment plan and then use 'silvercmd deploywar' to
deploy it? What are you using for a URL to try to hit the jsp? I have
deployed some struts apps with SS 3.7.1 and while it was tedious, it wasn't
a problem. Give me a bit more info on how you deployed and what exactly
happened, and perhaps we can figure it out.

Joey

-- Sun Certified Java2 Programmer
-- My Pocket Smalltalk Stuff: www.joeygibson.com/st
--
-- We thought about killin' him, but we kinda 
--  hated to go that far - Briscoe Darling




Re: getting jsp:include to work behind WEB-INF wall

2001-09-12 Thread Joey Gibson

On Wed, 12 Sep 2001 18:25:14 +0200, VIAUD CĂ©dric [EMAIL PROTECTED] wrote:

||| If you read carefully the servlet spécification, you see that everything
||| under /WEB-INF will nerver be served by HTTP server. So if you do a :
||| JSP:INCLUDE page=/WEB-INF/anything.jsp flush=true/
||| you make an HTTP request to the server. But the target is something it is
||| not allowed to serve.
||| So this couldn't work with in JSP:INCLUDE

I'm currently doing a jsp:include in one page with all of my pages
living under WEB-INF using Tomcat 3.3 (from CVS) and it works perfectly.

Joey

-- Sun Certified Java2 Programmer
-- My Pocket Smalltalk Stuff: www.joeygibson.com/st
--
-- We thought about killin' him, but we kinda 
--  hated to go that far - Briscoe Darling




Re: welcome file in web.xml with pre-compiled jsp's?

2001-08-24 Thread Joey Gibson

On Fri, 24 Aug 2001 12:40:04 -0400, [EMAIL PROTECTED] wrote:

||| PS  I can work around it with a index.htm as a welcome page that redirects you
||| with javascript to index.jsp, but that's very clumsy!

An ever-so-slightly-less-clumsy way to do this it to have an index.jsp
that looks like this:

jsp:forward page=/myaction.do/

This at least avoids the javascript and browser redirection.

Joey

-- Sun Certified Java2 Programmer
-- My Pocket Smalltalk Stuff: www.joeygibson.com/st
--
-- We thought about killin' him, but we kinda 
--  hated to go that far - Briscoe Darling




Re: welcome file in web.xml with pre-compiled jsp's?

2001-08-24 Thread Joey Gibson

On Fri, 24 Aug 2001 10:34:03 -0700, John Raley [EMAIL PROTECTED] wrote:

||| Joey Gibson wrote:
||| 
||| 
|||An ever-so-slightly-less-clumsy way to do this it to have an index.jsp
||| that looks like this:
||| 
|||jsp:forward page=/myaction.do/
||| 
||| But if index.jsp is precompiled (and removed) this won't function as a 
||| welcome file (i.e. something that will be shown if they request 
||| http://host/app/ ).

True. I've not done pre-compiled jsps before, but I would imagine you
could just not precompile this one file? If not, then forget what I just
said.

Joey

-- Sun Certified Java2 Programmer
-- My Pocket Smalltalk Stuff: www.joeygibson.com/st
--
-- We thought about killin' him, but we kinda 
--  hated to go that far - Briscoe Darling




Quarantine?

2001-07-11 Thread Joey Gibson

On Tue, 10 Jul 2001 23:33:04 -0500, Paladin
[EMAIL PROTECTED] wrote:

||| Incident Information:-
||| 
||| Originator:suhas [EMAIL PROTECTED]
||| Recipients:[EMAIL PROTECTED]
||| Subject:  Re: Error: org.apache.struts.action.MESSAGE
||| 
||| Message from suhas [EMAIL PROTECTED] was quarantined because
||| it contained banned content.

Does anyone know what the hell this 'banned content' is that Paladin
keeps telling us about? We're getting these stupid messages about once a
day now.

Joey

-- Sun Certified Java2 Programmer
-- Political Rants: www.joeygibson.com
-- My Pocket Smalltalk Stuff: www.joeygibson.com/st
--
-- We thought about killin' him, but we kinda 
--  hated to go that far




Re: Report to Recipient(s)

2001-07-11 Thread Joey Gibson

On Wed, 11 Jul 2001 08:51:32 -0600, Matt Raible
[EMAIL PROTECTED] wrote:

||| It's cause I typed in what is banned - it's the letter x three times in a
||| row!

You've got to love those simplistic internet filters!

Joey

-- Sun Certified Java2 Programmer
-- Political Rants: www.joeygibson.com
-- My Pocket Smalltalk Stuff: www.joeygibson.com/st
--
-- We thought about killin' him, but we kinda 
--  hated to go that far




Re: Know of any consulting companies?

2001-07-06 Thread Joey Gibson

On Thu, 5 Jul 2001 13:40:06 -0700 (PDT), Eric Loeb [EMAIL PROTECTED]
wrote:

||| Is there an ARS-Digita-like consulting company that
||| uses the various jakarta components to build web apps
||| for clients?

My company, BravePoint (www.bravepoint.com) is an Atlanta-based company
that does Java development using Struts. In addition we have developed and
taught a class on advanced JSP development using Struts that we've gotten
favorable feedback on.

Joey ([EMAIL PROTECTED])

-- Sun Certified Java2 Programmer
-- Political Rants: www.joeygibson.com
-- My Pocket Smalltalk Stuff: www.joeygibson.com/st
--
-- We thought about killin' him, but we kinda 
--  hated to go that far




Re: Know of any consulting companies?

2001-07-06 Thread Joey Gibson

If anyone who read my post about BravePoint and consulting tried to get to
our corporate site, please be sure to use the www.bravepoint.com url and
NOT the links at the bottom of the page. Those links were my personal stuff
and have nothing to do with the company. I didn't mean to include them...

Joey




Present/NotPresent Blows Up With SilverStream 3.7

2001-07-03 Thread Joey Gibson

I'm deploying some struts-apps on SilverStream 3.7 (don't ask...) but
the logic:present and logic:notPresent tags die if the
object-that-I-want-to-check-for is not present. This same app works,
without modification under WebLogic 5.1 and 6.0. Here is the error I get
when hitting a page with the logic:present tag and the thing to check for
is NOT present:

java.lang.IllegalStateException
Attribute org.apache.struts.action.EXCEPTION already has value
javax.servlet.jsp.JspException: Cannot find bean cartItems in scope session

and here is the full stacktrace:

java.lang.IllegalStateException: Attribute
org.apache.struts.action.EXCEPTION already has value
javax.servlet.jsp.JspException: Cannot find bean cartItems in scope session
at
com.sssw.srv.busobj.AgoHttpRequestEvent.setAttribute(AgoHttpRequestEvent.java:330)
at
com.sssw.srv.jsp.AgoJspPageContext.setAttribute(AgoJspPageContext.java:247)
at
org.apache.struts.util.RequestUtils.saveException(RequestUtils.java:919)
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:495)
at
org.apache.struts.taglib.logic.PresentTag.condition(PresentTag.java:138)
at
org.apache.struts.taglib.logic.NotPresentTag.condition(NotPresentTag.java:93)
at
org.apache.struts.taglib.logic.ConditionalTagBase.doStartTag(ConditionalTagBase.java:218)
at
com.sssw.gen.jsps.PetSearch_jsp_1443952992._jspService(PetSearch_jsp_1443952992.java:642)
at com.sssw.srv.jsp.AgoHttpJspPage.service(AgoHttpJspPage.java:92)
at
com.sssw.srv.resources.AgWarResource.doServletDispatch(AgWarResource.java:762)
at
com.sssw.srv.busobj.AgoWarServletRequestDispatcher.dispatch(AgoWarServletRequestDispatcher.java:50)
at
com.sssw.srv.busobj.AgoWarRequestDispatcher.forward(AgoWarRequestDispatcher.java:83)
at
com.sssw.srv.resources.AgWarResource.handleDirectoryRequest(AgWarResource.java:1088)
at com.sssw.srv.resources.AgWarResource.service(AgWarResource.java:523)
at
com.sssw.srv.resources.AgWarURLResource.perform(AgWarURLResource.java:72)
at com.sssw.srv.http.httpd.perform(httpd.java:4421)
at com.sssw.srv.http.Client.processRequest(Client.java:881)
at com.sssw.srv.http.Client.loop(Client.java:1215)
at com.sssw.srv.http.Client.runConnection(Client.java:1419)
at com.sssw.srv.http.Client.run(Client.java:1379)
at java.lang.Thread.run(Thread.java:484)

Has anyone else seen this problem? If so, is there a workaround for it?
All other Struts stuff that I use works perfectly under SS but this is
showstopper. (Yes, I can replace the present/notPresent tags with scripts,
which is what I may have to do, but if I can stick with a tags-mostly
approach, I'd rather do that.

Thanks,
Joey

-- Sun Certified Java2 Programmer
-- Political Rants: www.joeygibson.com
-- My Pocket Smalltalk Stuff: www.joeygibson.com/st
--
-- We thought about killin' him, but we kinda 
--  hated to go that far




Re: Present/NotPresent Blows Up With SilverStream 3.7

2001-07-03 Thread Joey Gibson

I just did some more testing (I always seem to gain insight after I
post...) and I discovered that it is the SECOND occurrence of a
present/notPresent on a page that dies. If I have a present that fails, and
then have another present/notPresent, on the same bean or a different bean,
it will die whether or not the bean is present of not. I can verify this by
moving the dying present/notPresent before the successful one, and then the
failing one works and the successful one dies. It would appear from the
error message and my cursory investigation of the Struts source that when
an attempt is made to find a bean, an exception is being caught and stored
in the org.apache.struts.action.EXCEPTION, and subsequent attempts to
replace that value with another caught exception are what is hosing it
down. 

So, has anyone else seen/verified this situation and what can/should I
do about it?

Joey

-- Sun Certified Java2 Programmer
-- Political Rants: www.joeygibson.com
-- My Pocket Smalltalk Stuff: www.joeygibson.com/st
--
-- We thought about killin' him, but we kinda 
--  hated to go that far