Re: struts-template tag library vs. jsp:include/
Thank you for your reply, but this didn't really answer my question. Let me rephrase. I am talking about jsp:include/, which is a dynamic templating mechanism, as opposed to %@ include %, which is static. As I understand it: jsp:include/ and struts-template:*/ are both dynamic templating mechanisms -- they are re-evaluated at runtime whenever referenced. They allow you to create a template with placeholders for dynamic values which you will supply at runtime. This is where they are similar. What I'm interested in hearing is how they differ. I assume that struts-template offers some improvement over jsp:include, otherwise it serves no purpose. So my question is, what does struts-template offer as an improvement over jsp:include? The answer may be as simple as "it provides a consistent and readable syntax", or it may be more substantial. Thank you, Jim Newsham Robert Taylor wrote: Although it doesn't discuss struts template tag specifically, the J2EE BluePrint has a good section on the comparison of JSP includes and using templates. I believe it is in section 10.3 where it discuss the Sample Application: View. http://java.sun.com/j2ee/blueprints/sample_application/view/index.html HTH, Robert -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Jim Newsham Sent: Friday, March 16, 2001 9:20 PM To: [EMAIL PROTECTED] Subject: struts-template tag library vs. jsp:include/ Hi, What are the differences between using the struts template tag library and jsp's include action? What are the advantages and trade-offs of each? Thanks, Jim Newsham
struts-template tag library vs. jsp:include/
Hi, What are the differences between using the struts template tag library and jsp's include action? What are the advantages and trade-offs of each? Thanks, Jim Newsham
Re: logic:iterate and form controls, revisited
Brian Knorr wrote: Jim, Hi... could you show me a small example of how you got this to work with the html:text tags... I can only get it to work with the way Eric Wu describes below. Do you know if this will problem is going to be fixed anytime soon? Thanks. --Brian I'll second this. Using a recent version of struts, I have been able to use nested/indexed properties in the jsp page to put a variable number of fields in the form, without patching BeanUtils (points c and d). I still find it necessary to programmatically construct the field name (point b), but there is nothing stopping you from using the html:text tags (and others) (point a), which make things a little easier/cleaner since the tags will automatically populate your fields from the Form object. Jim Newsham Eric Wu wrote: I have found that with the latest builds the support for nested and indexed properties seem to eliminate the need to patch BeanUtils as described in points c) and d) below. However, it seems that the html:text tag still cannot be used as it is not able to generate the required indexed values for the name= and value= parameters. So you are left with coding the text fields using the HTML form tags and scriptlets. It is not the cleanest approach but at least with the current builds, you don't need to worry about patching BeanUtils and wondering if it will break the build... I agree that this should be given a fairly high priority for 1.1. Eric Wu Java Architect www.GlobalMedic.com Tel.: 514.738.6770 / 1.888.986.3342 Fax.: 514.738.4827 Silver WWW Health Awards Winner Globe Mail Top 25 e-Businesses in Canada - #5 http://www.globetechnology.com/site/specials/e-25/ http://www.globetechnology.com/site/specials/e-25/ Visit www.medalliance.ca, GlobalMedic's new healthcare network for physicians, pharmacists, patients and consumers, developed in collaboration with Les ditions Sant Rogers Media. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] ] Sent: January 24, 2001 2:50 AM To: [EMAIL PROTECTED] Subject: logic:iterate and form controls, revisited Hi all, I recently ran in to a need to perform a task that's been discussed on this list at least a couple of times since I've subscribed. Unfortunately, an actual way to make it work was only described once, and that approach was unappealing. The problem is that I would like to construct a JSP with an HTML FORM that has a series of similar lines, using logic:iterate. The fundamental problem is that the various struts-form tags use the same name for all instances of a control in a given "column". This means that struts can't automatically shove the posted data back into the form bean for you (at least correctly!). The one approach to solving this that I saw (over the last two months or so) was by Chandan Kulkarni. If you want to go back and check it out, here are the headers: Date: Fri, 5 Jan 2001 07:44:11 -0500 To: [EMAIL PROTECTED], "Mishkin Berteig" [EMAIL PROTECTED] From: "Chandan Kulkarni" [EMAIL PROTECTED] Cc: "Chandan Kulkarni" [EMAIL PROTECTED] Subject: Re: Help: logic:iterate and form input fields Message-ID: 002f01c07715$3520bb50$[EMAIL PROTECTED] http://www.mail-archive.com/struts-user@jakarta.apache.org/msg01651.htm l This approach involves: (a) using raw HTML form tags, e.g., input instead of form:text. (b) constructing the value of the "name" and "value" attributes for the HTML form tags using JSP expression substitution - %= %. (c) Changing public static void populate(Objec
Re: struts generating progress messages
Kitching Simon wrote: Hi, I currently have a model-1 web application ie in which the .jsp pages are responsible for invoking the business logic. I am planning to move the webapp to struts, for all the obvious and traditional reasons. However, there is one nice feature of the current code that I can't see how to perform inside an MVC framework like struts: On submitting a particular form, there is a sequence of 4 operations to perform, each of which takes somewhere between 5 and 30 seconds to perform. Currently, what is done is to generate an almost complete HTML page, and force it to be flushed to the browser; as each long-duration step starts and completes, a fragment of page containing CSS-positioned html/ javascript is flushed to the browser. The effect is very nice - a list of the steps appears on the screen, an hourglass appears next to each step as it starts, and a tick or error message appears next to each one as it completes. Does anyone have any idea how to generate the same sort of effect (essentially alternating between business logic and presentation output) in struts? Thanks in advance, Simon How about creating a separate thread to perform the tasks, and forwarding immediately to the jsp page in your main thread. Create an object which can wait for the tasks to complete, and attach that object to the request before forwarding. As an example, create a TaskMonitor (sample code below; this code is untested, and I usually don't program threads so don't trust it to work without some scrutiny). Task thread. Create a thread to perform your tasks and give it a reference to this monitor. Each time a task is complete, call monitor.taskComplete(taskid). Main thread. Attach monitor to request. Forward to jsp. The jsp can call monitor.waitForTask(taskid) for each task in sequence. public class TaskMonitor { boolean[] taskComplete; public TaskMonitor(int taskCount) { taskComplete = new boolean[taskCount]; } public synchronized waitForTask(int taskid) { if (taskid 0 || taskid = taskComplete.length || taskComplete[taskid]) return; while(true) { try { wait(); } catch(InterruptedException ie) { } if (taskComplete[taskid]) return; } } public synchronized taskComplete(int taskid) { if (taskid 0 taskid taskComplete.length) { taskComplete[taskid] = true; notifyAll(); } } }
Re: if/elseif tag?
The "struts-logic" library includes quite a few variations of an "if" tag that can perform different sorts of conditional checks for you. At the moment, however, there is nothing that provides the "else" or "elseif" construct. This is mostly because I've yet to see a syntax for this that is: * consistent with the XML syntax required by JSP custom tags * easily understood by page authors * not butt-ugly to look at or to type I'm open to suggestions for a solution to these issues. Mike Campbellemail: [EMAIL PROTECTED] Craig I'm not too familiar with custom tag writing, so I don't know how technically feasible this is, but... how about a "cond" tag (similar to lisp's cond), whose body can contain multiple "test" tags. The first test which evaluates to true is allowed to render its body, and then further processing is inhibited. This would have the effect of "if, else if, else if ...". logic:cond logic:equal name="name" property="property" value="A"The value is A/logic:equal logic:equal name="name" property="property" value="B"The value is B/logic:equal logic:equal name="name" property="property" value="C"The value is C/logic:equal logic:trueAn unexpected value?/logic:true /logic:cond ... which should be equivalent to ... if (name.getProperty().equals("A")) { out.write("The value is A"); } else if (name.getProperty().equals("B")) { out.write("The value is B"); } else if (name.getProperty().equals("C")) { out.write("The value is C"); } else if (true) { out.write("An unexpected value?"); } Jim N.
Re: nested and indexed properties in 1.0?
Matthias Kerkhoff wrote: Is 1.0 going to have full support for nested and indexed properties? I have y forms which use property names such as "apples[2].oranges[3]" and I would really appreciate it if this was supported in 1.0. It's a simple change to support this since PropertyUtils already does it. All that needs to be done Its indeed a simple change. I'm also running a modified version of struts capable to use nested and indexed properties. I would too like this feature to be incorparated into struts. Is anyone who has implemented this modification willing to share? I need this feature yesterday, and am hoping I don't have to wait until Struts 1.0 final or (gasp) Struts 1.1. Thanks in advance, Jim Newsham
using tags within tag parameter field ?
I apologize as this is a generic jsp question and not specific to struts, but hopefully this is a simple one (at least, I give a struts example below). Is it possible to use a tag as an rtexprvalue within another tag's parameter field? For example (assuming 'mytag' can take a rtexprvalue for parameter 'param'): tag:mytag param="tag:anothertag param=\"hello\"/"/ As a struts example, here are two versions to show a dynamic list of simple menu items (there's a java.util.Collection attribute named "menu" attached to the request; it's a collection of beans with properties 'href' and 'text'), which differ only on the second line. The first version is quite ugly but works. The second version is what I'd like to use, but this doesn't work -- causes a compile exception. I'm assuming the answer to my question is "no", but does this mean I'm stuck with version 1, or is there a better way? ver 1: logic:iterate id="menuitem" collection="%=request.getAttribute(\"menu\")%" form:link href="%=((com.hotu.intra.MenuItem) pageContext.getAttribute(\"menuitem\")).getHref()%" bean:write name="menuitem" property="text"/ /form:link br /logic:iterate ver 2: logic:iterate id="menuitem" collection="%=request.getAttribute(\"menu\")%" form:link href="bean:write name=\"menuitem\" property=\"href\"/" bean:write name="menuitem" property="text"/ /form:link br /logic:iterate compile exception: /home/newsham/work/intranet/main.jsp:30: ')' expected. _jspTag3.setHref("bean:write name="menuitem" property="href"/"); ^ 1 error com.caucho.java.JavaCompileException: /home/newsham/work/intranet/main.jsp:30: ')' expected. _jspTag3.setHref("bean:write name="menuitem" property="href"/"); ^ 1 error Thanks, Jim Newsham