more questions
One of the problems I'm having with and probably more with the XML nature of JSP is that form elements have to be within tags, and no in an include used by . I have common components that different forms use, but have to do either a cut-n-paste(tm) or use <%@ include ... %> instead? Any thoughts? -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: template:put and get
I decided to do the second option, it works quite well. I don't like the idea of putting the while tag into the because that'd make the template file confusing for someone trying to maintain it (the image tag would never appear in the source for the included file, the developer could spend ages trying to work out what's going on) >JR> but replace the page="" with the . Trouble is you can't nest >JR> tags. One options is to do the html without the jsp, and have > >JR> height="23" border="0"/> > >JR> but that doesn't look great, but I can't think of anything else. The > >JR> seems to hide the content away somewhere away in the request, and I don't want to >JR> create 20 little html/jsp pages for the different headers that I have. > >JR> Any ideas? > >You can place whole html:img tag to the template:put tag as its >content and cut content and direct attributes. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
template:put and get
I've got a situation where I want to include a header file with and then in the header file have but replace the page="" with the . Trouble is you can't nest tags. One options is to do the html without the jsp, and have but that doesn't look great, but I can't think of anything else. The seems to hide the content away somewhere away in the request, and I don't want to create 20 little html/jsp pages for the different headers that I have. Any ideas? -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: JSP expressions inside custom tags
try "> You need to have the <%= %> present the whole string, not just the single part. At 10:56 AM 8/06/01 +0200, you wrote: >Hi! > >I am evaluating struts for a new project. One problem I wasn't able to solve >was the integration of JSP expressions inside the attributes of >custom tags. > >My code looks like this: > > > <% String name = ((PElement)pelement).getName(); %> > > ^^^ Here is my problem! > > > > >The links always contain the <%= name %> string instead of the evaluated >expression. I tried it with different quoting techniques but without luck. > >What is the correct solution here? > >TIA, >Erich > -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: New Windows, Struts, IE 5 and sessions dying
At 07:04 PM 1/06/01 +1200, you wrote: >Summary: Any known bugs and workarounds with Multiple Windows in IE5, >Servlet Sessions and Struts 1.0b1? A few things to note. Have a look to see if the redirect is forcing :80 (port 80) onto the end of the URL, this can cause the session get lost in the ether. Upgrade to struts-b2 and it'll go away. Another thing to note is that on NT you can have each IE run in a separate process, which gives it its own set of cookies, which will also loose the session value. I think it's probably the first one though, as you'd be using to generate the URL for the javascript, and up until struts-b2 it would add the port into the address and confuse the browser. This happens in Netscape Navigator as well. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: Potential Security Flaw in Struts MVC
At 11:53 PM 30/05/01 -0700, you wrote: >A good way of removing the bucketloads :-} from your Action classes is to >subclass ActionServlet and implement processActionPerform to do the logon >check. It's not just for login though, that was the example I used, every action that generates a form needs to do this. Mostly it is checking against URL hacking. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: Potential Security Flaw in Struts MVC
>> In the case at hand, nothing stops your user from logging on (so your >> security checks won't catch anything) and then hand typing a URL with >> query string parameters that maliciously or accidentally try to change >> things in the system. If the user is successful at doing this, it's shame >> on the app developer for listening to request parameters that you >> shouldn't. This is a good point. I'm finding my Actions and Forms have bucketloads (and that's the technical term for it) of User user; if ((user = (User) request.getSession().getAttribute("user") == null) return mapping.getMapping("index"); and on, and on and on. I'd like to try and find a good way to simplify this as best that I can. (This example is required if the session times out, other examples appear when a browser auto-fills in a URL and the user submits it without the form fields. etc. Very bad karma in that case.) >> Of course, you need to take other defensive measures as well (like using >> the transaction control support to avoid accidental or malicious resubmits >> of the same data). I've seen this in the example application, is there any documentation on using it (as best as possible). Thanks. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: Possible to access Init Params from JSP??
George Craig wrote: > Yes you can. Here is how to do it: > > <%= > application.getInitParameter(SOME_KEY) > %> Does this actually work? I've had report that in Tomcat and JRUN, it doesn't seem to return the values. Has anyone used it?
Re: subclassing ActionServlet?
I made a sub-class of ActionServlet an overloaded the initXXX() method that created the connecion pool. I did this because my database manager beans needed access to the connection pool parameters. The other choice is to use something like a singleton or factory bean pattery that generates the objects (or returns an instance to an already created one) as you need it. The down side is it may not have the initialisation parameters it needs. [EMAIL PROTECTED] wrote: > > Hello struts-users, > > My webapp needs bunch of beans that should be available > all the time and accessible from all JSP pages, so I guess I > have to create the beans at the startup time and set them to > the application context. > > How should I do this? My candidates are, > > 1) create a subclass of ActionServlet and do it there, > 2) create a subclass of Servlet (unrelated to ActionServlet) > and do it there. > > Which is better, or are there any other standard ways? > I don't see any examples that use subclasses of ActionServlet, > and I am wondering if there are some reasons not to. > > Thanks in advance, > > - kazumi
Re: Iterating on an Iterator?
takes a collection and can do that for you. >Our object model provides an Iterator interface to walk along >lists (properties of an object or lists of objects). > >Does anyone know how can I take advantage of a tag library to >accept an iterator an iterate using Iterator.hasNext() and >Iterator.next()? -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: Architecture for a form-wizzard
>I`m building a site that uses a application form that spans over several >pages. How should I design this application? >1. With formBeans for every page >2. One formBean for the entire application form What I find I am doing is building a separate form bean for each page that just represents the data for that page, and having a bean in the session the represents the data for all the pages within that transaction. The each form has a pre-action which populates the form from the session bean, and a post-action which sets data back into the session bean. The post-action then forwards onto the next pre-action for the next form. So something like PreForm1Action -> form1.jsp -> PostForm1Action -> PreForm2Action -> form2.jsp -> PostForm2Action this seems to work okay for now. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: Indexed Grid Representation on a Form
> So reading your comments, Jim, it sounds like your using code analagous to > this but your implementation uses a map instead (?) Yeah, I use them in form fields, for , radio buttons and checkboxes. > BTW, now that I'm using html field names like customerContactName[0].title, > I find that conventional javascript to set focus doesn't work - I get > javascript errors. Any ideas how to reference these fields? You can reference the javascript like document.form_name['customerContactName[0].title'].value Because JavaScript thinks the name is a valid JavaScript construct and so trys to look it up in its DOM model.
Re: Indexed Grid Representation on a Form
It should be: <% int i = 0; %> <% i++ ; %> "/> You need to replace the whole string. The exception would have been from the BeanUtils not able to understand what the [i] would have meant. If you have an iterator in a scriptlet, then you need to always use a scriptlet to access it. Usually. Mostly. I had a feeling there was a change made to iterate recently to give you an index value, but I can't remember what it was. I usually use a Map and have the key as the integer value in the index for the entry. Works well when you don't have liner numbering in the list of key/value pairs.
Re: is it a bug of CheckboxTag
> Another thing is that you shouldn't call .jsp pages directly. They > should always be called through an Action first. From the exmaple, > the subscription page is called through (I think) editSubscription.do > to populate the form, and then forward to the .jsp page. I should clarify this a bit. You shouldn't call .jsp pages directly that need to be populated by the database or elsewhere. Generic .jsp pages that just display data, content or whatever can be done fine by calling them directly if the beans are pre-populated (eg, a session or application scope bean). But if they are an editing form, eg, user details or content editor then they should have an Action populate them first.
Re: is it a bug of CheckboxTag
Set the value to true in the ActionForm reset() method. Another thing is that you shouldn't call .jsp pages directly. They should always be called through an Action first. From the exmaple, the subscription page is called through (I think) editSubscription.do to populate the form, and then forward to the .jsp page. At the top of the .jsp page you can then put something like (and this is from memory, so I'm not sure of the exact syntax) JeanX wrote: > > Jim Richards wrote at 2001-05-15 14:48:00, > >JeanX wrote: > >> If I uncheck a checkbox, there is no corresponding parameter pair in request. > >> So I can not get the right status of certain form. > >> How to resolve it ? > > > >In you ActionForm reset method you need to set all the checkbox values > >to false, as reset() is called before the form is populated. > > > >That way, the only values that get sent are the ones that need to be > >set to true, and the ActionForm is correctly set. > > So if I wanna some checkbox default true, > How can I do?
Re: is it a bug of CheckboxTag
JeanX wrote: > If I uncheck a checkbox, there is no corresponding parameter pair in request. > So I can not get the right status of certain form. > How to resolve it ? In you ActionForm reset method you need to set all the checkbox values to false, as reset() is called before the form is populated. That way, the only values that get sent are the ones that need to be set to true, and the ActionForm is correctly set.
Re: 2 newbie questions..
The mapping that is sent to your object has the global mappings, and the local ones as well. As for your second question, I'm not sure but the example application was done very early and it wouldn't surprise me if the class is not used at all. Have you tried a global search? If it's not used anywhere then it might be a hang over from earlier iterations of the code. >Quick questions from a newbie.. When the mapping is local to a >particular action, the Action class should call findForward on the mapping >that's passed in. But if the mapping is a global one, it should call >findForward on the instance of ActionServlet (called servlet) that is passed >down from the parent Action class. Is this correct? Or does the >ActionMapping that's passed in to the perform() method already contain the >global mappings? The reason I ask if because I really don't like the idea >of having access (and having to use) member variables of a parent class. It >makes my OO alarms go off. The example Struts application uses the >"servlet" object, instead of the ActionMapping instance. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: Philosophical question(s) related to STRUTS
As a profession developer I have taken to learning how to use Struts for several reasons (besides being Java, and thus way cool). It's free. It doesn't cost me anything to develop or deploy. Open Source. If the development team die in a freak accident from caffeine overdose at something like JavaOne then I can continue to apply my own patches to it. If Oracle disappeared tomorrow (or Cisco?) then who is going to apply patches, provide support and have further releases? if you end up developing your own framework, that's great but why re-invent the wheel? Does it matter if it doesn't become sanctioned? Your own framework won't become sanctioned? I developed my own framework when Turbine was being developed and discovered that amount of work it took was huge. I could have adopted Turbine an done all the development with that (I didn't because Turbine is huge and I was starting out with JavaServlets, and the best way I learn is to do it myself.) > 1) Is SunMicro going to be supporting STRUTS from a financial and/or > marketing standpoint ? > I only saw one tiny, tiny mention of STRUTS in the JAVAONE outline of > presentations I just got in the mail. > That bothers me. > > 2) If the answer to #1 is unknown, will JSP/Java serverside professional > developers take the time to learn STRUTS and employee it in their web > applications ? > > 3) If the answer to #1 is unknown, will corporations and consulting firms > decide to committ to STRUTS in lieu of their own frameworks and methodology > ? > > I am wading thru the one-inch thick documentation and I must say I am really > impressed with the work done so far. > However, as a consultant, I must be concerned about spending too much time > with this if it is not going to become a popular or sanctioned approach in > the webdev marketplace. > > Thoughts / feedback anyone ?
Re: Initialization of Request-Scoped Objects
No. What I do (antd I think it this is from the example app as well, maybe subscription.jsp) is to put at the beginning of the .jsp file (this is from memory, don't have the code handy) Where editFormCode is set up as a forward in the struct-config.xml file. This way, if the form bean has not been set up, it forwards the code through the form bean. This technique is useful for things like checking a user bean has been set in the session as well. > Jeff Trent wrote: > > When myAction.do is called, I have a chance within reset() to initialize my >request-scoped objects. However, if myAction.jsp is called instead then I can't seem >to find a way to get initialized. Are there any methods called in my Action class >when the > .jsp file is invoked instead of the .do file? >
Re: FW: Design Error? Bean repopulation...
I had this problem, and worked out a solution that seemed workable. The main thing to remember with the tags is the the name part should always be the name of the form bean, and the property be relative to that, otherwise the BeanUtils won't be able to repopulate the form. I tend to store my collections in SortedMap's and use the primary key of the database table as the index into the SortedMap (This means, each bean has a getId() which is an integer, and the Bean has the comparable interface to sort them). Then when I do the iterate, I iterate over the keys of the map and return just the Map.Entry values. Then when I do the I have something like (this if from memory, based on your code, it might take a few hacks to get right, I think you'll need a useBean for the retailerForm, can remember) "/> <%!-- or, if the bean identity id id, and so we use getId)( --%> "/> I use this method all the time, it works great. Here's another message with a copy of the code I use http://www.mail-archive.com/struts-user%40jakarta.apache.org/msg07627.html > - I have a number of beans held in a Vector. > - In my ActionForm I have a two getters for this vector - one returns the > vector and one returns elements of the vector - so something like this: > > public RetailerBean getRetailerBean( int index ) > { > return (RetailerBean)retailers.elementAt( index ); > } > > and > > public Vector getRetailers() > { > return retailers; > } > > This works fine to populate using the following type of iterate tag: > > > > > > --> > > > > However, it doesn't repopulate the beans when I do a submit. This is > because the generated html is something like: > > > > rather than: > > > > > which would allow my beans to be repopulated. > > The outcome of this is that I have to create arrays for all properties of my > beans in my ActionForm and take the values from there. This seems like > bodge-heaven and not at all object-oriented. > > If the form can be populated directly from the beans then surely it should > work the other way too.
Re: How do you use indexed properties with html:input?
At 12:12 PM 9/05/01 +, you wrote: >Hi, >I *guess* that the html: tags require a form bean (please correct me if >this is wrong) so they won't work with dynamically created page elements >like input text fields. > >I did the following and it works, got the idea from Scott Walter (thanks) - >see http://www.mail-archive.com/struts-user@jakarta.apache.org/msg06972.html I do a different thing. I have the data stored in a SortedMap and have the setter and getter methods like this (where templateEntries is the SortedMap): public TemplateEntry getEntry(int orderId) { return (TemplateEntry) templateEntries.get(new Integer(orderId)); } public void setEntry(int i, TemplateEntry templateEntry) { templateEntries.put((new Integer(i)), templateEntry); } and then the fields in the form are generated from an iterate loop over the SortedMap, each templateEntry bean having an id (the primary key in the database table). This way the id's don't have to be sequential (it's not an array index) and it's pure struts tags. They end up looking like this (there's alot of deeper stuff here, I don't have the time to make a clean example at the moment), what's important is the and bits. I'll leave the rest as an execise for the reader. order_id= : "/> : "/> Yes, I'll write a huge article once the project is over on what the hell I did, because I don't think I'll fully understand what I have done until then. (Just did some way cool stuff with some JavaScript that generates a date widget for user input) -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: Forward to an Action
Try instead of > -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: Struts and DAO pattern. Expensive?
> I need to confess I'm lost. The PetStore approach sounds cleaner in some > sence, but also sounds too repetite in other, and mostly, sounds way to > expensive (or it isn't?). Struts uses a connection pool. So when you do a getConnection() you're actually pulling one out from a pool of shared connection objects, so there is no real problem with generating a new connection. In my application I have manager objects will deal with data beans, and these managers have methods that all look the same (open connection, select data, build bean, close up, return). Yes it's a lot of cut and paste. I'd prefer to have used EJBs but the project size doesn't warrant such expense (time and effort, not money).
Re: pleae help..submit button only allows 1 parameter to be sent with the request
Do you have multiple submit buttons, and your action treats the data differently? You can use hidden fields, so that all the data is sent with the form fields. Then your action can determine which fields to use based on the valud of the submit button. If you have the same input field name and different values then you can either use some funky JavaScript to set the hidden fields values, or give them different names. This second option may break your form beans though. At 11:36 AM 2/05/01 +0200, Dudley Butt@i-Commerce wrote: >I want to be able to send more than one parameter when the submit button is >clicked. >currently i have this... > ><--- I want more >parameters to be sentis this possible? > > > >thanx > -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: struts at webappcabaret
Michael Mok wrote: > The servlet engine to use is Tomcat 3.1. Tomcat 3.1 has lots of buggies in it, you're better off using a 3.2.x version or go straight to a 4.0, although I think 4.0 is still in beta.
Re: Why isn't ActionsErrors throwable?
Because exceptions are slow, and can only handle one error at a time. The design as it is, allows for multiple action errors to be returned to a page for display. Exceptions should be for catastrophic errors that cause the system to barf. Having a blank password doesn't really fit within that framework. > The question is: Why doesn't ActionErrors extends > Throwable? Does it make sense to make a change in the > framework class org.apache.struts.action.ActionErrors > and make it throwable?
RE: why does struts use forward instead of redirect
In your code you can, I don't think there is a run-time parameter between them because it would affect code quite drastically if you switched from forwards to redirects. At 08:40 AM 25/04/01 +0100, you wrote: >Can you switch between the two, i.e. make struts use redirect? >>At 11:13 PM 24/04/01 -0400, you wrote: >>Anyone know why struts uses forward instead of redirect? > >A redirect sends a request back to the browser, thus generating another >connection between the client and server. Forward keeps it internal >to the server, which also means you can re-use the request object. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: why does struts use forward instead of redirect
>At 11:13 PM 24/04/01 -0400, you wrote: >Anyone know why struts uses forward instead of redirect? A redirect sends a request back to the browser, thus generating another connection between the client and server. Forward keeps it internal to the server, which also means you can re-use the request object. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: help with JavaScript and text box.
Try document.requisition['requisitionLines.requiredOnDate'].value = "the new value"; Alex Colic wrote: > > Hi, I have a text box mapped to a bean via: > > > > My form is called requisition. > > If I try to set the value of the text box via JavaScript I have to access > the box via > form.object or requisition.requsitionLine.requiredOnDate. > > JavaScript can't find the box due to the numerous '.'. > > Is there a way around this to access the box. Any help is appreciated. > > Regards > > Alex
Re: servlet context attribute?
"Young, Wayne" wrote: > > Ok, that gets me closer. I created the servlet & put the following code in > the init() method. > > // Store the lookup service in the servlet context >LookupService lookupService = new LookupService(); >getServletContext().setAttribute("LookupService",lookupService); > > I need to get access to this attribute in a class that has nothing to do > with servlets. Is there a method call I can make? Not really no, you might want to look up the definition of the single design pattern. I don't have the references here, but the basic idea is to not create the object as you done about but have LookupService lookupService = LookupService.getInstance(); and then public class LookupService { private static LookupService instance = null; public LookupService getInstance() { if (instance == null) instance = new LookupService(); return instance; } } so you can grab the objcet any where and be assured there is only one instance that you are sharing. You of course then need to make sure that the methods are synchroni(s|z)ed.
Re: Newbie datasource Q
What specific operation are you trying to do? Since you don't have autocommit set to true, you may be having transaction problems. I found it helpful to create a Test.java file with the same operations as creating the datasource (with the same parameters), a connection and doing a sample select statement. It helped to confirm where errors might be happening. JOEL VOGT wrote: > later on in a servlet I have > > javax.sql.DataSource dataSource = servlet.findDataSource(null); > con = dataSource.getConnection(); > > When I try to use this however, I get an java.sql exception : > 'no data found'
never ending iterate tag questions
I've now got the tag to work, but I'm confused about how it works with the collection attribute. I've seen examples for people where they have ... do something with bean ... but the documentation http://jakarta.apache.org/struts/api/org/apache/struts/taglib/logic/package-summary.html#package_description indicates that it should be used thus: ... do something with bean ... The difference here being the "=" inside the scriptlet for the collection attribute. When I don't have the "=" as the documentation suggests, I get Unable to convert a String to java.lang.Object for attribute collectio and if I do use the "=", which seem to be the correct way, looking at the generated Java code, I get the correct response. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
RE: Alternative Frameworks - continued
At 10:25 PM 20/03/01 -0800, you wrote: >Eric, >Have you looked into ASP.net vs ...? The main problem there is that a lot of the development tools are beta, and finding an ISP that will host it is also difficult. It will be at least 12 months before it has settled down. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: Confusion : Usage of Struts
What happens to javascript validations? Where do we fit them in the comlete picture? They don't happen at the moment. Part of the Struts 1.1 plan is to look at some forms of autogeneration of JavaScript validation. A few people have implemented their own system for this. Who takes care of whether is it a normal application or struts application. does the container do this ? There is no real difference, struts is normal ;-) When the web container is set up it need to know that a path ending in .do is part of struts, as are .jsp pages. If we have to code the struts-jsp and a corresponding bean for every form then where is the convenience ? Are we not trading one problem with another. I'm not sure what you mean, but there is some shortcut methods you can handle with the form input/output part. If you read the taglib documentation you'll see examples of this. Under what circumstances do I need to extend ActionServlet and use that ? When you need something that it doesn't provide. For example I extend ActionServlet to implement setting up singleton objects for database access. I have a gut feeling that struts application will be slow as it involves one extra component at the server side for every single GUI developed ? Milliseconds slower ;-) Can some body who is deeply involved with struts development reply. I'n not that deeply involved, but they are valid questions. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: PostgreSQL problems.
I've finally got the problem sorted out. It was rather obscure, but I think I could have only solved it because of the "Joy of Open Source(tm)". When I built my postgresql.jar file, I only put .class files into it, not realising there were some error_xx.properties file to be put in as well. I was getting an error during ActionServlet loading because there are documented "not supported" errors that would throw an SQLException, but since the error_xx.properties was not there an extra NullPointerException was being thrown (because the ResourceBundle was null, because there were no .proerties file) and this rippled through the system and broke init(). I've rebuilt my postgresql.jar file and the system loads, I can access the database and we'll all live happily ever after. At 11:30 PM 14/03/01 +1100, Jim Richards wrote: >At 01:28 PM 14/03/01 +0100, you wrote: >>We are currently using PostgreSQL as a database in a productive system together >>with struts. We tried with Interbase before, but ran into many many >>difficulties. So we switched to PostgreSQL and everything went well from then >>on. >> >>What specific kind of problems do you have? > >See > > http://nagoya.betaversion.org/bugzilla/show_bug.cgi?id=827 -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: PostgreSQL problems.
At 01:51 PM 14/03/01 +0100, you wrote: >This does not sound at all like a PostgreSQL problem. > >Doesn't the error also show up, when you remove the datasource section? No. That's the catch, it loads and runs if there's no datasource section in the struts-config.xml file (although you need to comment out the database code, or not access it). -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: PostgreSQL problems.
At 01:28 PM 14/03/01 +0100, you wrote: >We are currently using PostgreSQL as a database in a productive system together >with struts. We tried with Interbase before, but ran into many many >difficulties. So we switched to PostgreSQL and everything went well from then >on. > >What specific kind of problems do you have? See http://nagoya.betaversion.org/bugzilla/show_bug.cgi?id=827 -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
PostgreSQL problems.
I'm still getting problems with PostgreSQL (documented previously several times). Has anyone used it successfully as a database. Yes, I've got the settings correct, the JDBC string correct, lots of other things. I really need someone who actually has it working to put their hand up and say "yes, it does work, this is how I did it." Thanks. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: Business Object Bean Persistence Strategies
My approach is to have: JSP <-> Struts Form/Action <-> Business Rules <-> Database The busines rules are set up as singleton object on servlet startup. I've subclassed the ActionServlet and overloaded the datasource init method, there I set up the four business rule classes and put them into application scope, on creation the business classes get their datasource reference. The objects I pass around are data beans that model the database closely (similar to entity EJBs). So for logon, I have a User() object where I set the user_id and password from the logon form, then the action class will call User user = UserManager.logon(User user) which will either find the user and return a fully filled user object or throw and exception (I might change that though). UserManager has other methods for logoff, update and create. So the action code doesn't need to send the dataconnection because that ties the Action too closely to the data store (what happens if the authentication changes to LDAP or unix password/username or database password/username?). It also means I can reuse the business rules for another project that might not be struts based. (But whay would I do that ;-) Michael McCallister wrote: > > 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
Database pooling code
Has anyone got the database pooling code/DataSource to work or specifically had it fail? I've been having problems (documented previously) and I've read about a few others who can't seem to get the pooling to work as well, and I want to get an idea of specifically where the problem might lie in order to fix it. You are the simulacrum of my dreams and the signifier of my desires Mr Grumpy ... come and visit his home! http://www.cyber4.org/members/grumpy/index.html
Re: Problem for connecting DB
Can you send the top few lines from the exception stack trace? I think I have a similar problem with a different set up (solaris/postgreSQL). I have a feeling the database code just doesn't work. "Wang, Meng" wrote: > > Dear Jim, > > Thank you for your rapid response. Here is the specific information: > > Web server: tomcat321 > database: ACCESS > OS: Window 2000 > JDK:JDK1.3 > -- > 1. For testing purpose, I put database under my application root directory > and setup DSN in ODBC. > > 2. I initiate the database config in the struts-config.xml: > > > autoCommit="false" > description="Example Data Source Configuration" > driverClass="sun.jdbc.odbc.JdbcOdbcDriver" >maxCount="4" >minCount="2" > key="abc" > password="" >url="jdbc:odbc:test" >user="" /> > > 3. The codes in the Action class for connecting the database is: > try { > > DataSource ds = servlet.findDataSource("abc"); > . > > The problem is: can NOT find the data source. Is there any more thing to > do for connecting the database? > > Thanks a lots!!
Re: Problem for connecting DB
Can you be more specific? What web server, what database, what's your environment? What JDK are you running? What problems did you get? "Wang, Meng" wrote: > > Hi, I tried to use struts to connect the relational database and experoenced > some difficulties. Is there some example to show that? Thanks
Re: startup problems
I've now got the beta-1 build and it works fine with the PostgreSQL driver, which I'm very happy about. Mosy things seem to be working fine, I've got my own ActionServlet extending the base one, overloaded the initDataSources() method so I can create my own database singleton objects for reference within each Action, to access the database. All is well. For now. I think what might be useful for me now is getting some time together to read all the new documentation again. Jim Richards wrote: > > >I'm sure earlier today when I started with the new version I didn't get the load >error, and > >something I've done has freaked it out. But as you'll see I haven't done that much >to > >freak it out.
Re: Stupd question about Struts and EJB.
EJBs come in two flavours (as opposed to flavors), session beans and entity beans. Session beans represent business logic and rules, entity beans represent a row in the database. The model that you'd use is to have Actions do the basic processing of form elements into data beans (just regular beans, nothing special), but no business rules. The Action then calls a session bean with the data bean to do something (eg. usdate user details in the database). The session bean connects to the database with an entity bean (or more than one depending on the database structure). Visually, you'd have JSP => Action => Session Bean=> Entity Bean => Database Hope that helps. At 06:37 AM 27/02/01 -0500, you wrote: > > I am in the process of convincing my company to go with MVC and Struts. As > with any thing new, people are sometimes resistant > to change. One of the opposition questions I am getting is, how will this > work with EJB(problem is I don't know too much about EJB currently). Do the > EJB's references just go in the Form and Action Bean and every thing else > behaves the same? Are there any obvious points that I can bring up on the > subject? > Any help on this subject would be much appreciated! > > Thanks, Cameron Ingram -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: job scheduler with struts
Depending on what you want to do, you could put your code into an action, fix it with a URL like http://localhost/thingy.do and then run a job that calls the page. If you're on UNIX get the Perl module LWP, which installs command line scripts, one called GET which will call a URL for you, so then your script line in cron would be GET http://localhost/thingy.do >> /tmp/thingy.log If you're on NT, although it should work I'm not sure. There is an implementation of "at" for NT in the NT resource kit. Otherwise you might have to look at other options. Just be aware if you do't secure the page, then anyone will be able to call it. Mihir Parekh wrote: > > We need to implement a job scheduler (similar to unix cron job). Is > there a open source schedule which can be used with struts? Any > pointers on implementing servlet based scheduler? > > Thanks, > Mihir
Re: more than one formclass for a one jsp ?
At 07:37 AM 23/02/01 -0500, you wrote: > > Hi, > > I wanted to have more than one form class for a one jsp file. Because in > my one jsp file, i have a information of 4 tables. So i want to transfer the > information to 4 formclasses? Is it possible? If what I think you are doing is wanting to have the four form classes handle all the data from a form in one go, no I don't think so. A form can only have one action attribute, so there's no way to split the data appart. You can have four forms within the jsp page, and each one has it's own action, but only one can be used at a time. You won't be able to submit to all four at once. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: database locks.. (OT)
The usual thing to check for are: Are you using the database conneciton pool? Are you closing your database connection? Do use you transactions at all? Do you commit your work? Do you have autocommit turned on? Anand Raman wrote: > I am trying to implement a multi page form and in some scenario the > application is hanging because of a database lock which is not going > away after some DML.
Re: Problem with installing Structs WAR files
Tomcat will unwrap the .war files for loading when running, and delete them when finished as a convenience. If you want to keep them you'll need to unjar them yourself first, with something like cd $TOMCAT_HOME/webapps mkdir struts-documentation cd struts-documentation jar xvf ../struts-documentation.war > I have copied the WAR files in the Struts < /webapps > directory to Tomcat >< webapps > directory (struts-blank.war, struts-documentation.war, >struts-example.war, struts-template.war, >struts-test.war, struts-upload.war) . I'm using Tomcat 4.0-b1 , and >jakarta-struts-20010218.tar.gz > > I have started Tomcat and the WAR files all are unpacked. I could open >http://localhost:8080/struts-example, >http://localhost:8080/struts-documentation,... But after I stopped Tomcat, >all the JSP files in struts-example/ , struts-documentation/,... were >deleted. What's wrong? Please help me! -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: Indexed bean property names and Javascript
One thing to try in your code is to reference the element as: form['someBean.somProperty'].value Laine Donlan wrote: > I was wondering if anyone has had experience using javascript with form > elements containing nested properties. Basically I am trying to avoid > looping through the forms elements and matching names to find the > element I want. However I am having a problem with javascript not > liking form elements names with "."'s in them. > > i.e. > A form generated by the text tag like the following: > > > cannot be accessed by javascript using the > form.someBean.someProperty.value. > > Has anyone had success doing anything like this, or am I missing > something all together? Thanks in advance.
Re: startup problems
>I'm sure earlier today when I started with the new version I didn't get the load >error, and >something I've done has freaked it out. But as you'll see I haven't done that much to >freak it out. I think I'm onto something now. I commented out the database connection code I had: And now it doesn't get the error. Which is really odd because the startup comment with Tomcat indicated it loaded without a problem. The database is running, and the postgresql driver is in the CLASSPATH of tomcat. New org.apache.struts.util.GenericDataSource Set org.apache.struts.util.GenericDataSource properties Call org.apache.struts.action.ActionServlet.addDataSource(org.apache.struts.action.DATA_SOURCE, GenericDataSource[activeCount=0, autoCommit=false, closed=false, description=Cyberlancers Data Source Configuration, driverClass=org.postgresql.Driver, loginTimeout=0, maxCount=10, minCount=1, password=grumpy, readOnly=false, url=jdbc:postgresql://dbase.home.cyber4.org/cyberlancers, useCount=0, user=grumpy]) Pop org.apache.struts.util.GenericDataSource The url and username/password works with the JDBC test that come with PostgreSQL 7.0.3 that I'm using, and other simple tests that I've done. You are the simulacrum of my dreams and the signifier of my desires Mr Grumpy ... come and visit his home! http://www.cyber4.org/members/grumpy/index.html
startup problems
I'm currently running Tomcat 3.2.1, Solaris7 and J2SE with JDK 1.3 and I have been getting this problem for a few days now. I've got the 2217 build installed. When I start Tomcat this is the log of messages I get (I commented out struts-example and documentation for this test). (The run script bounces the web server and does a run start of tomcat, rather then a start/stop). I'm sure earlier today when I started with the new version I didn't get the load error, and something I've done has freaked it out. But as you'll see I haven't done that much to freak it out. It seems to load everything without a problem, which is odd. As the messages indicate that the form beans and mappings are loaded without hitch. At the bottom is has cannot load servlet name: action When I run a simple jsp page, that references the formBean I get this error (the full stack is at the end) javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection at org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:686) at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:441) a test JSP page works (just loading the libs and doing output). It only seems to be with the forms and associated beans. Most of the configuration code is a copy from the example application, most of the mods I have done (eg. database servlet) I have commented out to try and get this to work. The .tld files are there as I can do things like and so on. I've checked package names, I've taken out nifty bits of code, I've checked classes are compiled and where they expect to be. I've checked file permissions My jsp form (which is an include) is this and my configuration parameters are: I'm stumped. Any help would be great. If you need more data then I'll include what I can. ## # Output of Tomcat 3.2.1 ## root@splat$ ./run.sh /usr/local/apache/bin/apachectl restart: httpd restarted Using classpath: :/usr/local/tomcat/lib/jaxp.jar:/usr/local/tomcat/lib/servlet.jar:/usr/local/tomcat/lib/parser.jar:/usr/local/tomcat/lib/webserver.jar:/usr/local/tomcat/lib/jasper.jar:/cyber4/lib/java2/postgresql.jar:/cyber4/lib/java2/jdbc2_0-stdext.jar:/usr/java/lib/tools.jar 2001-02-18 02:24:00 - Ctx( ): Set debug to 1 2001-02-18 02:24:00 - ContextManager: Adding context Ctx( cyberlancers.devel.home.cyber4.org: ) Starting tomcat. Check logs/tomcat.log for error messages 2001-02-18 02:24:00 - Ctx( cyberlancers.devel.home.cyber4.org: ): XmlReader - init /cyber4/projects/devel/cyberlancers/htdocs 2001-02-18 02:24:00 - Ctx( cyberlancers.devel.home.cyber4.org: ): Reading /cyber4/projects/devel/cyberlancers/htdocs/WEB-INF/web.xml 2001-02-18 02:24:03 - Ctx( cyberlancers.devel.home.cyber4.org: ): Loading -2147483646 jsp 2001-02-18 02:24:04 - Ctx( cyberlancers.devel.home.cyber4.org: ): Loading 2 action register('-//Apache Software Foundation//DTD Struts Configuration 1.0//EN', 'jar:file:/u02/cyber4/projects/devel/cyberlancers/htdocs/WEB-INF/lib/struts.jar!/org/apache/struts/resources/struts-config_1_0.dtd' resolveEntity('-//Apache Software Foundation//DTD Struts Configuration 1.0//EN', 'http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd') Resolving to alternate DTD 'jar:file:/u02/cyber4/projects/devel/cyberlancers/htdocs/WEB-INF/lib/struts.jar!/org/apache/struts/resources/struts-config_1_0.dtd' New org.apache.struts.util.GenericDataSource Set org.apache.struts.util.GenericDataSource properties Call org.apache.struts.action.ActionServlet.addDataSource(org.apache.struts.action.DATA_SOURCE, GenericDataSource[activeCount=0, autoCommit=false, closed=false, description=Cyberlancers Data Source Configuration, driverClass=org.postgresql.Driver, loginTimeout=0, maxCount=10, minCount=1, password=grumpy, readOnly=false, url=jdbc:postgresql://dbase.home.cyber4.org/cyberlancers, useCount=0, user=grumpy]) Pop org.apache.struts.util.GenericDataSource New org.apache.struts.action.ActionFormBean Set org.apache.struts.action.ActionFormBean properties Call org.apache.struts.action.ActionServlet.addFormBean(ActionFormBean[logonForm]) Pop org.apache.struts.action.ActionFormBean New org.apache.struts.action.ActionForward Set org.apache.struts.action.ActionForward properties Call org.apache.struts.action.ActionServlet.addForward(ActionForward[success]) Pop org.apache.struts.action.ActionForward New org.apache.struts.action.ActionMapping Set org.apache.struts.action.ActionMapping properties New org.apache.struts.action.ActionForward Set org.apache.struts.action.ActionForward properties Call org.apache.struts.action.ActionMapping.addForward(ActionForward[false]) Pop org.apache.struts.action.ActionForward Call org.apache.struts.action.ActionServlet.addMapping(ActionMapping[path=/logon, type=au
Re: Help with Exception
> > Sorry about not cutting out the previous messages, but the > > discussion is sort-of relevant to what I'm having problems with. > > I'm getting > > > > javax.servlet.ServletException: Cannot find ActionMappings or >ActionFormBeans collection > > > > I can run the example, and I can run a test page with nothing but > > a few tags (eg: ) but no forms/beans/etc. And I get the > > above error. I've checked struts-config.xml. > > > > I can only think I've missed something. > > > > Have you configured the controller servlet to be ? If you do not >do this, none of > the servlet context attributes created by the controller servlet (including the two >mentioned in the > exception) will have been created if the first request you submit is to a JSP page. > > If that's not the issue, what servlet container are you running on. Some have >problems with > load-on-startup -- check the installation documentation for platform specific >details. Yes, sorry. I'm using Tomcat 3.2.1 on Solaris, with J2SE 1.3. I have load-on-startup set to 1 (and my database container set to 2). I get an odd error when Tomcat starts in that it says (and this is from memory, don't have the extact message here) it can't load servlet: action. Now I assume this is the action servlet that is the struts one in the web.xml. But, it was a cut and paste job with modifications from the example web.xml, so I'd expect it to work. The servlet mapping seems correct.
Help with Exception
Sorry about not cuttng out the previous messages, but the discussion is sort-of relevant to what I'm having problems with. I'm getting javax.servlet.ServletException: Cannot find ActionMappings or ActionFormBeans collection I can run the example, and I can run a test page with nothing but a few tags (eg: ) but no forms/beans/etc. And I get the above error. I've checked struts-config.xml. I can only think I've missed something. and the jsp file (which is an include) has: At 10:16 AM 9/02/01 -0800, Craig R. McClanahan wrote: >Toby wrote: > >> The actions class in struts set the MAPPINGS_KEY to >> "org.apache.struts.action.MAPPINGS" along with a MESSAGES_KEY, LOCALE_KEY, >> FORWARDS_KEY and ERROR_KEY. I cannot find the "mappings.properties" file >> anywhere in the jakarta-tomcat or struts directories and assumed this is why I >> am getting this error message. Does anyone know where I could find these >> files? >> >Have you defined your ActionServlet instance to be in the >web.xml file? If you haven't, and then try to access a JSP page first, the >controller servlet will not have been initialized, and the context attributes it >needs will not have been created yet. > >Craig > > >> >> Toby wrote: >> >> > I am able to run the struts-test example and the hello-world example from >> > Bluestone, but nothing else. I will take a closer look at the >> > struts-config.xml file. >> > >> > Ted Husted wrote: >> > >> > > Are you able to run the Struts applications provided in the >> > > distribution? >> > > >> > > The action mappings are provided through the struts-config.xml in the >> > > application's WEB-INF folder. >> > > >> > > *** REPLY SEPARATOR *** >> > > >> > > On 2/5/2001 at 8:21 PM Toby wrote: >> > > >> > > >Hi, >> > > >I'm new to Tomcat and Struts. I can get the basic hello world struts >> > > > examples to run in my environment. But when I try something more >> > > > sophisticated, I receive the following error message concerning the >> > > > ActionMappings. I believe I have a Context Path problem, but am not >> > > > sure how to resolve it. Can anyone help? >> > > > >> > > > Error: 500 >> > > > Location: /struts-logon/logon.jsp >> > > > Internal Servlet Error: >> > > > >> > > > javax.servlet.ServletException: Cannot retrieve ActionMappings under >> > > >key >> > > > "org.apache.struts.action.MAPPINGS" >> > > > at > -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: AW: JDBC Connection Pooling
I'm trying to do the same thing here, but I'm not sure on a few of the details. I've got a servlet called DatabaseContainer, which will handle all the database connections and populating Beans to send back to the Actions. What I can't work out is, once I've get the DataSource, how does the Action know about the DatabaseContainer? At the moment I've got getServletContext().setAttribute("DatabaseContainer", this); and so in the Action, I can call DatabaseContainer database = (DatabaseContainer) servlet.getServletContext().getAttribute("DatabaseContainer"); But this doesn't seem right. Since Craig doesn't like singleton objects hanging around, and I don't feel like I want to extend ActionServlet, this seems like the only way (since getServlet() is depreciated in the 2.2 spec). Any ideas? >> The problem I'm facing is a bit diffrent as I want to access the >> Connection Pool from a servlet that is started upon startup >> of the servlet engine (similar to the struts example application). >> In order to be able to access the DataSource, I tried to subclass >> the ActionServlet class and to access the data source that way. >> However, my servlet engine (Tomcat 3.2.1) complains that it is unable >> to start this new Action servlet... >> >> Any ideas how to solve this problem? >> >There are three things you will need to do: > >* Make sure that both the Struts controller servlet and your own > servlet are marked . > >* Use values for the attribute that cause the > Struts controller servlet to be initialized first (for example, use a > "1" as the value for the controller servlet, and "2" for yours). > I'm not positive that Tomcat 3.2 respects this, but it is supposed to. > >* The Struts controller servlet makes the data source it initializes > available as a servlet context attribute, as well as available via a > method call. You can therefore grab it by calling: > >DataSource ds = (javax.sql.DataSource) > getServletContext().getAttribute(Action.DATA_SOURCE_KEY); > > in any other servlet (or JSP page) that is part of the same web app. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: Old questions that die hard
Ted Husted wrote: > Jim Richards wrote: > >The other thing I haven't found reference to yet is > >client side validation (but I also haven't looked that hard either) > > It's on the 1.1 TODO list. > > And, of course, we're glad that you've checked in again! I did notice that you had your name down for the client side validation. I'd be interested in your thoughts, and ideas because this is something I've done a lot of recently (not in Struts/JSP though) ...
Re: Old questions that die hard
Ted Husted wrote: > Jim Richards wrote: > >The other thing I haven't found reference to yet is > >client side validation (but I also haven't looked that hard either) > > It's on the 1.1 TODO list. > > And, of course, we're glad that you've checked in again! I did notice that you had your name down for the client side validation. I'd be interested in your thoughts, and ideas because this is something I've done a lot of recently (not in Struts/JSP though) ...
Old questions that die hard
I've been out of the Struts loop for a few weeks (or months, or years based on Internet time) and I am impressed that almost everything is ready for a 1.0 release, which means Craig's comments below still stand, re: Multipage forms and forms built dynamically. The other thing I haven't found reference to yet is client side validation (but I also haven't looked that hard either) I'll have to start digging deep again. Craig wrote: >My thinking on multi-page forms is definitely not totally finished yet, but my >operating assumption has been that you'd have separate actions for each page, so >you could therefore direct errors back to the individual pages. The logical >"grouping" of the actions could happen by subclassing a common base class that >represented the shared logic. You would declare the same form bean for all of >these actions, and you'd store this bean in session scope. (As a side benefit, >you can also use "next" and "previous" logical forward names directly, without >having to calculate which page you are on in sequence, and then know what the >next and previous logical names are.) > >It is still messy, because the validation method (at least) needs to know what >fields came from what pages, and there is no convenient way to communicate that >information so that it only needs to be specified once. I think that a final >solution to this is probably going to need to wait for a 1.1 time frame, when we >can figure out how to deal with it cleanly. I believe that the current approach >works quite well for single page forms (with the outstanding issue of people >that want to deal with dynamic sets of properties, rather than fixed ones, which >will need to be a separate extension if we decide to support it). -- Mary had a crypto key she kept it in escrow and everything that Mary said the Feds were sure to know.
Re: Data Validation
>Has anyone thought about adding data validation tags to the Struts taglibs? This came up quite some time ago. I have a requirement for this sort of thing, and posted a library with example for doing validation (not sure where it is now). It work on the client side in JavaScript and you specify the function you want to use for validation, and the message to display, it piles them all up and displays it in a window.alert() with all the errors, and jumps to the first field with the error. It mostly works as there are some freaky things with hidden fields it doesn't like.
Re: war files, and form action question
"Craig R. McClanahan" wrote: > Tomcat only knows how to auto-expand WAR files if you store them in the webapps >directory > -- not if they are elsewhere in your filesystem. I'll assume this is a feature. > Yes there has, compared to Struts 0.5 ... the validate() method now takes arguments. > I'm > going to add a deprecated validate() method to ActionForm.java so you will at least >get > warned about this. > > Note also that the parameters to the perform() method are different in 1.0 versus >0.5 as > well. I just added a deprecated perform() method to warn people about this one. Well, it worked in the build from a few weeks ago (a 1.0 model). I had read about the change in validate, but since I didn't get a warning on the compile I thought I was safe. Also the javadoc perform method signature matched my one. I thought it might have been something like the configuration.
war files, and form action question
I've got two questions, this is more to do with my tomcat configuration, but I can't get the documentation and exmaples to load as .war files, currently I have in tomcat.xml (renamed form server.xml) Context path="/struts-documentation" docBase="/cyber4/projects/devel/endonet/htdocs/struts-documentation" debug="0" reloadable="true" > this is also inside a tag. It works if I expand the .war file out under htdocs/struts-documentation, but otherwise not. How do I change the this to make it work? The other question is I had a test application that was working, but the the 6-Dec-2000 build it doesn't seem to call the form validate method anymore. Have there been any changes since the middle of November that missed by me on the configuration file or Action class? My struts-config.xml looks like (the important bits anyway) where MultipageAction and MultipageForm are the ralavant beans, the first page is page1.jsp and the follwing page is page2.jap then success.jsp -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
design question
As I understand it, is the basic design of struts generally to avoid any direct java code in the .jsp files, and do everything through tags? And although we can so things within <% %> tags, it is not preferred? Just wondering before I embark on my project, if it's worth including the design of any extra tags, or just doing the things I want in <% %> ... -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: EJB references
You probably need to create a helper class that does all this work, keeps the references as public variables and create it as a singleton in the init of the servlet, and store it as an application wide variable so you can access it easily and have references to all the session beans. I can't remember the deal though with synchronisation and EJBs, you had better check on that as there will be a high possibility of multiple threads (servlets) accessing it at the same time. At 08:37 AM 6/12/00 -0800, you wrote: >Hi Jim and Alex, > >I think both of you understood me wrong. I am not planning to access EJBs >from JSP pages at all. I will have a lot of session EJBs to manipulate >Entity EJBs. But, the suggested approach accessing them from servlets was: [snip ...] -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: Article on JavaWorld
If you're prepared to be patient, I need both of these, and can work on them but I won't be able to start unitl January on the development of it. The AutoBean idea (as an idea) is something I use already in Cold Fusion, and have done before in PL/SQL. The client side validator, as I posted before I have a good JavaScript validation library I can use, and am happy for it to be included. "Craig R. McClanahan" wrote: > The "AutoBean" concept has been requested several times, often in the guise of > "beans with dynamic properties" so that you don't have to create a form bean > with individual getters and setters. I'd like to explore this concept in depth > in Struts 1.1, which will give us time to make sure that a complete and coherent > set of support for such beans can be included (for example, all the custom tags > that know how to extract bean properties should now how to extract them from an > AutoBean, without the page developer having to do anything). > > The "Validator" concept is interesting. Besides the server-side format checking > that is being done here, I would also like to see the option for the form tags > to generate client-side JavaScript code (if requested) to check as many things > like this as you can on the client side, to improve the user experience.
Re: Nesting form inside ifParameterEquals
You can use java script. I posted a message about this to the struts-dev mailing list a few days ago. I don't have the email, but you can find it in the mail archives, which I don't have a reference for either. > Nikolaus Rumm wrote: > > Hello, > > what I wanted to do is... > > >type="com.kephera.scivent.client.participant.UserForm"> > > >type="com.kephera.scivent.client.participant.UserForm"> > > > However, under struts 0.5 the tag's body and thus the form tag is not evaluated, but >the whole page is skipped. Is there a way to dynamically alter the action of a >struts:form tag ? > > Regards > > Nikolaus
Re: Question about errors tag
[big snip ...] > Is there another way to accomplish the same thing, without tacking the error > on to the redirect URL? Probably not, no. I can't see where you'd store the errors. In the session would cause problems with synchronisation, and on the redirect URL could cause buffer problems (with more then 1024 bytes of errors). You could store it in the session, if you used a unique identifier to store them, and pass that identifier through to the redirected URL. I'd think you need to look at *why* you don't want the action URL displayed in the first place. You could always be sneaky and use a hidden frame to force the URL to always be the same.
Re: EJB references
I'll be using ELB's for my application when I start building it in a few weeks time (still in the design stage). I expect to be using only EJBs from a action servlet, that are session beans, and those session beans use entity beans. From previous work I found there was too much overhead using the entity beans directly in the generation of a html page, and you rarely needed that direct conncetion to the database anyway. As for the references, I'm not sure what you mean. I'll be putting things like the JNDI and connection information into to web.xml as startup parameters. "Boulatian, Misak" wrote: > > Hi all, > > The application we design is quite large. I am still trying to figure out > the question on EJB references. From the Craig Mcc.'s comment I could put > those in one startup servlet. Is it a viable solution? I am going to have > many session references. Where am I going to store those references (in > servlet context)? How can I make those available to action classes? Or I can > put only the handle in the servlet context and call lookup in every action > class (any scalability problems with this approach?). I cannot believe that > none of you worked in large applications and will not be using EJBs for > business logic and did not go over this kind of issue. > > I appreciate response, > Misak Boulatian
Re: Submitting forms to alternate actions
With JavaScript you can specify the form action, so you'd have something like: You can also mess around with the form onSubmit action, but I was having trouble trying to determine which button was clicked through that method. This seemed a lot cleaner. Steven Peterson wrote: > > Hi all: > > I have used struts to set up a simple application. My problem comes up > when I want to submit a form to different actions, depending on which > button the user presses. If the contents of the form were not > important, I could simply GET a different URL (each mapped to a > different action) for each button. However, when I need the contents of > the form so that the form must be POSTed, then I am stuck -- as far as > I can tell, there is only one url that a form can be posted to. Is > there a way to override the form's coded post action based on which > button is pressed? > > - Steve > > -- > Steven Peterson, President > Frontier Productions, Inc. > 310 Wesley Drive > Chapel Hill, NC 27516 > http://www.frontierproductions.net > Tel: 919-942-1386 > Fax: 919-933-2677
Re: book ideas
I'd prefer (and this is personal preference only) more on the development of models and application frameworks then actual introduction code. Coverage of PostgreSQL as well (it has transaction, which are quite crucial to the EJBs, otherwise you get MySQL's serialised table locking which is not great). Use of EJBs through the MVC framework. Where to use session beans (both types) and when to use entity beans (ie. should entity beans be attached to the session object (no, not really) but only accessed through the session beans, and the session beans return ordinary Java Beans to the servlet. Security context in relation to attaching a profile to the whole application. Not a reprint of the documentation that comes with any of the main downloads, as this just duplicates content and kills more trees. Other EJB/J2EE containers (eg. Enhydra/Jonas). Wait till Tomcat 4.0 is stable and Struts 1.0, otherwise you'll have major dead space in the book. (Although a paper book will always be somewhat out of date) If you focus on frameworks/ideas/concepts rather then deep examples you'll find the book lasts a lot longer, which is why Knuth's books are still valid resources today but my Java 1.0 Beta2 books are wasted space. At 10:59 AM 30/11/00 +0100, you wrote: >Hi Everybody, > >I'm (already) working in a book in JSP and Tag Libraries development for New >Riders Publishing. >The idea of the book is: > >- An introduction on Servlets and JSP >- Deep in Tag coding >- Design and Architectural issues (major challenges when designing web apps >with Servlets, JSP, Pet Shop Model 2 approach, Struts Model 2 approach, the >role of tags in process encapsulation and reuse, how tags affect system >design and how the Servlet/JSP architecture responds to that, etc.). EJBs >are treated as subsidiary (calm down!) since it's too broad a subject and >very well covered in many other books. >- Deep in Struts (a couple of chapters to discuss the model, the usage >scenarios and of course the taglibs) >- Jakarta Taglibs (a broad coverage) >- Commercial taglibs (the commercial case) >- Appendixes on TOMCAT (I focus in TOMCAT), MySQL, Caucho Resin and Jrun >(examples are provided also on these), jBoss >- Many, many, MANY examples on everything. > >Questions are: > >1. What do you think of this coverage ? > >2. What would you like to see on paper ? My sources on the design issues are >a number of articles (for instance that one from Jason Hunter questioning >JSP), some reference books and the lists (not to mention experience, of >course). > >3. On the side of Struts, what do you like to see there ? What do you think >is not yet said or well said about Struts ? > >4. And on the design issues on Servlet/JSP architecture(s) ? > >Thank you all for your attention on this, > >Wellington Silva >UN/FAO > > > > -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: HttpSession.getAttribute() missing?
Then you've got the wrong .jar file in your classpath, or earlier in your classpath. You can either edit your CLASSPATH environment variable setting, or remove the offending .jar file from your system. You'll then need to include the correct .jar file (depends on your server setup) that includes the latest classes. What server are you using? > The HttpSession it's going after is in the Jswdk version 1.0.1.Could it mean >putValue() instead?
Re: How to make ActionForm handle extended properties
> Currently, every form field has to have equivalent field in ActionForm bean, > with both getter and setter method. This requires that a new ActionForm be > generated for each new Struts form (with additional fields). > > Our applicaiton requires 'extensibility', ie. HTML/JSP designer should be > able to add new fields to the form without breaking serverside Java code, > including Struts. > > I've made some minor changes to Struts 0.5 to achieve such extensibility. > Basically, it use a Hashtable to save and retrieve extra fields that do not > appear in the ActionForm. This is something I really need. I have my user profile fields generated from a database template table, so that it might contain data for a "First Name", "Last Name", "Address 1", "Address 2". TO make it reusable the next application might use "Full Name" and the application knows how to read the template table and display the correct type of text field and JavaScript validation function. I thought using String[] getXXX and setXXX(String[]) methods might have worked, but didn't.
Re: need some explanations
It's really only for an example. It you want real object persistence, you'll need to develop your owne layer. Something like EJB's will make this much, much easier. Or some direct JDBC code perhaps. Vilavanh Messien wrote: > > I analyzed the struts example in order to develop my own small application. > Unfortunatelaty, I don't really understand how the user's information are > saved > in the "database.xml" file. > The DatabaseServlet must write the information in the "database.xml" when > the destroy() method > is called. > My question is how to make the destroy() method perform ? > > How can I do to pass some arguments to the DatabaseServlet ? > > Thanks > > Vilavanh
Re: Chaining controllers and passing parameters
> One of the ideas I've been thinking about (for a Struts 1.1 timeframe) is to > support a more "workflow" oriented mechanism for defining actions. The thought > would be that an application developer would decompose the business functions of > the application into discrete "tasks", and then glue them together with > "scripts" defined in the struts config file. Struts could then include a > standard Action that executes the script -- the net effect would be to reduce > (or possibly eliminate) the need to write Action classes yourself. In such an > environment, chaining functions together would become as simple as writing the > appropriate tasks into a config file. > > Does this sound like an interesting direction to pursue? I'd actually -1 on that. although I don't know how loud my voice would be. The reasons would be that it'd create another layer, a scripting language that we'd define. It'd make it harder for new people to learn and cause bloat in the framework. At the moment, it's a lightweight yet still extendible framework that allows for the customisation we might need. We'd then need to work to make it a fully featured XML/etc based language, that yes would be useful, but I don't think should be done. Instead, we could create the tasks, but still allow the Action class to define which class is called and how, with our defined arguments. But wouldn't this clash with business oriented session EJBs, which should supply this function?
Re: Anybody have Dreamweaver definitions for struts?
>Just wondering if any of you have created Dreamweaver extension files or >property inspectors for the struts tags. Just make sure you use the lastest nightly build as the structure of the tag files has been split into 4 files, for form, bean, template and logic, which each have their own XML namespace. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: thought on design
> The server-side enhancement is that the validate() method is now called with the >request and > the current mapping so that you have more context for making your validation >decisions -- > for example, you can go retrieve the user's session and get state information you've >stored > there. Oh, I thought that was there from v0.5. That'd make sense. > Support for auto-generating client side validation JavaScript is not there, and is >unlikely > to be in the final 1.0 release. Well, perhaps I should to learn how the tags are built so I can start doing this then. I have an itch. I had a look at them, they don't seem too hard. > I agree with using client-side validation where you can, to improve the UI by >catching > errors earlier. My caution is that you should plan on re-performing these checks as > appropriate on the server side. Don't assume that your JavaScript validation >actually took > place. Oh, not at all. But different people prefer different things for their validation. Server side validation should be for things like, "does the user exist?" where as client should be, "is a user name entered?" It's a balance and trade between the two. We need to work out a good way of doing this. I don't want to see struts become too bloated with functionality. > This would worsen performance (handling exceptions is not particularly cheap) versus >the > current approach. > > Also, there are also many sorts of error checks that depend on more than one field >("field B > is required if field A is present, otherwise it must be blank"). The HTTP and >servlet specs > provide no guarantees on what order the request parameters are presented, so where >do you > put the checks for this? In many cases, you are going to need a global validate() >method of > some sort anyway. Um, yes. Good point. I didn't think of that. I'll try and get my JavaScript validation library together, clean it up and put it on my web site (which needs a good clean up anyway). And then write some stuff about how we could look at a client side validation, that works with a server side one.
Re: thought on design
> In 1.0, the validation model for the server side has been significantly enhanced. >The > idea of auto-generating JavaScript validation code for the things you can check on >the > client side is attractive, but won't make Struts 1.0 (unless someone really hurries > and creates it :-). Hmm ... I am using a nightly build from about a week ago, I'll have to dig into it to see how this enhanced validation works (or is it not in there yet). > I would caution you that, even if you implement client-side JavaScript validations, > your server side logic should not rely on them. After all, the user can easily turn > off JavaScript, and/or write an application that simulates a browser's interactions > with the server but tries to bypass your edits. The client side validation is only for simple things, that validate() would do, such as checking for number format, empty strings, valida credit card number, post code and so on. The action bean would still need to check that, say a credit card was valid (rather then just a number). >> Also, I couldn't work out how to get the request attributes >> to be sticky between the next and previous pages (think CGI.pm >> and it's param() functions). It's probably something to do >> with the response, but I don't have the docs handy. >> > > Sticky checkboxes have been fixed in 1.0 by adding a reset() method to the ActionForm > class. You should reset any boolean properties to false in the reset() method, which > is called before the property populator -- which will set the checkbox back to true >if > it was indeed checked. Hmm, I was thinking more about text fields and so on between multipage forms, not rebuilding the current form with the previous data. > I will take a look at your example, but there is a subtle philosophical issue that >has > affected the way ActionForm beans are specified in Struts. > > Basically, an ActionForm is part of the presentation layer, not the model layer. > Their primary purpose is to encapsulate the current set of inputs that a user last > entered -- whether or not they are valid -- so that you can create an error page that > faithfully represents what *was* entered, and points out what needs to be changed > (just like GUI apps do). Otherwise, you're going to force the user to have to > re-enter some of the fields, and that will not make you a popular person with your > user community. I suppose what I'd like is rather then having validate() being called, when each property has it's setXXX method called, the setXXX method does the simple validation, and throws a ProperyVetoException with the error message text as part of the Exception. Then if a try block cathces this, stacks up the error messages and calls the page again with these errors. It seems that from what I've seen, most validate() methods are the same.
Re: thought on design
Duffey, Kevin wrote: > I actually do a different design for validating forms. I place a hidden > field before each field I want validated, with a name of validate and a > value of RegExp names that determine the type of validation to be done. In > the JS, I loop through all elements, and if the type==hidden and > name==validate, I get the value, tokenize it into , separated items, then [snip ...] Yeah, that works. I was thinking about the Regular expression but that's only supported in JavaScript1.2 and I usually have a requirement of earlier browsers. My code also allows for generic validation functions (what if you need a "," in your validation RegExp?). Although regular expressions can do a lot, they can't do everything. Having hidden fields can cause problems at the server side depending on the technology you use. Since JSP and Servlets are flexible in the parameters, it's a horses for courses. But for both of us, the validate seems to be the wrong thing.
Re: Struts + Design Philosophy
> users. What I am asking is, will STRUTS gracefully support a 2 stage > approach to forms - 1 stage to construct and fill in values, and a second > one to gather responses and process ? This is something I am looking at, have a look at the simple JavaScript validation page I posted yesterday (well, yesterday my time). I think we can improve on the ActionForm.validate() style of doing things.
thought on design
Having had a look at struts for few weeks now, I have some thoughts based on other work I've done and what I'd like to see/do implemented. Just to start with, I do like it. It'll make development cleaner and easier. I would have done something similar based on Cold Fusion's fusebox model probably. The validation method in ActionForm.validate seems to me to being too simple. I'm used to JavaScript validation that is fairly similar (see attached html file). I do notice that there is some mention of this in the TODO list. The main problem I see so far with validate is how it will work for mulitpage forms. The only way I can see that it'd work is by having a hidden field (or form submit value that would specify the page number and an if statement in the validate method that would check just the required values. This would tie the validate too closely to the HTML page. If you look at the example I've attached, you'll see that there are references to the pages in MultipageForm and MultipageAction, as well as validation that is tied to the pages. (The code could be cleaner, eg. more messages from the .properties file, better error checking, and cleaning out unused beans, formatting of the code ;-) I could write the code so it checks that a parameter is specified, but this will cause problems with check boxes and multiple select. Also, I couldn't work out how to get the request attributes to be sticky between the next and previous pages (think CGI.pm and it's param() functions). It's probably something to do with the response, but I don't have the docs handy. What I'd like to see is better use of the Bean style, where we use PropertyVetoException and similar. It does mean writing a more stubborn bean container. But it'll be useful when it comes to using Beans developed for instant graphical interfaces. Since all my work has been back end work, I've only just got into Beans now after a long time in Servlets, EJB and Java 1.0 AWT programming. Have fun ... Title: Form Validation Not required/not validated phone number: Not required/validated: Text field: 4 digit number (credit crad/postcode) Phone number: Email: Credit Month: Credit Year: multipage.tar.gz -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: Pages being cached
(This has been cross posted to tomcat-user, as it seems to be a tomcat issue rather then a struts issue.) I have found that this behaviour is *not* replicated when using Tomcat's built in HTTP server. I need to do some deep experimentation, and install tomcat-3.2b8 as well. I'll let you all know how it goes. >>> I'm getting weird behaviour with my struts code, and with the example >>> application. > >>Once during testing I noticed that pages seemed to be served at random.. >>Then I shut down httpd and then shut down tomcat. >>Thereafter I restarted tomcat and then restarted htttpd. >>Then everything worked. >> >>So I've concluded that when I want to restart tomcat, I've to >>first stop httpd, then tomcat, then start tomcat and then start httpd. >> >>I'm not sure if I should restart tomcat when I just want to restart httpd. > >I have to restart Tomcat and Apache to get anything to work. It doesn't >help. Once my application has compiled the three pages it has in it, >(that is viewed them) it starts freaking out. Going through the documentation >doesn't seem a problem, so long as that's all I do. It happens with the >example application, with everything. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Re: Pages being cached
>> I'm getting weird behaviour with my struts code, and with the example >> application. >Once during testing I noticed that pages seemed to be served at random.. >Then I shut down httpd and then shut down tomcat. >Thereafter I restarted tomcat and then restarted htttpd. >Then everything worked. > >So I've concluded that when I want to restart tomcat, I've to >first stop httpd, then tomcat, then start tomcat and then start httpd. > >I'm not sure if I should restart tomcat when I just want to restart httpd. I have to restart Tomcat and Apache to get anything to work. It doesn't help. Once my application has compiled the three pages it has in it, (that is viewed them) it starts freaking out. Going through the documentation doesn't seem a problem, so long as that's all I do. It happens with the example application, with everything. -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Pages being cached
I'm getting weird behaviour with my struts code, and with the example application. Currently I've got Tomcat 3.2b6 running, with the latest nightly build of struts (17-11-2000, that's the 17th November, 2000) and the examples, documentation and test data all run. (Which I must say, took a very long time to get a configuration other then a standard install right.) JDK 1.3, Solaris7 ... all the latest patches. (On a side note, I don't think tomcat loads .war files unless then are in the $TOMCAT/webapps directory and the AutoLoad interceptor is turned on.) I have virtual hosts set up, and contexts usually set as something sensible (usually /context). I've got Apache web server and mod_jk. I've found that after loading about 2 or 3 pages from the example, or my own (three page) application, pages start coming out of order, just by clicking on links or submitting forms. The weirdest behaviour is when I might be viewing the documentation on one virtual host and context, and a page from my example application (on a different virtual host and context) will appear in its place. Or the example application will appear instead of my application. It's not the browser because I have the cache set to zero, and for it to compare the document on the network to local every time. Anyone seen similar? -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html
Application frameworks
(sorry if you've already got this from another list, I'm trying to canvas as many ideas as I can) I've been looking at several application frameworks over the last few days, and was wondering what people were using? In general I'd like to have my servlet generate XML output (perhaps using ECS?) that is picked up by an XSLT engine (perhaps Cocoon?) for display to the user to keep the content apart from the system. So far I've come across Turbine Quite well developed but requires a large amount of initial knowledge to get your head around (although that's *my* opinion). I understand the model, but I want to use EJB for the database connectivity, and Cocoon for front end processing which AFAIK has not been integrated fully yet (unless the docs haven't been updated). Enhydra A full enterprise application environment. Also has the same problem as Turbine; large system with lots of work done on it. It uses a process where your HTML pages use tags that are replaced by the content. Which doesn't seem as flexible as I want. (Although there is a good separation between business/display/database.) Struts A smaller project, designed with news models in mind. Although not fully developed I don't know if Cocoon XML transformation will work with it. Any ideas? thanks ... -- Kumera - a new Open Source Content Management System for small to medium web sites written in Perl and using XML http://www.cyber4.org/kumera/index.html