Re: Struts book give-away
Clarification: I did manage to download the pdf, but cannot seem to open i in Acobat 4.0: the file apparantly is corrupted.. Geeta I downloaded and opened fine. You are using a very old version of Acrobat. My version is 6.0, so maybe it only supports a newer version? -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Cactus vs StrutsTestCase
I agree. There are two frameworks I've seen to test struts based web stuff. The easiest to use is StrutsTestCase (the other is mockrunner). It can use both a Mock container as well as Cactus. I haven't gotten around to using the CactusTestCase, as I do most of my unit testing without the overhead of the container (to me, that's for integration testing). The Mock container does a good job I feel. I do have an EJB layer, but I use an interface for my Struts delegate methods. This allows me to send a Mock'ed object of my interface to my Struts Action class to test, without having to go through the EJB stuff (For EJB stuff, I'm using MockEJB, but that's a different email). Nice thing about using Mocks for my delegate classes, is that I can simulate lots of different things. I can tell it to pass anything back to the Action servlet, including throwing exceptions. This allows me to make sure my Action Servlets are handling all kinds of situations. HTH Hi, Ashikuzzaman£¡ I use StrutsTestCase to test my struts-based web tier action. Because StrutsTestCase use mock object to mock the container. So you needn't start your container(tomcat or jboss) to test your action class. It's a very fast way to test. However, StrutsTestCase can not mock EJB call. So if your web application contains EJB you should use cactus, which can start jboss automatically to test your code, or you use the MockEJB to mock your ejb call. -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
setting link inside logic:iterate
What I'm trying to do is create a list of items from an ArrayList in the session. My list is an Array list of objects. Here's the interface: public interface SecurityMenuView { /** * Returns the Struts Action for the given Menu item * * @return */ String getAction(); /** * Returns the label for the given menu item. * * @return */ String getLabel(); } Now, this is what I'd like to do in my jsp (it obviously doesn't work..). logic:iterate id=link name=userView.menuList lihtml:link action=link.action/li /logic:iterate So.. I'd like to set the action to the link element's action property. Does anyone know a good way to do this? I've tried doing this too: logic:iterate id=link name=userView property=menuList lia href='bean:write name=link property=action/'bean:write name=link property=label//a /logic:iterate but it means hard coding the path to the action (i.e., /my-app/action.do. Thanks. -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
MockObjects and Struts
I'm trying to setup an environment to test my Action classes. To do this, I'd like to be able to use MockObjects as my delegate classes. A test Login action, for example, may have an interface SecurityManager, with a single method boolean validateLogin(String username, String password) I'd like to be able to somehow pass a MockObject implementation of my interface to my Action class to test various things. I'm not sure how to do this. Any suggestions? Something things I've thought of: 1. Have field declaration set to default delegate class. Have getter method to change. 2. Insert class as Session variable. I can do this fairly easy in my Test cases, but not sure how I'd do this in deployed situation... TIA. -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Lazy questions on this list
So from what I'm hearing here, as a newb, it is safe to assume that all answers to my questions will be www.google.com... No, but as a newbie many of them will be. Many of them will also be in one of the books that are out there, the docs, the source code or the archive of this list: http://marc.theaimsgroup.com/?l=struts-userr=1w=2 I'd like to point out another possible place to look is: http://news.gmane.org/gmane.comp.jakarta.struts.user or if you prefer a newsreader format: nntp://news.gmane.org/gmane.comp.jakarta.struts.user -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Struts and Links
I'm crossposting this into the Struts group, as this question may have to do with me not understanding how to access a Global Forward inside an a tag. Specifically, this deals with DisplayTag. I don't know if I can use the html:link tag there I'm trying to create a link in my tag that will call a global forward. I'm using a decorator to create the link. My Global Forward looks like this: forward name=doGetCostCenter path=/WEB-INF/pages/getcostcenter.jsp/ Currently, my link looks like this: a href=doGetCostCenter?id=610380action=editEdit/a I've tried it: doGetCostCenter.do full path to app\doGetCostCenter (with and without the .do) I see in the FAQ, it mentions using requestURI in the display:table tag. Does this affect how I would create my value in the Decorator class? Thanks -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts/SQL Server rephrased
Let's restate the question... I'm new to struts and my database is SQL Server. Can someone point me in the correct direction where to find out how to set up an environment that utilizes these two to build an application? You are missing one more component.. Your application server. Are you using Tomcat? JBoss? Weblogic? Basically, any Struts tutorial will help you on that side of the equation. For SQL Server, you'll need a JDBC Driver. After that, follow your application server's instructions on setting up a datasource. -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
html:base / Question
This is probably less a Struts question than it is an HTML question, but I figured most here have dealt with this issue. I'm a little confused by the html:base / tag. Lets say we have the following directory structure WITHIN our webapp: webapp - images - myimage.jpg - scripts - WEB-INF - pages - test.jsp Ok. Now I've got a jsp page that's in the webapp/WEB-INF/pages directory. In that webapp, I've got the html:base / tag declared in the header. Now, when I view source on my test.jsp page, I see this: base href=http://localhost/webapp/WEB-INF/pages/test.jsp/ Now, on that page, I want to reference an image in webapp/images/myimage.jpg. I can get there by using: href=../../images/myimage.jpg But I'd rather not. Is there a way to get to the root of the webapp? I've tried: /images/myimage.jpg And that doesn't seem to work. -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JAAS Login using LoginAction...
Anyway, tried the ideas from this website using JBoss 3.2.1 and Struts 1.1? There's nothing specific to Struts you need concern yourself with. The only thing that's struts related is how you get your login information. I've used one of 2 methods: 1. Used a login.jsp, with username and password. LoginAction and LoginForm or 2. No login form. Use Servlet Filter to see if there's a UserView in the session. If not, redirect to a login screen (see #1 above). Now, the details are more specific to JBoss than Struts, and is really beyond the scope of this mailling list. But.. Here's what I suggest: LoginContext loginContext = new LoginContext(client-login, (CallbackHandler)handler); loginContext.login(); Make sure you have client-login defined in your login-config.xml, and its using the org.jboss.security.ClientLoginModule. Your application must define the authentication policy that contains your DatabaseLoginModule. Contact me offlist if you have any other questions. Or better yet, visit the JBoss forums. -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Page Title
How do i assign different title for each page using tiles. Following is my tile layout which has title My Site Name. And it has Header, Side Menu, BODY, Footer. Should i have title/title in each BODY jsp ? Is there any short cut to get the page name and over ride the main layout title ? Definitely. Put this in your header: titletiles:getAsString name=title//title Now, in your tiles-def.xml file, put this: definition extends=default.layout name=browse.costcenters put name=title value=BIS-Web Browse Cost Centers/ put name=body-content value=/custom/browse-costcenters.jsp/ /definition -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: logic:iterate problem
uhh.. Never mind. Figured it out. Told you all it would be something stupid. Forgot to add the %@ taglib uri=/tags/struts-bean prefix=bean%... Sorry to waste bandwidth. -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
logic:iterate problem
Basic question, should be easy, but Im obviously missing something easy. Trying to iterate through a java.lang.Set collection that I have put in my session. My jsp will display the header information, but nothing else. This is my jsp. It is a tile, so what you see below is the complete content file (tried with and without the type parameter): [BEGIN CODE] %@ taglib uri=/tags/struts-html prefix=html% %@ taglib uri=/tags/struts-logic prefix=logic % table trthCenter/ththTitle/ththTotal/th/tr logic:iterate id=centerItem name=browseCenters type=com.berzerkersoft.bisweb.db.ejb.value.CenterBrowseValue tr tdbean:write name=centerItem property=center//td /tr /logic:iterate /table [END CODE] Below is a fragment of my Action class. Note the System.out.println, where I print out the values. This is outputing the expected output. [BEGIN CODE] Set browseCenters = getBrowseCenters(userView.getUsername()); Iterator itr = browseCenters.iterator(); while (itr.hasNext()) { CenterBrowseValue browseValue = (CenterBrowseValue)itr.next(); System.out.println(browseValue); } session.setAttribute(IConstants.BROWSE_CENTERS_KEY, browseCenters); return mapping.findForward(FORWARD_browse); [END CODE] -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: logic:iterate problem
To partially answer my own question, I changed this: table trthCenter/ththTitle/ththTotal/th/tr logic:iterate id=centerItem name=browseCenters type=com.berzerkersoft.bisweb.db.ejb.value.CenterBrowseValue tr tdbean:write name=centerItem property=center//td /tr /logic:iterate /table to read: table trthCenter/ththTitle/ththTotal/th/tr logic:iterate id=centerItem name=browseCenters type=com.berzerkersoft.bisweb.db.ejb.value.CenterBrowseValue tr tdElement Value: bean:write name=centerItem property=center//td /tr /logic:iterate /table and I get the exact number of Element Value: outputs, but no output from the bean tag So something must be wrong with the bean tag or the way I have my id declared... -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Confused by index.jsp, welcome.jsp, and logon.jsp
In my mind, http://localhost:8080/logon tells to look for logon.do. According to the action mappings: action path=/Logon That would be http://localhost:8080/logon/Logon.do the logon (lowercase l) is the application context. By typing http://localhost:8080/logon, you access the default welcome page (see your web.xml file, should be index.html, index.jsp). The welcome.jsp is invoked because index.jsp is just a forward to the welcome forward. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Design Opinions Please
Thanks again to all who helped me with the definitions problem. Working great now. I'm now trying to figure how I want to design my application. Here are the specific actions (not necessarily struts actions): 1. Login Verification 2. If #1 Successful, Read user's options, and forward to the user's default page. What I had hoped to do was to create 2 actions, LoginVerificationAction and DefaultScreenAction (and a 3rd, the action for the user's Default Screen, lets call it DefaultAction). In effect, this would chain 3 Actions, but I came across the problem that I couldn't forward an action to another action (or can I?). Another option was to forward to jsp pages, that would just forward to the specified action, but this seemed kind of silly. Any ideas on the above problem? -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: newbie question
Now I want to call sicpage1.jsp directly without first calling sicpage0.jsp. But sicpage1.jsp is not getting populated with data since the action class is not getting called. create a global forward to the action, and call the forward. -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: one page, multiple forward to's - how do I do that?
This has probably been asked a million times. I have several pages where the user can click to go to a login page. I want to use the same page for the login. How can I set it so that after the login it goes back to the page it came from? One way is to add the url to the session. Here's what I do: 1. Filter intercepts incoming request. 2. Checks to see if user object in memory. 3. If not, write the requesting URL into session, and forward to login screen. 4. Login screen. 5. If login successful, retrieve URL from session. 6. If URL = null, then go to default page. 7. If URL null, then forward to URL. -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tiles Definition problem
Thanks to everyone who responded. Everyone recommended doing this: Try this: forward name=defaulttile redirect=true path=default.layout/ Still doesn't seem to work. I get the feeling I'm missing something so insanely stupid that its tough to figure out. I'm not sure how to get any more debug information. The only thing I'm getting on the console that looks like its Struts related are these lines: Aug 25, 2003 1:32:08 PM org.apache.struts.util.PropertyMessageResources init INFO: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true Aug 25, 2003 1:32:09 PM org.apache.struts.util.PropertyMessageResources init INFO: Initializing, config='org.apache.struts.action.ActionResources', returnNull=true Aug 25, 2003 1:32:10 PM org.apache.struts.util.PropertyMessageResources init INFO: Initializing, config='resources.application', returnNull=true Aug 25, 2003 1:32:10 PM org.apache.struts.tiles.TilesPlugin init INFO: Tiles definition factory loaded for module ''. Aug 25, 2003 1:32:11 PM org.apache.struts.validator.ValidatorPlugIn initResources INFO: Loading validation rules file from '/WEB-INF/validator-rules.xml' Aug 25, 2003 1:32:11 PM org.apache.struts.validator.ValidatorPlugIn initResources INFO: Loading validation rules file from '/WEB-INF/validation.xml' Aug 25, 2003 1:32:12 PM org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on port 8080 Aug 25, 2003 1:32:13 PM org.apache.jk.common.ChannelSocket init INFO: JK2: ajp13 listening on /0.0.0.0:8009 Aug 25, 2003 1:32:13 PM org.apache.jk.server.JkMain start INFO: Jk running ID=0 time=30/331 config=C:\jtools\jakarta\jakarta-tomcat-4.1.2\conf\jk2.properties Aug 25, 2003 1:33:01 PM org.apache.struts.util.PropertyMessageResources init INFO: Initializing, config='org.apache.struts.taglib.logic.LocalStrings', returnNull=true I don't know if any of this will point to problems or not. Instead of reposting all my code again, It can be downloaded here: http://www.berzerker-soft.com/testtiles.zip here's the content of my previous email, in case you don't want to download. Thanks in advance... /WEB-INF/tiles-def.xml ?xml version=1.0 encoding=UTF-8? !DOCTYPE tiles-definitions PUBLIC -//Apache Software Foundation//DTD Tiles Configuration//EN http://jakarta.apache.org/struts/dtds/tiles-config.dtd; tiles-definitions definition name=default.layout path=/templates/defaultLayout.jsp put name=title value=Default Title/ put name=header value=/common/header.jsp/ put name=menubar value=/common/menubar.jsp/ put name=body-content value=/common/body-content.jsp/ put name=footer value=/common/footer.jsp/ /definition /tiles-definitions - /WEB-INF/struts-config.xml -- ?xml version=1.0 encoding=ISO-8859-1? !DOCTYPE struts-config PUBLIC -//Apache Software Foundation//DTD Struts Configuration 1.1//EN http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd; struts-config form-beans/ global-exceptions/ global-forwards forward name=defaulttile redirect=true path=default.layout/ /global-forwards action-mappings /action-mappings controller processorClass=org.apache.struts.tiles.TilesRequestProcessor/ message-resources parameter=resources.application/ plug-in className=org.apache.struts.tiles.TilesPlugin set-property property=definitions-config value=/WEB-INF/tiles-defs.xml/ set-property property=definitions-debug value=2 / set-property property=moduleAware value=true/ set-property property=definitions-parser-validate value=true/ /plug-in plug-in className=org.apache.struts.validator.ValidatorPlugIn set-property property=pathnames value=/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml/ /plug-in /struts-config index.jsp %@ taglib uri=/tags/struts-logic prefix=logic % logic:redirect forward=defaulttile/ -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tiles Definition problem
David. Thank you very much. I knew I was missing something very simple. I had 2 books I had been referencing, Programming Jakarta Struts and Struts In Action. I guess I missed the forward thing in those docs. Thanks again, its working great. -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tiles Definition problem
I'm going to describe my problem, then list the appropriate files below. I'm new with tiles, and am trying to get a simple tiles-definition working. Here's what I did: 1. I create a file called tiles-def.xml, and put it in my WEB-INF directory (listed below) 2. Make sure my definitiions-config property is set for the TilesPlugin. 3. While I'm in the struts-config, I set up a forward for my definition (see below). 4. I have verified that the individual tiles and layouts do exist and seem to be correct. typing: http://localhost:8080/testtiles I end up getting a 404: The requested resource (/testtiles/default.layout) is not available. Any help is appreciated. /WEB-INF/tiles-def.xml ?xml version=1.0 encoding=UTF-8? !DOCTYPE tiles-definitions PUBLIC -//Apache Software Foundation//DTD Tiles Configuration//EN http://jakarta.apache.org/struts/dtds/tiles-config.dtd; tiles-definitions definition name=default.layout path=/templates/defaultLayout.jsp put name=title value=Default Title/ put name=header value=/common/header.jsp/ put name=menubar value=/common/menubar.jsp/ put name=body-content value=/common/body-content.jsp/ put name=footer value=/common/footer.jsp/ /definition /tiles-definitions - /WEB-INF/struts-config.xml -- ?xml version=1.0 encoding=ISO-8859-1? !DOCTYPE struts-config PUBLIC -//Apache Software Foundation//DTD Struts Configuration 1.1//EN http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd; struts-config form-beans/ global-exceptions/ global-forwards forward name=defaulttile redirect=true path=/default.layout/ /global-forwards action-mappings /action-mappings controller processorClass=org.apache.struts.tiles.TilesRequestProcessor/ message-resources parameter=resources.application/ plug-in className=org.apache.struts.tiles.TilesPlugin set-property property=definitions-config value=/WEB-INF/tiles-defs.xml/ set-property property=definitions-debug value=2 / set-property property=moduleAware value=true/ set-property property=definitions-parser-validate value=true/ /plug-in plug-in className=org.apache.struts.validator.ValidatorPlugIn set-property property=pathnames value=/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml/ /plug-in /struts-config index.jsp %@ taglib uri=/tags/struts-logic prefix=logic % logic:redirect forward=defaulttile/ -- Bryce Fischer [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]