Re: How can one servlet (ActionServlet) effect another servlet (AxisServlet)...?
On 6/6/07, Dave Newton [EMAIL PROTECTED] wrote: --- Jeff Amiel [EMAIL PROTECTED] wrote: Does this sound possible? According to the source, it's not only possible, it *is*... at least w/ TC6. You could just check the source of the TC version you're running and see if it's the same way or not. Any further insight would be appreciated. Speaking as the original author of this part of Tomcat in 4.1 and 5.0 (and it hasn't changed that much in 5.5 and 6.0 AFAICT), request and response instances can indeed be pooled and reused for *different* requests. That being said, Tomcat has been pretty rigorously tested for thread safety by virtue of the fact that tens of thousands of applications (many very high volume) are running on it. It is *substantially* more likely that there are thread safety issues in user code (such as simultaneous access to session scoped or application scoped beans), rather than a bug in Tomcat, when you see intermittent issues like this. Craig McClanahan Probably want to follow that one up w/ the TC folks. d. Got a little couch potato? Check out fun summer activities for kids. http://search.yahoo.com/search?fr=oni_on_mailp=summer+activities+for+kidscs=bz - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How can one servlet (ActionServlet) effect another servlet (AxisServlet)...?
On 6/6/07, Jeff Amiel [EMAIL PROTECTED] wrote: I'm not debating that there could be bad user code here(although I've reduced my test cases down to an empty axis service call and an nearly empty struts actionIf there IS bad code, it's probably at a low level inside axis or struts or some other library that I don't have immediate control over) What I'm trying to determine if the re-use of response instances could be the reason why the axis servlet is getting a response given to it that is already in a committed state... I'm not 'afraid' of dealing with pooled objects that may be in a questionable state (like with database connection pool handles...knowing to check/set auto-commit on them when acquiring them from pool because the previous user may have changed some settings on them)...I'm just interested in knowing if this is a 'known' danger of running without a security manager on Tomcat (5.5) and just as easily avoidable. I'm just trying to warn you that the evidence of the last 5 or so years (given how many people deploy apps on Tomcat) means you are going to get a lot of skepticism if you go to the Tomcat user list and try to blame this kind of problem on Tomcat. The likelihood of that being the real issue, given the fact that even *you* can't reproduce it reliably, and the fact that nothing changed in your environment, makes this the least possible likelihood. Note that probably 99.9% of the apps running under Tomcat standalone run without a security manager -- but that is even *more* unlikely to be the issue. Of moderate possibility is that one of the frameworks you are using (Struts or Axis) is at fault. Again, the odds are against you -- but not quite as much as that it's a Tomcat issue. On the other side of the coin: * Each of these two frameworks has been deployed widely -- on Tomcat and on other servers -- without a large number of complaints of this sort of issue. * The symptoms you describe are the classic scenario where a previously existing application level thread safety issue has already existed, but didn't surface until the usage pattern of the app itself changed. Note that I'm not at all familiar with the Axis code base, and have never deployed an app that used Axis (with or without Struts). But, given the fact that the exception is in fact coming from Axis, my suggestion is: * Look to your own code first -- in particular at the logic of the Struts action you claim is being executed at the same time as a SOAP call to the Axis servlet. * Ask on the Axis list if anyone has seen this, including the full stack trace so that proper diagnosis is possible. It's not impossible that there is a threading problem in Struts or Tomcat that is causing this. But, in my years of experience, my gut says that is probably not where the issue actually exists. Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: MVC1 -Frame Based JSP Application to Tiles
On 5/24/07, Raghuveer [EMAIL PROTECTED] wrote: I Have a JSP web application using MVC1 framework. It uses Farmes(one left for navigational links and other right with tabs on top.) From tiles documentation i understand i can use tiles with out struts ? So i was thinking the possibility and feasibilty of using tiles for my current application. Any Comments? The most recent version of Tiles 2 can indeed be used without Struts or any other framework (although both Shale and Struts 2 offer integrations with this code as part of their own frameworks) -- and it has also graduated into its own top level Apache project. Go to tiles.apache.org for more information, including links to separate mailing lists focused specifically on Tiles. Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Handling requests through servlets vs struts action class ?
On 5/18/07, jasdeep [EMAIL PROTECTED] wrote: But then i thought it may have serious performance penalty as struts action is using single thread model (AFAIK). This is not a correct assumption. In Struts 1, there is a single *instance* of each Action, but it can be processing multiple requests (on multiple threads) at once. Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: HELP!!
On 4/30/07, nagesh.kumar [EMAIL PROTECTED] wrote: taglib-uri/WEB-INF/tlds/struts-html.tld /taglib-uri Please remove blank space after .tld in the above line it should be like taglib-uri/WEB-INF/tlds/struts-html.tld/taglib-uri The following advice presumes that you are using Struts 1.1 or later, on a Servlet 2.4 or later servlet container (such as Tomcat 5.x or 6.x). If you are not, you really should. There are three important things to note here: * The suggestion from Nagesh is likely to have no impact, because the servlet container should be ignoring whitespace around the values of parameters in the web.xml file. This is a good thing, because you often want (for readability) to put the value on a separate line. * The taglib declaration that Vikas is using will *only* work if you have manually copied the TLD to the specified location (WEB-INF/tlds/struts-html.tld inside the web application). But you should not have to do this, which leads to the most important point. * If you are using anything later than an ancient servlet container, specifying a taglib declaration is totally unnecessary, because the container will search inside JAR files included in your webapp. What you should be doing (for a Struts 1.x application) is declaring the following in your pages: %@ taglib prefix=html uri=http://struts.apache.org/tags-html; % and doing *nothing* in web.xml. The servlet container will find the correct tag library descriptor in the struts JAR files in WEB-INF/lib with no further actions on your part. See the Struts 1.x user guide[1] for more current information. Craig [1] http://struts.apache.org/1.x/userGuide/index.html Thanks Regards Nagesh Reddy -Original Message- From: vikas rao [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 01, 2007 10:10 AM To: Struts Users Mailing List Subject: HELP!! Hi, I am getting this exception: org.apache.jasper.JasperException: /index.jsp(9,0) No tag defined in tag library imported with prefix html My index.jsp file code starts like this: %@ taglib uri=/WEB-INF/tlds/struts-html.tld prefix=html % so what is the problem? I have added this in the web.xml file: taglib taglib-uri/WEB-INF/tlds/struts-html.tld /taglib-uri taglib-location/WEB-INF/tlds/struts-html.tld/taglib-location /taglib /web-app I am sooo frustrated, cant make a single struts program work :(. help!! vikas. DISCLAIMER: The information in this e-mail is the property of InterGlobe and is confidential and privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken in reliance on it is prohibited and will be unlawful. If you receive this message in error, please notify the sender immediately and delete all copies of this message - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 1.3.8: Sidebar: Sharing JAR Files Across Web Applications
On 4/20/07, Ken Miller [EMAIL PROTECTED] wrote: Craig McClanahan [EMAIL PROTECTED] 4/17/2007 4:33 PM Craig McClanahan wrote: Yep ... it's magic :-). Ah, magic. Lots of hand waving, followed gasps and applause :-) Guys, thanks for the great info - this has all been really helpful. However, I do have one question regarding the loading of the tag descriptors. When I first started getting struts working in my environment, I deployed the application with the struts jar files in the lib directory, and I was able to use the taglibs without making any changes to web.xml to create a uri-to-location mapping. (I take it the struts code looks for these tlds automatically upon startup, yes?) Actually, it is the JSP page compiler (part of the servlet container) that looks for these things, but yes, a modern container will scan JAR files for *.tld files in the META-INF directory. However, when I moved the struts jars into their own 'app', I was no longer able to do this. Placing a mapping in web.xml didn't help, and the only thing I could do was place the tlds in the WEB-INF directory in the web app. The strange this was that I was able to load the tlds via the class loader, although I didn't try it through the context class loader. What does moved the struts jars into their own 'app' mean? If you moved them to a different web application, they won't be accessible at all. If you put them someplace like Tomcat's $CATALINA_HOME/shared/lib directory, the JAR files should be accessible ... but I have no idea whether Tomcat scans those JARs as well as the ones in WEB-INF/lib. Is this an example of the issues I may have to deal with by trying to share the struts libraries? Cheers! -klm. Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 1.3.8: Sidebar: Sharing JAR Files Across Web Applications
On 4/16/07, Ken Miller [EMAIL PROTECTED] wrote: Can someone point me (or at least give me a clue) where a potential problem may exist? I've configured my server to have a shared set of Commons and Struts jars (something I did before reading the above paragraph), and it appears to work, but I'd like to investigate a few situations which may cause problems to better understand the possible pitfalls. There are at least two potential scenarios to watch out for. First, consider a case where you have a library commons-foo that your webapp depends on. Now, assume this library has a static variable bar defined in one of its classes. The challenge you have different semantics depending on where commons-foo.jar is located. * If commons-foo.jar is within /WEB-INF/lib, the static variable is global only to that particular web application. If two different webapps use this library, their uses of the static variable do not conflict. * If commons-foo.jar is stored in a shared classloader provided by your container (for example, in the shared/lib or common/lib directory for Tomcat) the global is shared *across* webapps, and any changes from webapp A can adversely impact webapp B. Second, consider what happens if library commons-foo needs to dynamically instantiate an instance of an application-provided class. The naive way for a library to do this is: String className = ...; // Calculate the name of the class you want Class clazz = Class.forName(className); Again, there are two different semantics (assuming the class to be loaded is part of your webapp, not part of the shared hierarchy): * If commons-foo.jar is within /WEB-INF/lib, the classloader can see your application class, and load it with no problems. * If commons-foo.jar is stored in a shared classloader provided by your container, you'll get a ClassNotFoundException. That happens because Class.forName() and friends start from the classloader that loaded the calling class itself (i.e. the commons-foo class doing this work) ... but your application class is not visible because you can only look *up* a classloader hierarchy, not down. The libraries that Struts itself depends on have likely shaken out most of the bugs like this since I wrote those warnings several years ago :-). But the only way to figure out if an arbitrary library will work in a shared environment is to exhaustively test and/or audit the code for statics and dynamic object creation. Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 1.3.8: Sidebar: Sharing JAR Files Across Web Applications
On 4/17/07, Christopher Schultz [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Craig, Craig McClanahan wrote: The naive way for a library to do this is: String className = ...; // Calculate the name of the class you want Class clazz = Class.forName(className); * If commons-foo.jar is stored in a shared classloader provided by your container, you'll get a ClassNotFoundException. That happens because Class.forName() and friends start from the classloader that loaded the calling class itself (i.e. the commons-foo class doing this work) ... but your application class is not visible because you can only look *up* a classloader hierarchy, not down. Can you briefly explain how struts even works when loaded from a shared ClassLoader? My reading of this suggests that shared struts would not be able to load actions found in the webapp's ClassLoader(s), but it sounds like the OP has done this successfully. Yep ... it's magic :-). Actually, what happens is that the servlet container provides a mechanism to acquire the ClassLoader instance for the web application itself, from which you can load application classes no matter where the caller is located. For instance, when Struts loads an action class, it does something like this (plus some exception catching, of course): String actionClassName = ...; ClassLoader cl = Thread.currentThread().getContextClassLoader(); Class actionClass = cl.loadClass(actionClassName); The container guarantees that the context class loader for a thread is set correctly, before it enters your servlet, filter, or listener. I'm just curious how it is done because you say above that this is a naive implementation... how does one do this in a smart way? It's not too relevant to the question... just thought I'd take the opportunity to find out since I've never heard of a good way to search down the ClassLoader hierarchy. There is indeed no way to search down the hierarchy, which is why the context class loader convention was created. As you examine libraries for potentially putting them into a shared class loader, look for code that does this kind of thing. Thanks, - -chris Craig -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGJMBM9CaO5/Lv0PARAqcPAJ9vnk8pj9El1gWtmqPv2smLYkSyxgCbBjOx 1nEpmu62YlqqDaqjHYLEkN8= =HxZg -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 1.3.8: Sidebar: Sharing JAR Files Across Web Applications
On 4/17/07, Christopher Schultz [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Craig, Craig McClanahan wrote: Craig McClanahan wrote: Yep ... it's magic :-). Actually, what happens is that the servlet container provides a mechanism to acquire the ClassLoader instance for the web application itself, from which you can load application classes no matter where the caller is located. For instance, when Struts loads an action class, it does something like this (plus some exception catching, of course): String actionClassName = ...; ClassLoader cl = Thread.currentThread().getContextClassLoader(); Class actionClass = cl.loadClass(actionClassName); I thought that the server created and started those threads independently of the webapp being used. Yes, it does ... although there is no restriction that a particular thread be used *only* for a particular application. Generally, the server will pool the threads across all active apps. I've never used Thread.getContextClassLoader... is that something that the server sets when it handles a request -- for purposes such as this? Yes, that's exactly what it is for. Craig The container guarantees that the context class loader for a thread is set correctly, before it enters your servlet, filter, or listener. I guess so... ;) There is indeed no way to search down the hierarchy, which is why the context class loader convention was created. As you examine libraries for potentially putting them into a shared class loader, look for code that does this kind of thing. Cool. Thanks for the explanation, Craig. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGJS4d9CaO5/Lv0PARAqzKAKC4t0HR31h8KaLX471socJ7rbNphQCfWpAM IrvvDVTjDYBpzob6TtwoGl4= =Qq2L -END PGP SIGNATURE- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 2.0.6 != Shale?
On 4/15/07, Nicolas Lanquetin [EMAIL PROTECTED] wrote: So, question: Are these the same frameworks? Is Shale a codename for Struts 2? No, they are not the same. No, it is not a codename. The Shale codebase started in a sandbox of the Struts project, and was proposed to the Struts committers as a basis for Struts 2. The Struts committers chose a different path for that (the merger with WebWork), and Shale became its own top level project at Apache (http://shale.apache.org/). Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts-Faces: parameter
On 2/18/07, Rodrigo Pereira [EMAIL PROTECTED] wrote: Is there any way of passing parameters to the action instead of form fields? I mean, I have a value on a managed bean and I'd like to pass it to the action, how can I do that? If the managed bean has been created already, and you know what scope it is in, you can just use the normal mechanism to get a request attribute, or a session attribute, and so on. But often, in a JSF based app, that is not always the case. For that scenario, there is a way to evaluate value binding expressions programmatically that will work inside your action, *if* it has been forwarded to from a JSF post (which means that the JSF lifecycle created a FacesContext for it): FacesContext fc = FacesContext.getCurrentInstance(); ValueBinding vb = fc.getApplication().createValueBinding(#{mybean.param}); String param = (String) vb.getValue(fc); This will cause the managed bean named mybean to be created (if necessary), then the getParam() method to be called, and that value to be returned. In this example I presumed that the data type was a string, but it can be any object type. Thanks, Rodrigo Pereira Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: R: R: Error : request.getReader()
On 1/29/07, Marcello Savino [EMAIL PROTECTED] wrote: The reason i need the request body is that the action i should take is to analyze the html generated. (ie.: syntax checking, finding img without alt attributes, reading meta-information ...). More: this job must be done server side (no jscript or other client-side stuff are allowed in my application). Thanks Marcello, To accomplish this goal, it seems to me you should be caring about the *response*, not the *request*, right? After all, it is the response that contains the markup that was generated by the server. The request will only contain the request parameters for this form, in the standard format defined by the HTML specification. If my assumption is correct, you should look at technologies that use a Servlet Filter to be able to capture a copy the rendered output, in addition to sending it to the browser. Using a Filter has the advantage of being something you can add without modifying the actual code that creates the HTML output, and then removed when you are finished with your testing. As to details of the technology, the SiteMesh[1] package has to do exactly what you are talking about ... buffer up the generated response, and then do something with it. SiteMesh is about transforming the generated output, which you are likely not interested in ... but examining the source code of the filter that SiteMesh uses should give you a big head start on figuring out how to implement something like this. Craig [1] http://www.opensymphony.com/sitemesh/ Marcello Savino ALDEBRA S.p.A. tel. 0461302441
Re: [s2] Struts Dependency Injection and EJB3 - support ? or how can i Do it?
On 1/22/07, Paris Apostolopoulos [EMAIL PROTECTED] wrote: [snip] I wonder the @EJB annotations are not going to work (I guess). I had a look @ some glassfish FAQ.. The standard annotations for Java EE 5 resource injection are indeed *not* going to work on a Struts action, because they only work on container-created objects (servlets, filters, listeners, and JSF managed beans). You'll want to look at a custom interceptor solution (as described in this thread), continuing to use JNDI lookups, or perhaps using an alternative resource injection framework like Spring. Craig
Re: Web Design Tools
On 1/9/07, CHARLIER Cyril [EMAIL PROTECTED] wrote: On 1/9/07, Robert Slama [EMAIL PROTECTED] wrote: Hi, Netbeans 5.5 is very well tool. http://www.netbeans.org Can you say more on hwo to interface netbeans with struts please :-) ? When you create a new Web Project, one of the panels that come up offers you a set of frameworks, including Struts and JSF. Click on the Struts checkbox, and your new project will come up with the Struts libraries pre-installed, and a basic struts-config.xml file set up. Craig -- Cyril
Re: Struts-Faces action
On 1/5/07, Rodrigo Pereira [EMAIL PROTECTED] wrote: Hi, I am new to JSF and Struts-Faces integration library. I am facing a problem but I did not find any documentation about this. That's the error I am getting: SEVERE: Servlet.service() for servlet jsp threw exception java.lang.IllegalArgumentException: Cannot find action '/login.do' configuration The implication of this message is that there is no action named /login in your Struts configuration files. Do you have one? Craig at org.apache.struts.faces.renderer.FormRenderer.encodeBegin( FormRenderer.java:115) at javax.faces.component.UIComponentBase.encodeBegin( UIComponentBase.java:317) at javax.faces.webapp.UIComponentTag.encodeBegin(UIComponentTag.java :374) at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java :261) The action is there in my struts-config.xml as following: action attribute=formLogin name=formLogin path=/login scope=request type=com.strutsfaces.LoginAction validate=false forward name=success path=/userLogin.faces contextRelative=true / forward name=failure path=/formLogin.faces contextRelative=true / /action Does anybody can help me? Thanks, Rodrigo Pereira
Re: [FRIDAY] DBCP configuration
On 1/5/07, Christopher Schultz [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Wesley, Wesley Wannemacher wrote: When configuring the database connections, where do you tend to put them? Without question: have your container create the connection pool and make it available via JNDI. This is the most portable configuration you can have. It allows the proper separation between development (the job of the programmers) and deployment (the job of the folks running the app servers). The folks who do the deployment should be in charge of running the app and database servers, so they know where they live, how much load they can handle, what special configuration options are best, etc. There's one additional advantage to using JNDI for this ... in many shops you have two or even three environments to worry about (development, staging, production), each with its own database instance. Having the database configuration for each instance in its own server means you do not need to go tweak your connection parameters as you move your app from one place to another. - -chris Craig
Re: [S2] Struts 2 GA Release Anytime Soon?
On 12/21/06, Nagraj Rao [EMAIL PROTECTED] wrote: Hi Ted Are there any AJAX Tags related issues in S2.0.1?? I'm currently migrating my project to 2.0.1, so in case there are any issues i'll start backing off. I got certain postings which were discussing DOJO issues in it to which i'm not much concerned right now. Overall i dont see any major issues in 2.0.1 . Correct me if i'm wrong. As with basically all open source projects, the issue tracker for Struts2 is publicly visible[1]. You are far better off reviewing the reported issues yourself (this is exactly the information that the developers see on reported issues), to see if any if any of them affect you, and what their status is. Asking generalized questions like this, where any possible answer does not really tell you what you need to know (does release x.y.zhave an issue that affects *me*), is not as effective at helping you make a correct decision on what to do next. Craig [1] https://issues.apache.org/struts/browse/WW N - Original Message - From: Ted Husted [EMAIL PROTECTED] To: Struts Users Mailing List user@struts.apache.org Sent: Friday, December 22, 2006 1:25 AM Subject: Re: [S2] Struts 2 GA Release Anytime Soon? On 12/21/06, Elie Ciment [EMAIL PROTECTED] wrote: The beta tag doesn't sit so well with them up there. Yes, this is why we release the codebase and then decide on its quality. We can make the judgement on actual experience, ratther than guestimates. Unless we go back and re-release the XWork bits as a stable version, S2.01 is stuck with the beta tag, regardless of the quality of the build. Though, it still could happen any time. The stumbling block is the XWork beta/rc tag. Once that is resolved, everything else could be wrapped up the first time someone had a free day. -Ted. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2, Shale, Seam, pure JSF - what to use?
On 12/19/06, Don Brown [EMAIL PROTECTED] wrote: It isn't an either/or question. You can use JSF actions, components, and configuration in a Struts 2 app, using the Struts 2 JSF Plugin. If you prefer an action-centric design, but want to use JSF components, then it is worth looking into. If you want a pure JSF approach, especially if you have your eye on the JSF tools, then MyFaces or Shale would be worth looking at. See also: http://cwiki.apache.org/WW/javaserver-faces.html As Don mentions, you can use JSF components with Struts2 pretty easily, and that can be a good avenue if you primarily want JSF for the visual components part, and don't need/want the managed beans and lifecycle controller parts. If a framework on top of JSF is what you are after (which is a reasonable thing for an application developer to want -- JSF focuses on the component APIs and the foundations for application needs), you can definitely look towards Shale[1] (we're putting the finishing touches on what we hope will be a GA release) or Seam[2] (just released 1.1 ). If you like tooling assistance around your development efforts, you might also want to take a look at what support your favorite IDE provides. If you happen to be in the NetBeans camp, the Visual Web Pack plugin is totally focused around visual drag-and-drop, and includes a built in framework with a lot of similarity to the view controller function in Shale, plus there is pretty nice non-visual support for straight JSF coding (including code generation for CRUD apps). You'll also see great support for JSF in Oracle's JDeveloper, and basic but getting there support in Eclipse. I can't speak to Idea's support for JSF, but wouldn't be surprised if it is comparable. Don Craig [1] http://shale.apache.org/ [2] http://jboss.com/products/seam/ On 12/19/06, Piero Sartini [EMAIL PROTECTED] wrote: Hello list, the last days I've read a lot about web frameworks in java. And the more I read, the more questions I have. Just writing this down, maybe someone has some thoughts that can help me. My problem is simple, or lets say it should be simple: What webframework is a good choice to start a new web application? After all, JSF seams to be popular, it is supported by big vendors and it is a standard. My problem with JSF is that its way too basic in my eyes. It does not give me best practices, its just there and says: use me. But it does not give me an idea how it is used best. But maybe I missed that. My feeling is that its a core technology like jsp ... someone should build a framework with it ... I am missing this framework around JSF that does speed up development. Is shale meant to be this framework? It matured a lot since I last looked at it. But for me, it looks like its not really accepted - maybe I am wrong. Is shale what I am searching for? There is JBoss Seam. I don't want to use jboss AS and not sure if its the best choice.. I looked at struts2 and it feels like it could be what I searched for. There is good documentation, many examples, an maven archetype, lots of users and the possibility to use third party technologies like freemarker. But my problem is that I am not sure if its not better to use JSF to be compatible with future technologies. There are a lot of ajax-components for example, and we can wait that a lot of third party libraries and tools will be available... Is there a simple answer? Regards, Piero - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] configuring Tiles with Struts 2
On 11/28/06, quinmeda1 [EMAIL PROTECTED] wrote: A little more info The following exception is thrown when trying to start the app with the listener: 2006-11-28 10:44:15 StandardContext[/myapp]Exception sending context initialized event to listener instance of class org.apache.struts2.tiles.StrutsTilesListener java.lang.NoClassDefFoundError: org/apache/tiles/TilesContainer Just as a historical note, I've been misled by NoClassDefFoundError before. It is not necessarily talking about this class itself (TilesContainer) -- that would normally give you ClassNotFoundException instead. It is more likely to be a missing class that is *imported* by TilesContainer. Craig
Re: Does Struts 2 solve the action chaining problem?
On 11/28/06, Tarek Nabil [EMAIL PROTECTED] wrote: Hi, One of the problems with Struts was that if you had a page that requires some setup and this page submits to an Action, then you would not be able to set validate to true on that action because if validation problems occur then Struts will take you directly to the input JSP without performing the setup and your JSP wouldn't work. A solution to that would be to specify the input of the action as the setup action, which means you're doing action chaining and Struts is not good at that (it will reset your form among other things). The solution of choice for us so far was to call validate() ourselves in the action and if a validation problem occurs then we call the setup method (eventually you start using your action methods as an API which still was not good). Another problematic scenario is the case when you're editing some database record for example. When you go to your setup action for the first time, you will populate drop down lists for example, and then load the existing values from the database to your JSP fields. If the user attempts to save and some problem occurs then in the setup action, you will need to again populate the drop down lists, but you will NOT want to overwrite the user's inputs with the existing data. This is very similar to the first problem, but you would also need to pass some flag to the setup method to tell it whether to copy the data from the database to your ActionForm. Does Struts 2 or even WW 2.2.4 solve that problem in an elegant way? I remember coming across something about using Interceptors for that, but that would mean creating an Interceptor for almost every action of that type. I also noticed that there are some warnings in the documentation against using action chaining in Struts 2 as well. Interceptors are an O-O oriented approach to this kind of issue, but there are ligther weight alternatives. For the particular need of a setup action, consider the use of the Preparable interface in Struts 2. It's pretty similar to what the Tiles Controller interface supported in Struts 1.x ... a chance for your business logic to set up the stuff that is needed for rendering a particular view. If you're looking at JSF as a view technology, you'll likely be interested in what Shale http://shale.apache.org/; has to offer, particularly in the View Controller feature. Not only does the View Controller functionality support the setup scenario (via the prerender() callback method on the ViewController interface), it also supports cleaning up *after* the view has been rendered, via the destroy() callback. Craig
Re: Please unsubscribe me
On 11/7/06, Pillay, Kiren KN [EMAIL PROTECTED] wrote: I've tried many times to unsubscribe myself from this list but its not working. I've asked for help but to no avail. Done. Craig
Re: get webapp root directory from action constructor
On 11/3/06, Patrice Le Cozler [EMAIL PROTECTED] wrote: Hi, I want to load a property file at webapp start. Since that property file is located in my webapp's directory structure, I want to be able to determine its absolute name at runtime. I tried this.getServlet().getServletContext().getRealPath(PROPS_FILE) but getServlet() returns null when called from an Action constructor. Why ? Is there another way to achieve the same result ? I can't use MessageResources because it depends on the actual httpRequest instance. An alternative approach that doesn't need access to the servlet instance should work for you. Put your properties file (say, myprops.properties in the WEB-INF/classes directory. Now, you can access it like this: InputStream stream = this.getClass().getResourceAsStream( myprops.properties); Properties props = new Properties(); props.load(stream); stream.close(); Thanks in advance Patrice Craig
Re: taglib uri question
On 10/30/06, Wendy Smoak [EMAIL PROTECTED] wrote: On 10/30/06, Rick Schumeyer [EMAIL PROTECTED] wrote: In any event, the author gives one method for including taglibs in jsp. For example, for tiles you would use: %@ taglib uri=/WEB-INF/struts-tiles.tld prefix=tilles % This works, but requires you to put the tld files in your webapp under WEB-INF. With a Servlet 2.3/JSP 1.2 or later container, this isn't necessary. But the current tiles docs say to use: %@ taglib uri=http://struts.apache.org/tags-tiles; prefix=tiles % ... 1. Is the only way to determine the correct uri value to look it up in the docs? (Is there any other way to know that the correct value is http://struts.apache.org/tags-tiles; ?) The final answer is in the tld itself, which you can find inside the struts-tiles jar, or in svn: http://svn.apache.org/repos/asf/struts/struts1/trunk/tiles/src/main/resources/META-INF/tld/struts-tiles.tld The uri should match there in the tld and in your %@ taglib directive. 2. How does that really work ? I know that nothing ever actually connects to http://struts.apache.org, so how does that value get mapped to the correct jar file under WEB-INF? Are all the jar files checked until one with a matching tag is found? According to Craig, it's magic. :) http://marc.theaimsgroup.com/?l=struts-userm=104205482618830w=2 I'm hazy on the specifics, but I think all the jars get scanned when the webapp starts, and that it looks in META-INF and below. Any tlds it finds are then available to the webapp. That is exactly right. The important thing to realize is that the taglib URI itself is just an arbitrary string ... the fact that most people make them look like URLs was probably, in retrospect, a mistake. The actual matching that occurs is the uri value you specify in a %@ taglib % directive, to the uri element in a TLD. The two strings can be anything at all, as long as they are identical. -- Wendy Craig
Re: Drag-and-drop struts-aware IDE?
On 10/20/06, Bruno Melloni [EMAIL PROTECTED] wrote: It surprises me that a drag-and-drop struts aware IDE does not exist. A Struts drag-and-drop plug-in for Eclipse would be a very compelling product - the strength of (a current version of) Struts with the easy of use of Visual Studio... Many would pay for that. It should not be quite so surprising, when you think a bit about what such a tool would actually have to do. Struts tags for JSP pages are not really standalone components, so the tool would have to continually recompile the entire page and then ask it to render itself (simulating the runtime environment inside a servlet container) every time you dropped a new tag, or changed a property on an existing one. Given the speed of current generation JSP compilers (a lot better than it used to be, but still visible) that is still going to make it hard to provide a great user experience. Tools for component oriented frameworks like JSF get away without this, because the components can be rerendered indivisually. For example, in Java Studio Creator when you drop a new component, it just asks that component (and any children) to rerender, with no need to deal with the entire page. Craig
Re: Static objects in Struts Application ..
On 10/13/06, Chris Pratt [EMAIL PROTECTED] wrote: Each Web Application within the container is loaded within it's own Context (and ClassLoader) which effectively keeps the static's separate. (*Chris*) That is generally true, *unless* you put your libraries in the shared classloader(s) provided by the container (in Tomcat, that means putting JAR files inside the shared/lib or common/lib directories). In that case, the statics are shared across *all* webapps using that library, which is generally a bad thing. Craig On 10/13/06, souravm [EMAIL PROTECTED] wrote: Hi, If there are two different Struts applications deployed on the same Tomacat instance, what happens to the static objects within the Struts framework? My guess is Struts maintains different Static objects for each application in a hash map. Can anyone confirm ? Regards, Sourav CAUTION - Disclaimer * This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system. ***INFOSYS End of Disclaimer INFOSYS*** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: [Struts 2] setting spring bean from action
On 9/11/06, Ted Husted [EMAIL PROTECTED] wrote: The Spring bean can be instantiated as a singleton, and any change made to the object via the property would be to the singleton instance, and reflected anywhere else the object is referenced, including another Action class. I believe that there may be notions of session in the Spring API, but I would have to look. (Though, I may also be thinking of Spring.WEB for .NET.) Generally, a Spring bean is a singleton or not-a-singleton, so the scope is either global or local. In Spring2, you have the additional option to create Spring beans in a scope (request, session, or application). But for Spring1 the above statement is accurate. Craig Something to note is that in S2, Actions are *not* singletons, so a Spring bean injected to an Action is only a singleton if Spring makes it so. -- HTH, Ted. * http://www.husted.com/struts/ On 9/11/06, Garner Shawn [EMAIL PROTECTED] wrote: It is already autowiring into my action. I want to autowire out from of my action into spring so it can get autowired in other actions after I set the value and don't want to copy all the bean values from one object to another. I realize I could autowire an enclosing bean and then set the value but I think it'd be just as easy to set the bean back into spring. Also are spring beans scoped? Application, Session? Shawn 2006/9/10, Ted Husted [EMAIL PROTECTED]: On 9/9/06, Garner Shawn [EMAIL PROTECTED] wrote: I want to set the value of the spring bean defined in the spring xml file. I have the value in the action but I want to set the spring bean's value with it. Given a matching property, Struts 2 can automatically inject a Spring bean into the Action. Set the beans to autowire and autodect beans default-autowire=autodetect /beans - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Shale] Old form values still there after Cancel button.
On 8/30/06, Jason Vincent [EMAIL PROTECTED] wrote: Hi all, For the life of me I can't get JSF to stinkn forget values that were entered on a form. The view controller is request scope. Are you using Shale for this? If so, you'd be best off joining the Shale user list, as Shale is now it's own top level project. See http://shale.apache.org/mail-lists.html for signup details. If I start to enter data in a form and then click the Cancel button, which has immediate=true, the values entered by the user reappear in the form when I return to the page. The action of the Cancel button returns home which maps to a navigational rule to the home page that is a redirect. I've tried these two things which haven't worked: 1) traverse the ViewRoot looking for UIInputs and setting the submitted value to null. 2) set the value binding to the VC managed bean to null. I had read that JSF will reuse evaluated expressions if they aren't null. Setting the cancel button's immediate property to true is the right general behavior, because you want to bypass validation and model value updates. However, that should actually be irrelevant if you are redirecting to the new page. The only way I can think of that you should expect the behavior you describe is if you have bound components on the page to a bean that is in session scope, rather than request scope. Any help is greatly appreciated. Jason - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Craig
Re: shale: jndi lookup error
On 8/5/06, vasiliy.kiryanov [EMAIL PROTECTED] wrote: Good afternoon. [http://shale.apache.org/features-jndi-integration.html] link says to me that I can aquire a java.sql.Connection from this data source .. but it constantly return null. from the myfaces BackBean this datasource resolves good. Does anybody have any ideas? Shale has become it's own top level project with it's own mailing lists ... you might want to subscribe to the user list there via the links on http://shale.apache.org/mail-lists.html. What you are trying looks like it should work. If you try to look it up in the usual JNDI way, InitialContext initContext = new InitContext(); DataSource ds = (DataSource) initContext.lookup (java:comp/env/jdbc/postgres); does it actually work? Also, what servlet container are you running on? Craig I have next entry in the web.xml resource-ref descriptionpostgreSQL Datasource/description res-ref-namejdbc/postgres/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref and use next class: public class jndiTest extends AbstractViewController { public jndiTest() { try { FacesContext context = FacesContext.getCurrentInstance(); Application appl = context.getApplication(); ValueBinding vb = context.getApplication ().createValueBinding(#{jndi['jdbc/postgres'].connection}); Connection conn = (Connection) vb.getValue(context); } catch (Exception e) { e.printStackTrace(); } } } and I call object of this class in this way: public class TestLoginBackBean extends AbstractViewControllerTestCase { LoginBackBean loginBackBean; public TestLoginBackBean(String name) { super(name); } public static Test suite() { return (new TestSuite(TestLoginBackBean.class)); } public void setUp() { super.setUp(); loginBackBean = new LoginBackBean(); } public void tearDown() { loginBackBean = null; super.tearDown(); } public void testLoginBackBean_one() { jndiTest jnditest = new jndiTest(); } } -- View this message in context: http://www.nabble.com/shale%3A-jndi-lookup-error-tf2055640.html#a5663762 Sent from the Struts - User forum at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts-Shale
On 8/3/06, Jeevan Kumar Kade [EMAIL PROTECTED] wrote: Hi, Is there is major differeence between Struts-Shale framework and JSF. Please, categorize and differentiate on this. Your best bet is to ask this kind of question on the Shale user mailing list[1] since Shale is now a top level Apache project. Shale is a framework that *extends* JSF by adding additional features and ease of use ... features are described on the website[2]. Thanks in Advance Jeevan Kumar Craig [1] http://shale.apache.org/mail-lists.html [2] http://shale.apache.org/ - Do you Yahoo!? Get on board. You're invited to try the new Yahoo! Mail Beta.
Re: [Shale] Get the application path
On 7/28/06, Marty Phee [EMAIL PROTECTED] wrote: How do I get the application path. I can see it in the debugger through the ApplicationContextFacade, but not sure how to access it. I need the path of the application to pass on to a report generator. Shale has migrated to its own top level project with it's own mailing lists ... you'll want to refer to http://shale.apache.org/mail-lists.html for subscription information. But, to answer this particular question, the context path of an application is available from the ExternalContext associated with the current request. In a view controller (or other class that extends AbstractFacesBean), you can call: String contextPath = getExternalContext().getContextPath(); or, in any sort of backing bean, you can use the more verbose approach: FacesContext context = FacesContext.getCurrentInstance(); String contextPath = context.getExternalContext().getContextPath(); Thanks, Marty Craig
Re: [Shale] Get the application path
On 7/28/06, Marty Phee [EMAIL PROTECTED] wrote: Thanks. I'll move over to that list, but I'm looking for the application path. Not the context path. By application path do you mean the directory path to where the application is deployed from on disk? You are correct in noticing that this is not exposed to the application via JSF APIs ... in part because there might not actually be such a thing (for example, if the app server runs your application from an unpacked WAR fie, or puts all the resources into a database or somethng like thiat). The best you can do is infer it from a call like this: FacesContext fcontext = FacesContext.getCurrentInstance(); ServletContext scontext = (ServletContext) fcontext.getExternalContext ().getContext(); String path = scontext.getRealPath(/index.html); // Or some resource known to exist ... check path for being null ... ... strinp off the last segment to get the directory path ... Craig Craig McClanahan wrote: On 7/28/06, Marty Phee [EMAIL PROTECTED] wrote: How do I get the application path. I can see it in the debugger through the ApplicationContextFacade, but not sure how to access it. I need the path of the application to pass on to a report generator. Shale has migrated to its own top level project with it's own mailing lists ... you'll want to refer to http://shale.apache.org/mail-lists.html for subscription information. But, to answer this particular question, the context path of an application is available from the ExternalContext associated with the current request. In a view controller (or other class that extends AbstractFacesBean), you can call: String contextPath = getExternalContext().getContextPath(); or, in any sort of backing bean, you can use the more verbose approach: FacesContext context = FacesContext.getCurrentInstance(); String contextPath = context.getExternalContext().getContextPath(); Thanks, Marty Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Shale - init and destroy being called twice
On 7/13/06, vramineni [EMAIL PROTECTED] wrote: Hi, I am a newbie to web development in Java. Coming from ASP.Net background, I thought Shale framework would be easier for me to understand. Actually, I am able to progress well with Shale/Clay/MyFaces and pretty much do everything that I could using ASP.Net. I am stuck with this problem of init() and destroy() being called twice. First init() call has PostBack set to false always. I thought I was doing something wrong, I have downloaded the Shale usecases project and even this project has the same issue. Right now, I am getting by using a counter. Any help on this would be appreciated. Shale now has it's own mailing list ... could you please join us there using the information at [1] to subscribe? Also, which page(s) in the Use Cases application did you observe this behavior on? Also, can you provide a few more details about the page and managed bean And, how recent is the version of Shale you are using for this? Craig [1] http://shale.apache.org/mail-lists.html -- View this message in context: http://www.nabble.com/Shale---init-and-destroy-being-called-twice-tf1941764.html#a5322081 Sent from the Struts - User forum at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: URL transparency for a web application in a clustered system
On 7/13/06, Michael Jouravlev [EMAIL PROTECTED] wrote: Say I want to redirectto to a same action that has been posted to from a browser. I don't have a hardcoded action name that I want to call. I need to obtain this name (with context and such) from the request. What do I do? I can get request.getRequestURI(), request.getRequestURL(), request.getContextPath() but obviously they display information about request that was generated by a load balancer. Is there a standard, or non-standard but common way to obtain original address that was used by a browser for initial request? Of course I can create my own balancing application and send original address to a cluster member as parameter, but I am looking for less proprietary solution. Seems that Tomcat performs redirection through browser, or is it just the sample that I am running? Can a load balancer call managed server directly, without involving browser? Are there clustering solutions out there, that provide full server transparency including URL that a browser sent a request to? What happens with tools like mod_rewrite? If I have Apache in front of Tomcat this is kind of the same as having load balancer in front of Tomcat, is it? So the original URL is lost as well? Seems that automatic action/page reloading from the same address works only in non-clustered environment which really limits the applicability of this technique. If you are using Tomcat, you can set some configuration options in the Connector element (I think it is) so that the application sees the same URLs that the browser submits to, instead of ones pointing back at the load balancer. Check out the server configuration docs[1] for more info. Settings like proxyName and proxyPort are probably what you are looking for. For other servers, you'll want to look for similar sorts of capabilities, but it's clearly going to be server specific. Michael. Craig [1] http://tomcat.apache.org/tomcat-5.5-doc/config/http.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[ANNOUNCE][SHALE] Apache Shale Top Level Project Is Now Up And Running
You might have seen the recent announcement that Apache Shale, originally developed as part of the Apache Struts project, has been approved as an Apache top level project of its own. This message is an announcement that the project resources are now completely set up (thanks to the prompt attention of the Apache infrastructure team), and ready for use: Project Web Site: http://shale.apache.org/ Project Wiki Site: http://wiki.apache.org/shale/ Mailing List Information / Subscription / Archive Links: http://shale.apache.org/mail-lists.html Nightly Builds: http://people.apache.org/builds/shale/ On the web site, you will notice that there is, as of yet, no logo for the project. In fact, we would really like two images -- one for the web site logo, and a Powered By Shale logo that can optionally be included by web applications built with Shale. As someone who can barely draw a rectangle with straight lines, this seems like the perfect opportunity to get the community involved in a design ... so we're going to have a logo contest. Read about it on our wiki page, and submit your creative ideas there: http://wiki.apache.org/shale/LogoContest then, join the Shale User mailing list and root for your favorites. Craig McClanahan
Re: [Shale] Validation...
On 7/5/06, Rodrigo Barreiros [EMAIL PROTECTED] wrote: Hi, I need use client-side validation in my application. I am using Shale Validator (shale-core-1.0.2) with Myfaces 1.1.1. The validation works fine, but messages appears encoded in wrong way. For example, for message (in portuguese): errors.required={0} ? um campo obrigat?rio. Appears: Nome #233; um campo obrigat#243;rio. in alert window. The same happens using corejsf-validator tag. Any suggests? One thing to double check is to review how you created your properties file. After creating such a file, you need to run the native2ascii command line tool to do the encoding on it. Another issue might be the character encoding on your JSP page itself. Be sure you've set the encoding to UTF-8, using something like either: @page pageEncoding=UTF-8 % or @page contentType=text/html;charset=UTF-8 % Thanks, Rodrigo Craig -- View this message in context: http://www.nabble.com/-Shale--Validation...-tf1896745.html#a5188079 Sent from the Struts - User forum at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [shale] and ejb 3.0 and hibernate working together example
On 6/30/06, Adam Brod [EMAIL PROTECTED] wrote: I had to put my directory structure like this: [mywebapp]\WEB-INF\classes\META-INF\persistence.xml It didn't work when I put it in a top-level META-INF directory. It also works if the persistence.xml file is in the META-INF directory of a jar file in WEB-INF/lib ... the key is that it has to be visible to the webapp class loader. HTH, Adam Brod Product Development Team Craig PS: By the way, NetBeans 5.5 takes care of all the grunt work like this for you :-).
Re: How to add service servlet in Struts ?
On 6/30/06, A. Lotfi [EMAIL PROTECTED] wrote: Hi, we had a client/server application : Client :Swing application Server :Servlet The client is communicating lot with the servlet. Now we are moving to Struts, how can I keep the servlet in Struts so I will use it in all my actions, I am looking in a way that at the strut up that servlet starts. Thanks, your help is appreciated. There is no problem having your own servlet along with the Struts servlet in the same web application, as long as you map to different URL patterns. In order to get your servlet to start up when the app starts, use a load-on-startup element inside the servlet element in web.xml (just like the examples for Struts's ActionServlet demonstrate). The number you use inside determines the order of loading, in case that matters. Craig - Yahoo! Music Unlimited - Access over 1 million songs.Try it free.
Re: [shale]Craig McClanahan's comment on View Controllers
On 6/29/06, Baker,Jonathan [EMAIL PROTECTED] wrote: In an earlier post, Craig responded to a question by saying Personally, I consider putting view controllers in session scope to be a pretty bad idea, and would lean towards making this a restriction. (Putting non-view-controller backing beans in session scope to save state across sessions is fine.) (The whole post is included below if you're interested) This makes sense if a ViewController is our in-memory object representation of a page, since a page only lasts for one request. Well, I was looking at the Shale samples and in the rolodex example, the ViewController (backing bean) for the rolodex is stored in session scope. managed-bean description View controller for the JSP view rolodex usecase /description managed-bean-namerolodex/managed-bean-name managed-bean-class org.apache.shale.usecases.rolodex.Rolodex /managed-bean-class managed-bean-scopesession/managed-bean-scope /managed-bean I understand that samples don't have to reflect best-practices, but I'm curious as to what the best-practice would be. Good catch :-). I suspect the use case here was maintaining some view state information across requests -- right, Gary? Should your ViewController object be in request scope, and get injected with a non-view-Controller that could live in any scope. The non-view-Controller can have model objects injected into it. This way the ViewController can handle all view related methods, and pass through to the non-view-Controller for business methods which then get passed on to the model objects. That's the way I'd probably do it, especially if I had prebuilt model and business logic objects. A benefit of this is that your non-VC beans don't have to have any API dependency on the web tier at all ... making it much easier to unit test in isolation, or reuse in other application environments. If these non-VC objects are managed beans, you can also use the setter dependency injection mechanisms to configure *them* as well. Should your ViewController object live in request scope, and just get variously scoped model objects injected, and after that just work as both a View and non-view Controller. This works ok for simple apps, but can lead you down a mixing of concerns path that makes life more complicated in larger scenarios. The corresponding question for Struts 1.x would be do I put my business logic directly into my Actions, or do I abstract it out into separate classes? The general wisdom is that you *should* separate things, but you'll often see small (and sometimes not so small) apps that mix. Shoud you do something else completely different from either of those two scenarios? JB Craig
Re: [shale] and ejb 3.0 and hibernate working together example
On 6/29/06, stephan opitz [EMAIL PROTECTED] wrote: hello... does exist any kind of good example which include in the controller component hibernate with normal pojos or maybe already ejb 3.0??? I am almost through with a Shale+EJB3 (well, actually its Shale+JPA) example. It's the good ol' Struts MailReader application, recast to use the new Java Persistence Architecture for talkng to the database. One nice thing about it (courtesy of Java EE 5) is you get dependency injection of things like the entity managers into your managed beans (including the view controllers behind each page). This will get included (eventually) as a formal Shale example later on. An application that used Hibernate for persistence woud be virtually identical in overall structure ... the concepts behind Hibernate and JPA are pretty similar for this kind of usage, although many of the details definitely differ. stephan Craig
Re: shale log trace
On 6/29/06, Daniel del Río [EMAIL PROTECTED] wrote: Hi all, I have a trace in the console like DEBUG DelegatingVariableResolver : Attempting to resolve variable 'org.apache.shale.TAG_UTILITY_BEAN The console is full of traces like this every time a page is reload, what it means? It looks like you have debug-level logging turned on for Shale, which is definitely going to create *lots* of output. This particular message means that a value binding expression was being evaluated that included this particular managed bean name. I tried to limit the category for the org.apache package in the log4j configuration file without luck. log4j.logger.org.apache.shale=OFF (i would prefer not to quit all, but for test...) You'd probably be better off setting the overall Shale logging level to INFO. You can then go set the level to debug on particular classes if you want debug-level logging for investigating a particular area. some have an answer? thanks in advance. drh. Craig
Re: [shale] Design question involving ViewController
On 6/17/06, Gary VanMatre [EMAIL PROTECTED] wrote: From: Sean Schofield [EMAIL PROTECTED] I am writing an application that is using MyFaces tree2 to allow the user to navigate to a more detailed view of the item they click on. I just wanted some feedback on the following strategy: The node in the tree has an action method that puts the selected node's id into the request as a parameter. The String returned by the action method navigates you to a general detail page which is associated with a ViewController. The vc's init() method reads the node id out of the request and pulls the necessary info out of the data. Does this general approach make sense? I think that's exactly what the extra callbacks on the view controller should be used for. You could use the setter injections stuff on a managed bean to grab the values out of the request but without the view controller, you wouldn't have a good hook for pre process or staging logic since the view root doesn't have these kind of events. While biulding a Shale-based prototype application recenty, I ran into a gotcha with respect to the setter injection stuff when you don't actually have a request parameter on the incoming request. If you use #{param.foo} as your managed property's value element, and there is no request parameter named foo, the RI (at least) will throw an exception when trying to do the value push. (Didn't have time to confirm whether MyFaces acts the same way). One could argue that this is a usability issue that should be addressed even if the spec is silent on the topic. But, in the mean time, I'm doing exactly what Sean describes (copy the request parameters in the init() callback) to pull out these sorts of values. Indeed, if you use the latest sources (in the Maven-generated buld that we just switched to), I've added the following convenience method to AbstractFacesBean (ancestor to AbstractViewController) to make this kind of thing a bit simpler to code: public String getRequestParameter(String parameterName); TIA, Sean Gary Craig
Re: help in maven
On 6/19/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Dear all, I am new to Maven. Can u suggest me a good resource to learn maven. A very helpful resource is an online e-book, Better Builds With Maven[1]. I have exp. in ant tool. What way maven differs from ant? Help plz. regards, Mansoor Craig [1] http://www.mergere.com/m2book_download.jsp
Re: [shale] Problems with View controller
On 6/19/06, Marty Phee [EMAIL PROTECTED] wrote: I'm using: shale, tiger, tiles. Nothing like trying *all* the new stuff all at once :-). How recent is the Shale build you are using? I ask because there were recent (after 1.0.2) changes in how init and destroy get called such that they should *always* happen. To cause the other callbacks to occur, you'll need to use s:subview tags around your tiles:insert tags. Also, I haven't tested this particular combination, so if that fails on a current build, then it's a bug we'll need to take a look at. Craig I have a layout with one of the tiles being AdminContent.jsp. !-- Doc index page description -- definition name=/admin/AdminMain path=/admin/layouts/mainLayout.jsp put name=header value=/admin/tiles/header.jsp / put name=menu value=/admin/tiles/MainMenu.jsp / put name=monitor value=/admin/tiles/DSLMonitor.jsp / put name=content value=/admin/tiles/AdminContent.jsp / put name=messages value=/admin/tiles/Messages.jsp / /definition I have a backing bean bean.AdminContent which is also declared as a @View. @Bean(name=AdminContent, scope= Scope.SESSION) @View public class AdminContent { @Initpublic void init(){ System.out.println(Init called); } @Prerenderpublic void preRender() { System.out.println(Prerender); } @Destroypublic void destroy() { System.out.println(Destroy); } @Preprocesspublic void preprocess() { System.out.println(Preprocess); } init() is getting called, but none of the other methods are (destroy, prerender, preprocess). When I do submits the bean is being populated fine and the callback works as expected. JSP: AdminContent.jsp f:view . . . h:form table border=0 cellpadding=0 cellspacing=0 tr td h:outputText value=Status: #{AdminContent.status}/ /td /tr tr td h:commandButton value=Start action=#{adminContentHandler.saveAdminContent} / br h:commandButton value=Stop action=#{adminContentHandler.saveAdminContent} / br h:commandButton value=Restart action=#{adminContentHandler.saveAdminContent} / /td /tr /table /h:form . . . /f:view Layout: mainLayout.jsp html head titleMy Title/title link rel=stylesheet type=text/css href=/styles/vaAdmin.css/ /head table border=0 cellpadding=0 height=100% width=100% tr valign=top td colspan=4 tiles:insert attribute=header /tiles:insert /td /tr TR height=100% TD height=100% width=15% valign=top tiles:insert attribute=menu /tiles:insert /TD TD width=65% valign=top tiles:insert attribute=content /tiles:insert /TD td width=20% valign=top tiles:insert attribute=monitor /tiles:insert /td /tr tr valign=bottom td colspan=4 valign=top tiles:insert attribute=messages /tiles:insert /td /tr /table /html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [shale] Problems with View controller
On 6/19/06, Marty Phee [EMAIL PROTECTED] wrote: Ok, I've got most everything working. Combination of things mostly me not know how to configure everything. There is a problem though if you use tiger and subview. Only init() will be called if the bean is marked session. If you mark it request init and destroy will be called. The problem is in org.apache.shale.component.SubView. Not really a problem per-say, but tiger needs to implement something for subviews. Hmm ... I'll bet it's not just subviews ... I'll bet any ViewController you put in session scope will have the same problem. Personally, I consider putting view controllers in session scope to be a pretty bad idea, and would lean towards making this a restriction. (Putting non-view-controller backing beans in session scope to save state across sessions is fine.) It ends up failling here after I set the id to a valid managed (by tiger) bean that has the @View anotation. Since it's trying to cast it to a ViewController it fails. What bit of code is trying to cast it? If you are talking about the ViewControllerCallbacks implementation, that gets specifically replaced by a Tiger version that uses reflection to call the method marked with an annotation instead, when you add shale-tiger.jar to your webapp After I added extends AbstractViewController all the events were filed. Like wise if I didn't use tiger it worked fine. Those caess make sense, because even the Tiger version will recognize beans that implement the ViewController interface ... essentially it just pretends that the four callback methods were annotated. // Construct and initialize a new ViewController, if any is associated String expr = #{ + name + }; try { vc = (ViewController) context.getApplication(). createValueBinding(expr).getValue(context); if (vc == null) { log.debug(messages.getMessage(subview.noBean, new Object[] { getId() })); return null; } Where specifically is this code? If it's in the subview handler, that will definitely have problems with the Tiger stuff, and will need to be updated. Craig Craig McClanahan wrote: On 6/19/06, Marty Phee [EMAIL PROTECTED] wrote: I'm using: shale, tiger, tiles. Nothing like trying *all* the new stuff all at once :-). How recent is the Shale build you are using? I ask because there were recent (after 1.0.2) changes in how init and destroy get called such that they should *always* happen. To cause the other callbacks to occur, you'll need to use s:subview tags around your tiles:insert tags. Also, I haven't tested this particular combination, so if that fails on a current build, then it's a bug we'll need to take a look at. Craig I have a layout with one of the tiles being AdminContent.jsp. !-- Doc index page description -- definition name=/admin/AdminMain path=/admin/layouts/mainLayout.jsp put name=header value=/admin/tiles/header.jsp / put name=menu value=/admin/tiles/MainMenu.jsp / put name=monitor value=/admin/tiles/DSLMonitor.jsp / put name=content value=/admin/tiles/AdminContent.jsp / put name=messages value=/admin/tiles/Messages.jsp / /definition I have a backing bean bean.AdminContent which is also declared as a @View. @Bean(name=AdminContent, scope= Scope.SESSION) @View public class AdminContent { @Initpublic void init(){ System.out.println(Init called); } @Prerenderpublic void preRender() { System.out.println(Prerender); } @Destroypublic void destroy() { System.out.println(Destroy); } @Preprocesspublic void preprocess() { System.out.println(Preprocess); } init() is getting called, but none of the other methods are (destroy, prerender, preprocess). When I do submits the bean is being populated fine and the callback works as expected. JSP: AdminContent.jsp f:view . . . h:form table border=0 cellpadding=0 cellspacing=0 tr td h:outputText value=Status: #{AdminContent.status}/ /td /tr tr td h:commandButton value=Start action=#{adminContentHandler.saveAdminContent} / br h:commandButton value=Stop action=#{adminContentHandler.saveAdminContent} / br h:commandButton value=Restart action
Re: OT: Tomcat not setting session cookies ? Please help :(
On 6/15/06, Mon Cab [EMAIL PROTECTED] wrote: Thanks Craig Tomcat is not only doing this on the first page, but also on all the subsequesnt pages. And theres no jsessionid cookie in the cookie folder. I also disabled the firewall, to see if the cookie was being blocked there. Do you know how something like this might happen? Sorry, can't help you much there. I'd suggest trying to find some sort of HTTP monitoring tool (or see if Tomcat can dump out all the HTTP headers to see if the cookie is actually being sent or not, or if perhaps it might be getting swallowed by a proxy somewhere. Craig --- Craig McClanahan [EMAIL PROTECTED] wrote: On 6/15/06, Mon Cab [EMAIL PROTECTED] wrote: Hi All of a sudden tomcat has stopped settign session cookies. I have been developing on my local machine for approx 1yr. Now, When I goto my webapps home page: http:/127.0.0.1:8080/webapp), tomcat is rewriting the URL as http://127.0.0.1:8080/webapp/Welcome.do;jsessionid=DAF0604E76E234C157A9BFDF53FD2617 , indicating that it is not setting a session cookie. When I check the session cookie folder C:\Documents and Settings\user\Cookies. There is no jsessionid cookie. When I set a cookie from within webapp, the cookie is set as normal and stored in the cookie folder C:\Documents and Settings\user\Cookies, and is retrieved by my web application. Why is Tomcat not setting a session cookie? I configured my browser to accept all session cookies. I am using Windows XP Pro, with IE6, j2sdk1.4.2_08, Tomcat 5.0.28. This has been working as it is supposed to for 1 year. Can anyone explain what is going on? When you submit the very first request in a new session, Tomcat has no way to know whether your client has cookies enabled or not. So, it sends the session id both ways (via URL rewriting, and by sending a cookie). If the second request comes back in with a cookie, Tomcat says aha, this particular client supports session cookies and turns off the rewriting. Otherwise, it will continue the rewriting for all subsequent requests in the same session. Craig __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [shale] using the eclipse ide (maybe ith ant or maven2)
On 6/15/06, Gary VanMatre [EMAIL PROTECTED] wrote: From: Wendy Smoak [EMAIL PROTECTED] On 6/15/06, Gary VanMatre wrote: My second attempt was to add the cargo.jvmarg to the /shale-apps pom.xml: build finalName${artifactId}/finalName plugins plugin groupIdorg.codehaus.cargo/groupId artifactIdcargo-maven2-plugin/artifactId ... properties cargo.jvmargs-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n/cargo.jvmargs /properties Gary, this worked perfectly for me (with JSwat). Thanks! This has been on my figure out how to... list for a while now. (Be sure to 'mvn install' once from the top to make sure your pom changes get into your local repository.) Yeah, I finally got it to work too but I had to add it to the shale-clay-usecases pom.xml. I thought that I tried the install at the shale-apps level. So the inheritance must not be dymamic for all the sub pom's. The parent pushes it's config to the child? But, I added those command to my maven notes. side: 'mvn help:effective-pom' will show you what's in effect, lewise 'mvn help:active-profiles' will show you which profiles are I was going to commit this jvmargs setting to the shale-clay-usecases's pom but what do you think about moving it up to shale-apps so we wouldn't have to think about it again? If it really does work for all the apps, I'm definitely +1 on putting this in shale-apps-parent. -- Wendy Gary Craig
Re: OT: Tomcat not setting session cookies ? Please help :(
On 6/15/06, Mon Cab [EMAIL PROTECTED] wrote: Hi All of a sudden tomcat has stopped settign session cookies. I have been developing on my local machine for approx 1yr. Now, When I goto my webapps home page: http:/127.0.0.1:8080/webapp), tomcat is rewriting the URL as http://127.0.0.1:8080/webapp/Welcome.do;jsessionid=DAF0604E76E234C157A9BFDF53FD2617 , indicating that it is not setting a session cookie. When I check the session cookie folder C:\Documents and Settings\user\Cookies. There is no jsessionid cookie. When I set a cookie from within webapp, the cookie is set as normal and stored in the cookie folder C:\Documents and Settings\user\Cookies, and is retrieved by my web application. Why is Tomcat not setting a session cookie? I configured my browser to accept all session cookies. I am using Windows XP Pro, with IE6, j2sdk1.4.2_08, Tomcat 5.0.28. This has been working as it is supposed to for 1 year. Can anyone explain what is going on? When you submit the very first request in a new session, Tomcat has no way to know whether your client has cookies enabled or not. So, it sends the session id both ways (via URL rewriting, and by sending a cookie). If the second request comes back in with a cookie, Tomcat says aha, this particular client supports session cookies and turns off the rewriting. Otherwise, it will continue the rewriting for all subsequent requests in the same session. Craig
Re: [shale] Backing view
On 6/14/06, Marty Phee [EMAIL PROTECTED] wrote: Newbie, I'm using Shale with tiger. JSP, subscribe (example from somewhere) that does a save. All this works fine, but I made a change so that the return should send it to a Success page. navigation-rule from-view-id/subscribe.jsp/from-view-id navigation-case from-outcomesuccess/from-outcome to-view-id/success.jsp/to-view-id /navigation-case /navigation-rule I kept getting a 500 error: 12:11:39,292 ERROR [faces]:253 - Servlet.service() for servlet faces threw exception java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? I then created a Success bean @Bean(name=success, scope= Scope.SESSION) @View public class Success { } And then everything worked. Do I always need a View behind my jsp's or am I doing something wrong? @Bean(name=subscrHandler, scope = Scope.REQUEST) public class SubscriberHandler { @Value(#{subscribe}) private Subscriber subscriber; public void setSubscriber(Subscriber subscriber) { this.subscriber = subscriber; } public String saveSubscriber( ) { subscriber.save( ); return success; } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] It is supposed to always be optional to have a backing bean behind a JSP view. Could you please post the entire stack trace for the IllegalStateException you encountered? Craig
Re: [shale] Backing view
Comments interspersed below. On 6/14/06, Marty Phee [EMAIL PROTECTED] wrote: Here you go. Again this is Shale with Tiger. 13:27:47,796 ERROR [faces]:253 - Servlet.service() for servlet faces threw exception java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? at org.springframework.web.jsf.FacesContextUtils.getRequiredWebApplicationContext (FacesContextUtils.java:78) at org.springframework.web.jsf.DelegatingVariableResolver.getWebApplicationContext (DelegatingVariableResolver.java:134) at org.springframework.web.jsf.DelegatingVariableResolver.resolveVariable( DelegatingVariableResolver.java:112) at org.apache.shale.spring.WebApplicationContextVariableResolver.resolveVariable (WebApplicationContextVariableResolver.java:87) at Hmm ... interesting that Spring is involved here too. Are you using the Spring integration to create managed beans from the Spring bean factory? I've tested Spring integration and Tiger-based managed beans separately, but never tried them together. org.apache.shale.view.faces.ViewViewHandler.setupViewController( ViewViewHandler.java:285) at org.apache.shale.view.faces.ViewViewHandler.createView( ViewViewHandler.java:130) at org.apache.shale.tiles.TilesViewHandler.createView(TilesViewHandler.java :184) at org.apache.myfaces.application.NavigationHandlerImpl.handleNavigation( NavigationHandlerImpl.java:145) at org.apache.shale.dialog.faces.DialogNavigationHandler.handleNavigation( DialogNavigationHandler.java:196) at org.apache.myfaces.application.ActionListenerImpl.processAction( ActionListenerImpl.java:84) at javax.faces.component.UICommand.broadcast(UICommand.java:106) at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164) at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication( LifecycleImpl.java:316) at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter( ApplicationFilterChain.java:173) at org.apache.shale.faces.ShaleApplicationFilter.doFilter( ShaleApplicationFilter.java:275) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter( ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke( StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke( StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java :126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java :105) at org.apache.catalina.core.StandardEngineValve.invoke( StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java :148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection (Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket( PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt( LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run( ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595) Succes.jsp !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN HTML HEADTITLERejected!/TITLE /HEAD BODY CENTER TABLE BORDER=5 TRTH CLASS=TITLESuccess!/TH/TR /TABLE H2You have been successfully registered./H2 /CENTER /BODY/HTML I notice that this page doesn't actually have any JSF components in it. Could you try an experiment and add f:view/ (and the appropriate taglib directive) to make this into a JSF page? Craig
Re: [shale] Backing view
On 6/14/06, Marty Phee [EMAIL PROTECTED] wrote: Removed spring and it works. Thanks for the pointer. So, if I use spring you must have managed beans for all JSP's? Not sure if Im actually going to use spring. It appears that this is the effective state of the current implementation. But I consider that a bug -- it should be possible to use this combination of stuff together, without any requirement that a view controller exist for each page. It would help us make sure this gets attention if you could file a bug report documenting your experiences with this, and then note the workaround (removing Spring) that made it work for you in the short term. http://issues.apache.org/struts/ Craig Wendy Smoak wrote: On 6/14/06, Marty Phee [EMAIL PROTECTED] wrote: Here you go. Again this is Shale with Tiger. 13:27:47,796 ERROR [faces]:253 - Servlet.service() for servlet faces threw exception java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? ... org.apache.shale.spring.WebApplicationContextVariableResolver.resolveVariable (WebApplicationContextVariableResolver.java:87) This looks similar to the problems a couple of other people have had when they are not using Spring, but still include shale-spring.jar in WEB-INF/lib. This might help: http://www.nabble.com/Re%3A-Shale-Clay%3A-Are-managed-beans-mandatory-in-xml-view--p1873169.html If you're not using Spring and Tiles, try removing the shale-spring and shale-tiles jars from your application. (Assuming they're in WEB-INF/lib now, but it looks like they are from the stack trace.) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: changing scope of custom JSTL class variables
On 6/14/06, Calvin G. Dodge [EMAIL PROTECTED] wrote: I'm maintaining and upgrading an existing Struts application (written by someone else long ago, with no chance of contacting the authors). I just discovered that our custom tag class variables have global scope - when a tag class (derived from javax.servlet.jsp.tagext.TagSupport) is used, an instance of that class is created - but then reused, rather than having a new instance created every time the tag is used in a JSP page. This puzzles and troubles me - it means that getters and setters are dealing with global values, rather than session values, and could lead to real trouble when we have enough users that 2 or more are using pages with the same tags at the same time. Is there some configuration issue I'm missing? I know that you can declare variable scope for form beans - is there a way to do this with custom tag classes? The lifecycle of custom tag instances (Struts or JSTL or otherwise) is driven by the JSP Specification, and is version dependent. For JSP 2.0, the container is allowed to reuse tag instances ... but it will have called release() on the old usage first. For JSP = 2.0, tag instances are created for each use. Thanks! Calvin Dodge Prosocial Applications, Inc. Craig
Re: how to interact ,servlets with JSF/Shale
On 6/13/06, vivek maheshwari [EMAIL PROTECTED] wrote: hello friends, this is vivek maheshwari currently working on JSF /Shale, i know how presentation Layer(view part) directly interect with model via backing bean, but by doing thing ,i think it 'll break the rules of MVC, that why i want to use servlets as controller, JSF as view and EJB as model classes. But i have no idea how to use it? kindly provide me names of some reference book as well as some links showing examples abt this type of architecture. or help me abt ur views regarding my prob. thanks and regards JSF has a global request processing lifecycle similar to what you see in Struts or other MVC-based frameworks, but it also supports the View Helper design pattern where you have an individual controller (the backing bean) for each view, or page. The role of this backing bean is pretty much the same as an ActionForm+Action in Struts (or an Action in WebWork) ... it's an adapter between the HTTP request and the business logic. For more on this pattern, I'd recommend reading its description from the online pattern repository from the book Core J2EE Patterns: http://java.sun.com/blueprints/corej2eepatterns/Patterns/ViewHelper.html The rest of the patterns in the book make good reading too ... a chart of how they all relate to each other is at: http://java.sun.com/blueprints/corej2eepatterns/Patterns/index.html Craig
Re: [shale] Example with subdialog?
On 6/13/06, Adam Brod [EMAIL PROTECTED] wrote: Hi- I'm having trouble understanding how to use subdialogs. How do I specify the end state for a subdialog that also ends the calling dialog? You'll need to take the outcome value returned by the exit state from the subdialog, and create a transition for that to the exit state for the calling dialog. The documentation mentions some of the possiblities, but doesn't really show how to configure it. Is there a good example somewhere? I looked in the samples I downloaded, but the subdialog isn't included. If I understand it correctly. In the example below (from shale-starter and sql-browser), the subdialog Edit Profile is mentioned, but it isn't in dialog-config.xml. You're right ... if the commented out sample is going to reference a subdialog, then the subdialog should be there too. The actual implementation of the dialog and subdialog from which this was taken is in the Use Cases example, where the subdialog is defined like this: dialogname=Edit Profile start=Setup !-- Global transitioh definitions -- transition outcome=cancel target=Cancel/ transition outcome=finish target=Finish/ action name=Setup method=#{profile$edit.setup} transition outcome=success target=Page 1/ /action viewname=Page 1 viewId=/profile/profile1.jsp transition outcome=next target=Page 2/ /view viewname=Page 2 viewId=/profile/profile2.jsp transition outcome=next target=Page 3/ transition outcome=previous target=Page 1/ /view viewname=Page 3 viewId=/profile/profile3.jsp transition outcome=next target=Exit/ transition outcome=previous target=Page 2/ /view action name=Cancel method=#{profile$edit.cancel} transition outcome=success target=Exit/ /action action name=Finish method=#{profile$edit.finish} transition outcome=password target=Page 1/ transition outcome=success target=Exit/ transition outcome=username target=Page 1/ /action end name=Exit viewId=/usecases.jsp/ /dialog This does a simple three-page wizard with next, previous, finish, and cancel buttons on each page. Thanks for your help. Adam Craig
Re: [shale] downloads
On 6/12/06, Wendy Smoak [EMAIL PROTECTED] wrote: On 6/12/06, Ian.Priest [EMAIL PROTECTED] wrote: Has the shale download site gone down? I can't see any directories under http://cvs.apache.org/builds/struts/nightly/struts-shale/... Sorry for the inconvenience, but we're in the process of converting to Maven 2 and nightly builds should be back shortly. Shale 1.0.2 (Alpha) is listed on the Struts download page: http://struts.apache.org/downloads.html Craig -- can you run the nightly build script on the trunk and upload those files to buy us some time? There haven't been that many changes on the branch. I'll see what I can do in this respect ... more news later. Thanks, Wendy Craig
[Shale] Nightly Builds Resumed
For those of you following Shale, you've probably noticed that there have not been any nightly builds available for the past few weeks. This was due to a combination of circumstances, but the primary reason is we've been focusing on migrating the build environment from Ant-based scripts to use Maven2 instead. When completed, it will be *much* easier to build Shale, or applications based on Shale. However, in the mean time, I'm pleased to announce that creation of nightly builds for Shale have been restored. You can get the 20060612 version from: http://people.apache.org/builds/struts/nightly/struts-shale/ NOTES: * The Shale website currently has a bad link to this page (it points at cvs.apache.org). That will be fixed soon. In the mean time, use the link above. * When the conversion to Maven2 is complete, the organization of the artifacts published as nightly builds (as well as the organization of Shale releases as well) will be changed. Watch here for an announcement of the date that this goes into effect for the nightly builds. Craig McClanahan
Re: [Shale] tiger - abstract base class?
On 6/12/06, Adam Brod [EMAIL PROTECTED] wrote: Hi- I want to define a managed property in an abstract base class using shale-tiger annotations. Then the subclasses can use the same property. You're trying to use @Property on the abstract base class, right? Is this possible? So far, it doesn't seem to work. Jpa allows for mapped superclasses that are abstract, so the same thing would be great in JSF as well. http://java.sun.com/javaee/5/docs/api/javax/persistence/MappedSuperclass.html Because the Tiger extensions processes annotations at runtime, it should actually be able to figure this out without additional annotations. Right now, it only looks at the specified managed bean class itself. Could you please file an issue asking for this improvement? http://issues.apache.org/struts/ Thanks, Adam Brod Product Development Team Craig
Re: Poll: What part of a Struts will be the most important to support for migration?
On 6/12/06, Don Brown [EMAIL PROTECTED] wrote: On 6/12/06, Ted Husted [EMAIL PROTECTED] wrote: On 6/12/06, Don Brown [EMAIL PROTECTED] wrote: Please let us know your thoughts so we can focus on developing tools to make migration as easy as possible. Thanks, My first thought would be how would migrating one part without the others would serve any practical purpose? In some cases, I think so. For example, it might be nice to reuse validator configurations or custom ActionForms. I'm thinking we could support either pretty easily. Struts Actions, on the other hand, are more difficult since they depend on ActionForms, but it could probably be done with a proxy Action and a bunch of parameters. My second thought would be how often would production-applications actually be migrated? That is a good question and one I'm trying to answer here as well. I want to make sure the time spent on migration tools will be productive and user's fears of being left behind are mitigated. Personally, I've migrated my current Struts application to Action 2, but plan to leave the rest alone because, right, if it isn't broken, why fix it. There are also the cases where an existing app is going to be substantially re-implemented, and the natural question will be whether or not to upgrade the underlying framework to take advantage of new features. If SAF2 doesn't even pay lip service to a migration story (which'd be pretty ironic of the lambasting that Shale got over wanting the Struts brand :-), then you're not giving the existing users much incentive to migrate to SAF2 versus any other framework. Don Craig In the field, it seems like that once a Struts application hits production, it continues to use the same version. A new application might use 1.2, but the old ones continue to plug along on 1.1. If it ain't broke, why fix it? -Ted. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Poll: What part of a Struts will be the most important to support for migration?
On 6/12/06, Ted Husted [EMAIL PROTECTED] wrote: And, if we are creating a SAF1 emulator, why not just use SAF1? Let SAF1 handles the *.dos, and let SAF2 handle the *.actions. Having two frameworks to keep track of instead of one, each with their own idiosyncracies and release trains, is not making life better for the engineers that have to maintain that kind of a beast. -Ted. Craig
Re: ActionForm and EJB
On 6/8/06, Dave Newton [EMAIL PROTECTED] wrote: Frank W. Zammetti wrote: On Thu, June 8, 2006 1:09 pm, Michael Jouravlev wrote: On the other hand, the whole idea of Struts/Commons Validator sucks big time, because database already has all necessary validations, domains, triggers, etc. Since most apps use database anyway, input data should either be validated directly by a database or by DAO; DAO should pull metadata from database to build validation/conversion rules. Seems that Ruby on Rails is closer to this approach, while most other frameworks do the same job twice or even three times. I *totally* disagree with this :) +1, and Frank didn't even mention that complex business-model-aware validations most likely _can't_ be done in the database without a pretty robust payer of triggers and stored procs, which are generally DB-specific: I don't want to validate zipcodes for addresses anwhere but at the outer-most levels of the app. I want form validation to be done as close to the form as possible. I want business-logic style validation to be done immediately following generic form processing. DB-level validation (references, etc.) handled last, and preferably the most generic. IMHO, where and how to do what kinds of validations is going to be the next great debate in application framework design :-) I'll sketch below what I believe might be an ideal scenario, starting with a couple of motivating goals: * Enhance the user experience by catching errors as quickly as possible (ideally client side in a webapp), with error messages that are relevant to the user's context in that particular application. * Minimize the number of times I need to specify the same validation in source code, metadata, or whatever. Ideally, every such requirement should be stated exactly once. It's also important to recognize that there's more than one kind of validation here ... the most important distinction being presentation (is the date entered by the user syntactically correct for the locale that the user is interacting with or is this a correctly formatted credit card number) versus business rules (is the invoice date after the customer's account-open date or is this credit card number and expiration date actually valid). Because the database will have date-oriented data already converted to a DATE data type, it doesn't really seem appropriate to specify the presentation style restrictions there (most likely it'd be the same stuff for every single DATE in the entire schema). You've also got to deal with interesting complexities such as fields that are required in some contexts and not others, so you probably want some mechanism to deal with exceptions or overrides of the embedded rules. As to where/how to specify validation rules, using annotations for this (at a couple of different levels) looks like an interesting possibility -- indeed, it was one of the topics that several of the Struts committers who got together at JavaOne this year talked about briefly. One could envision a situation where business logic validations were encoded as annotations on the POJOs representing your persistence tier (JPA entity classes, Hibernate based persistent classes, whatever), while presentation tier validations were encoded on whatever things your presentation framework uses to store the intermediate values (properties on an SAF1 ActionForm, or an SAF2/WW action, or on JSF backing bean, for example). Ideally, your presentation framework would also be able to reach through to the business rule validations of the persistent objects your input forms are bound to, so it could perform whatever business rule validations it was able to on the client side (again, in a webapp world, perhaps by having your input field widgets to AJAX callbacks to the server where necessary). Indeed, this whole concept is relevant beyond just web frameworks ... it would make sense in the long term to have a JSR that standardized a set of validation annotations everyone could share, while giving various frameworks the freedom to implement the semantics of doing the validation in whatever fashion best fits the particular technologies that framework uses. Dave Craig
Re: [shale] - Dialog issues
On 6/7/06, Greg Allen [EMAIL PROTECTED] wrote: Craig, I was gonig to point you at the website page about Dialog, but I can see now it's not particularly helpful :-). There's only one sentence (the very last one) that contains the key bits. Basically, the only current way to enter a dialog is to have some action on a non-dialog page return a logical outcome string of the form dialog:x, where x is the name of the Dialog you want to start. This causes Dialog's version of NavigationHandler to kick in, and transfers control the the starting state. I saw the documentation, but didn't see where it applies to what I am trying to do. So are you saying there is no way to make my Login.jsp page behave as a dialog? Give what you say here I don't see one, but somebody else might... So, you want to start a dialog as the very first thing that the user sees? Right now, the only way to do that is something of a hack, but this should work. * Make the welcome page of your app be a JSF page that has a Welcome to my app ... type banner, with a Command Link component on it that has action=dialog:Log in on it. * Use a bit of JavaScript to programmatically submit the page, which will trigger initiating the dialog to display the login page as part of it. Having a programmatic server side way to do this would definitely be useful, as would a way to trigger a dialog directly for the app's welcome page. But something along the lines above should get you started for now. Thanks for the info. -- Greg Craig
Re: [shale] subviews with backing beans
On 6/6/06, Bahadır Yağan [EMAIL PROTECTED] wrote: Hi. With shale's ViewController a managed bean named index is automatically associated with index.jsp. What I need is to have the same for subviews. Say, I included loginForm.jsp from index.jsp, is it possible to have the same association with my backing bean loginForm ? You should be able to get that service, if you surround the included jsp with an s:subview component: s:subview id=loginForm jsp:include page=loginForm.jsp/ /s:subview The id of the subview should match the name of the managed bean containing the corresponding ViewController instance. I don't know if this is a valid aproach, perhaps clay or tiles has better ways to do the same. Any suggestions? Bahadir Craig
Re: [shale] - Dialog issues
On 6/6/06, Greg Allen [EMAIL PROTECTED] wrote: I am having some problems with the shale dialogs. I have defined my dialogs (correctly, I believe) in the dialog-config.xml as follows: dialogs dialog name=Log in start=login action name=login method=#{account$login.login} transition outcome=authenticated target=Exit/ transition outcome=unauthenticated target=Login Form/ /action view name=Login Form viewId=/tiles/Login.jsp transition outcome=authenticated target=Exit/ /view end name=Exit viewId=/tiles/Homepage.jsp/ /dialog /dialogs However, when I successfully authenticate I don't end up on my home page, but remain on the login page. I found this in the log file: DEBUG http-8080-Processor24 org.apache.shale.dialog.faces.DialogNavigationHandler - handleNavigation(viewId=/tiles/Login.jsp,fromAction=#{account$login.logi n},outcome=authenticated) DEBUG http-8080-Processor24 org.apache.myfaces.application.NavigationHandlerImpl - handleNavigation fromAction=#{account$login.login} outcome=authenticated no matching navigation-case found, staying on current ViewRoot DEBUG http-8080-Processor24 org.apache.shale.view.faces.ViewPhaseListener - afterPhase([EMAIL PROTECTED] 0aa1,INVOKE_APPLICATION(5)) Why is no matching case found? It seems like it should be. That's really odd ... the no matching navigation cases is coming from the MyFaces navigation handler implementation ... but, if you are within a dialog, Shale should never have delegated to the default one in the first place. Are you sure that you correctly entered the dialog (by returning an outcome string of dialog:Log in from some action that was outside of a dialog? Thanks, * Greg * Craig
Re: [shale] - Dialog issues
On 6/6/06, Greg Allen [EMAIL PROTECTED] wrote: That's really odd ... the no matching navigation cases is coming from the MyFaces navigation handler implementation ... but, if you are within a dialog, Shale should never have delegated to the default one in the first place. Are you sure that you correctly entered the dialog (by returning an outcome string of dialog:Log in from some action that was outside of a dialog? Yes, I believe that is my problem. However, this is my login page, the initial page in my application. I get there via jsp:forward page=/tiles/Login.faces/ in my index.jsp page. How do I set this up to enter my Login.jsp as a Shale dialog, so that the right navigation handlers are used? Thanks, -- Greg I was gonig to point you at the website page about Dialog, but I can see now it's not particularly helpful :-). There's only one sentence (the very last one) that contains the key bits. Basically, the only current way to enter a dialog is to have some action on a non-dialog page return a logical outcome string of the form dialog:x, where x is the name of the Dialog you want to start. This causes Dialog's version of NavigationHandler to kick in, and transfers control the the starting state. You can do this directly, for example from a hyperlink: h:commandLink ... value=Start Login Dialog action=dialog:Log in/ or indirectly via the value returned from an action method: h:commandLink ... action=#{backingBean.myaction}/ public class MyBackingBean { // mapped to managed bean name backingBean ... public String myaction() { ... return dialog:Log in; } ... } Craig
Re: [shale] Is there a Dialog Scope?
On 6/5/06, Adam Brod [EMAIL PROTECTED] wrote: Hi- JBoss Seam provides addition Scopes beyond Request, Session, Application and None. In particular, JBoss has a Conversation Scope that stores your data for the duration of a specific conversation. This frees the developer from stuffing data in the session and then manually removing it at the end of the dialog. Does Shale Dialog offer that functionality? I want to configure my bean with Scope=Dialog. It would live for the duration of the dialog, and then to be automatically destroyed by the Dialog Manager. Shale's dialog feature[1] does indeed support this kind of state saving/destroying, although it is not directly treated as a separate scope. Instead, Dialog provides a way for your application to store a context object (in session scope) that stays in existence for the remainder of a particuar conversation with the user, then is thrown away for you. The simplest sort of object to use would be a Map implementation with arbitrary keys. Alternatively, you could construct a context class with properties specific to the particular use case of each dialog. JSF components can be bound to this state object with a standard value binding expression (something like #{state.data.foo} to get to a property or map entry named foo), so your learning about all the techniques you already use to bind components to request scoped objects carries over. Note that there are currently some outstanding bugs in this area of Shale, particularly with respect to having more than one dialog active at the same time (either on the same page, or across windows) -- but the basic functionality works well for a single active dialog. These issues are high on my priority list to get them addressed, because I feel this is mission critical before a 1.0 General Availability release of Shale. Please let me know what I can do. Thanks, Adam Brod Product Development Team Craig [1] http://struts.apache.org/struts-shale/features-dialog-manager.html
Re: [shale] Is there a Dialog Scope?
On 6/5/06, Duong BaTien [EMAIL PROTECTED] wrote: Hello Craig: Could you let us know if you are a part of the proposed Web Beans that combine Shale, Oracle ADF, and Seam? It may even more useful if you can roughly lay out the direction of your vision in this area. I am indeed, in the sense that I worked with Gavin on preparing the JSR submission in the first place, and I am going to be Sun's representative on the Expert Group. My personal vision for this sort of thing is centrally based on the idea that a successful foundation framework should serve as an integration platform for lots of different specialized frameworks, even if those specialized frameworks might have individual implementations of the same functional area. Look at the success of Spring ... a criticial success factor is how the dependency injection framework, used as a foundation, embraces alternative approaches to the same problem areas, because one size does not fit all needs. I would get real nervous if we tried to build a single monolithic architecture that allowed only one blessed approach to each need. For example, you can use Shale, ADF Faces, and Seam today ... by themselves or in any of the possible combinations ... because they all are based on JSF. Yes, there are functionality overlaps ... and that's a good thing. Pick the right combination of technologies that meet the needs of your particular project. So, why standardize Web Beans, then? It's sort of like the early days of web frameworks, when everyone was solving their needs by building their own webapp frameworks. There is enough experience in the world today to raise the base level of functionality provided by the platform. The binding and state management capabilities contemplated in the JSRs will provide solutions to problems that people like me who provide frameworks :-) shouldn't necessarily *have* to build ourselves ... let alone applicaton developers. Of course, even if the Web Beans JSR[1] comes to fruition and is adopted, nothing forces you to use it, or all of it -- any more than using a JavaEE platform application server forces you to use EJBs if you don't want to. But adopting technologies that get standardized does make it more likely that you'll get competitive product offerings from multiple providers (along with tools support) more quickly than might otherwise occur. Thanks BaTien DBGROUPS Craig [1] http://jcp.org/en/jsr/detail?id=299
Re: Struts Editing in IDE
On 6/5/06, Andrè Kapp (AJ) [EMAIL PROTECTED] wrote: All you need is the base Eclipse 3.2 and then MyEclipse on top of that - Standard with MyEclipse is support for Struts 1.0 /1.1/ 1.2, etc... Also included is support for JSF, Hibernate, Proper JSP editor, Database Explorer It wil cost you a license fee of +- $30.00 but it is money well worth spend. Here is the web-site link http://www.myeclipseide.com/ This is really ALL you need Or you could do this kind of thing with NetBeans 5.0 or 5.5 beta, and spend your $30 on more important stuff like beer :-). However, neither of these solutions really addresses the drag and drop request from the original poster. The tools that support Struts have tended to focus on automating creation of the configuration files, and making the process of hand coding JSP pages less painful. If you really want visualization of what your page is going to look like at runtime, from within a tool, you'll likely want to take a look at tools based on JavaServer Faces (such as Sun Java Studio Creator, Oracle JDeveloper, and so on) instead, that provide this capability as a first class feature of the tool. Craig McClanahan
Re: The validwhen validation's treatment of null and empty string
On 6/2/06, Scott Van Wart [EMAIL PROTECTED] wrote: If a bean's property is the empty string , does a test like (property == null) suffice? Or do I have to say ((property == null) or (property == ''))? You need to test for both conditions in the latter case, but the particular approach you suggest above is not necessarily going to work. You cannot reliably do == tests on strings if you are looking for equality -- you need to use the equals() function instead. When faced with the kind of test you're trying to do here, I would suggest the following: if ((property == null) || property.equals()) { ... it is either null or an empty string ... } It is important to do the null test first, because if that test passes, the expression evaluation rules guarantee that the application won't try to evaluate property.equals() as well. That's a good thing ... because that would generate a null pointer exception if property was indeed null. If you want to learn more about Java basics things like this, I would strongly recommend working your way through the Java Language Tutorial[1]. It has concise introduction to language concepts like this, plus it goes over the basics of using many of the common Java APIs. - Scott Craig [1] http://java.sun.com/docs/books/tutorial/
Re: [Shale] How to cancel the s:commonsValidator/
On 5/23/06, James Reynolds [EMAIL PROTECTED] wrote: I'm coding a cancel button on an update form. I've set its immediate attribute to true, but that isn't skipping the client side validation. Is there a way to do this, or must I only use server validation in this case? This sounds like an issue that has been reported previously[1], and resolved as fixed. How recent is the version of Shale you are using? Thanks Craig [1] http://issues.apache.org/struts/browse/SHALE-37
Re: [shale] shale-test compiled for compatibility?
On 5/22/06, Ryan Wynn [EMAIL PROTECTED] wrote: I think this may have been asked before but can someone please make sure that shale-test is being compiled such that it is compatible with jdk 1.4. I am getting some major-minor version errors when trying to run my unit tests against 1.4. Here is the information from my shale-test manifest: Manifest-Version: 1.0 Ant-Version: Apache Ant 1.6.3 Created-By: 1.5.0_05-b05 (Sun Microsystems Inc.) Extension-Name: org.apache.shale.test Specification-Vendor: The Apache Software Foundation Specification-Version: 1.0 Implementation-Vendor: The Apache Software Foundation Implementation-Version: 20060504 Is this from a nightly build? A snapshot release? Are you getting a incompatible class format error, or something different. The nightly builds and the releases are indeed built with a JDK 1.5 compiler (so that the Tiger Extensions module can be compiled) ... but the source and target options for the Test Framework compile are set to 1.4 explicty, so it's supposed to work. Thanks, Ryan Craig
Re: Shale Unit Testing
On 5/19/06, Robert Alexandersson [EMAIL PROTECTED] wrote: Hello. I will start developing a application using Shale, for personal use. This time I want to start the right way, meaning I want to build it Testdriven, or at least creating testcases for it. Are there some exampleapplications that use the Shale-Test-Framework. I saw there are a couple of example apps in the shale-build, so the real question is are there other apps out there using Shale-Testdriven development? Any starting helpers are appreciated. Don't just look at the runtime examples ... look at the source code. The use cases example app, for example :-), includes unit tests that leverage the test framework to exercise the backing beans in the webapp itself. Craig I will also make it using the Clay variant, meaning no logic at all in view. Any pointers here are also welcome! I know there are examples in the examples-app so don't just say look in them. Regards Robert A - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [shale] All SHail hale
On 5/18/06, Hey Nony Moose [EMAIL PROTECTED] wrote: ahem ... Can you guys please take it outside (i.e. offlist) and settle this among yourselves. Please? Nobody else is interested. Craig Dakota Jack wrote: Heh Nony, you are as bright as the other trolls, like Newton, you hang with. you unduly elevate me sir, I am not at all in the league of M. Newton, an honour to be counted as such. you besmirch Herr Newton by entwining his persona with mine. I could care less about appearances, in case you had not noticed. indeed. a remarkable approach to life. not unique, but not frequent. the reserve of outcasts and the filthy rich. congratulations on your brave approach to life. hope it brings you flowers and kittens and blueberry gumdrops. You and Newton are the butt kissers around here. ew! my lips don't leave my face for anyone. I really don't think anyone thinks that I am swooning over anything. whatever you reckon. it's your dream ... I thought what Wendy said was funny. and nothing that anyone one else has ever said on the list was also funny? so in a unique moment in time, someone saying Does everyone live in Portland? Maybe I should live in Portland. lol is the funniest thing you've ever seen written on this list, deserving of immediate repartee? you are noted as a humourless agressor, my man. amicable behaviour from you is immediately conspicuous, and deserved investigation. (no disrespect to Wendy, and apologies for inclusion of your text. you became an unwitting pawn in this notorious list-pariah's interminable maneuvers. i recommend a browse through the archives to see what flavour this dakota jack's mails usually take.) End of story. we wish Are you at all interested, by the way, in the problem discussed here, or are you just dedicated to your office as troll? oh, no. HNM is purely entertainment for the masses (troll, if you wish). and by the way if any of the committers wishes to evict HNM, I'm happy to exit the persona at any time, should it become a nuisance to *real* struts list users. no that's not butt-kissing. it's respect for the community. On 5/17/06, Hey Nony Moose [EMAIL PROTECTED] wrote: Dave Newton wrote: [EMAIL PROTECTED] wrote: Does everyone live in Portland? Maybe I should live in Portland. lol Ooo, and here I was going to suggest controlled explosions to stop the plethora of web frameworks... Never mind. Dave So you're suggesting just one succinct hit, round about ... say ... Portland? While we're at it, can someone trim dakota whatsisface's tree? After that dreadful fawning to Wendy on the back of what I take to be an Oh my God! she's got a harvard email address! thing ... get me a bucket ... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Shale startup - without Spring.
Sorry for the late response ... I'm at JavaOne this week and *very* busy. One thing to ensure is that, if you remove Spring, you also remove shale-spring.jar from your webapp ... it's an optional layer, but if you add that you would also need to add Spring. Craig On 5/16/06, Jason Vincent [EMAIL PROTECTED] wrote: Hi there, Perhaps my error are unrealted, but... I was trying to get get rid of Spring from my classpath - as it is so stinkn huge when it is unzipped. From what I read in the Shale doc'o, spring is only needed if I was instantiating POJO objects outside the JSF config file. So... I tried to eliminate the Spring jars from my classpath. Before I attempted to remove Spring, I would occasionally get some server 500 errors like this... java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? org.springframework.web.jsf.FacesContextUtils.getRequiredWebApplicationContext (FacesContextUtils.java:79) So ... After the removal, at Tomcat startup, I'm now getting: 2006-05-16 08:51:16,703 [main] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/mac] - org.apache.shale.component.Subview javax.faces.FacesException: Can't instantiate class: 'org.apache.shale.component.Subview'. at com.sun.faces.application.ApplicationImpl.newThing( ApplicationImpl.java:728) ... 2006-05-16 08:51:16,718 [main] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/mac] - org.apache.shale.component.Token javax.faces.FacesException: Can't instantiate class: 'org.apache.shale.component.Token'. at com.sun.faces.application.ApplicationImpl.newThing( ApplicationImpl.java:728) ... 2006-05-16 08:51:16,718 [main] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/mac] - org.apache.shale.component.ValidatorScript javax.faces.FacesException: Can't instantiate class: 'org.apache.shale.component.ValidatorScript'. at com.sun.faces.application.ApplicationImpl.newThing( ApplicationImpl.java:728) ... 2006-05-16 08:51:16,796 [main] ERROR com.sun.faces.config.ConfigureListener - One or more confgured application objects could not be created. Check your web application logs for details. 2006-05-16 08:51:16,796 [main] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/mac] - Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener javax.faces.FacesException: One or more confgured application objects could not be created. Check your web application logs for details. at com.sun.faces.config.ConfigureListener.verifyObjects( ConfigureListener.java:1152) Am I missing something from my web.xml file? Thanks, Jason - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [shale] All Hail Shale
On 5/16/06, Dakota Jack [EMAIL PROTECTED] wrote: Dead on, Wendy. Brett lives in Portland, as does Craig, the perpetrator of Shale. For the record, Howard Lewis Ship (original creator of Tapestry) lives in Portland too :-). Craig
Re: UML diagrams of Struts
On 5/12/06, Vaneet Sharma [EMAIL PROTECTED] wrote: How can I get UML diagrams of Struts (specialy the class model diagram) ? There are class diagrams embedded in the package description javadocs for many of the packages that make up Struts ... for example see [1] for the classes in the org.apache.struts.action package. Craig [1] http://struts.apache.org/struts-action/struts-core/apidocs/org/apache/struts/action/package-summary.html
Re: Problems fetching struts-config DTD
On 5/11/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi! I have a Struts webapp with a struts-config.xml that starts with the usual ?xml version=1.0 encoding=ISO-8859-1 ? !DOCTYPE struts-config PUBLIC -//Apache Software Foundation//DTD Struts Configuration 1.3//EN http://struts.apache.org/dtds/struts-config_1_3.dtd; Which version of Struts are you trying to use this with? Since you are asking for version 1.3 of the DTD, then it will need to be at least some version of 1.3 before this would use an internal copy. Struts 1.2.x only supports DTD versions up through 1.2. Craig
Re: Shale: onclick=disabled='true'; not calling Action Method. (stopping double click)
On 5/11/06, Jason Vincent [EMAIL PROTECTED] wrote: Hi all, My project spec is asking me to disable form buttons once they are clicked. It seemed easy to me, just add onclick=disabled='true' to the commandButton. But as anything I've found with JSF, it isn't that easy. When I do this, the action method isn't being called after it passes validation. If I remove the onclick attribute, the form works fine; so I know it isn't a logic failure in the ViewController. I noticed that JSF inserts some of its own onclick logic to the button too. So I thought I'd try to disable the button by using the onsubmit attribute of the form tag. This also had the same behavior. AFAIK, the custom onclick code supplied by JSF is only on the *hyperlink* component (h:commandLink, not on the *button* component (h;commandButton). Are you sure you're not confusing the two? What is going on here? Is disabling the button changing the submitted request parameters? Thinking it through, yes it actually *does* change the submitted request parameters. According to the HTML specification, disabled input controls are *not* included in the request attributes submitted to the server. Therefore, disabling the submit button will mean that the request parameter telling the server which button was clicked is not included -- which means JSF can't tell which command component submitted the form -- which means it has no way to know what action to invoke. I'd look for a strategy involving capturing the *second* click rather than the first one, so you can make sure the original request is submitted with no modifications. Thanks all, Jason Craig
Re: Shale: onclick=disabled='true'; not calling Action Method. (stopping double click)
On 5/11/06, Michael Jouravlev [EMAIL PROTECTED] wrote: On 5/11/06, Craig McClanahan [EMAIL PROTECTED] wrote: On 5/11/06, Jason Vincent [EMAIL PROTECTED] wrote: According to the HTML specification, disabled input controls are *not* included in the request attributes submitted to the server. Therefore, disabling the submit button will mean that the request parameter telling the server which button was clicked is not included Unless Javascript is used for form's data collection and submission. I'd look for a strategy involving capturing the *second* click rather than the first one, so you can make sure the original request is submitted with no modifications. You mean, to resubimit the same request? What is the point? As I understand it, the goal of the exercise is to *prevent* the second submit from occurring, while still allowing the first submit to complete properly. Will not it be the same anyway? Isn't it the task of the business layer to decide what to do with the second submit (say, add CD to the basket then again add CD to the basket to make two of them, etc). Nah, I would not like that. I don't use Struts token feature for the same reason: my buseness rules may allow resubmit as add one more. Seems that Shale (JSF?) uses Javascript anyway, Actually, it's the Command Link component that does this (i.e. when you want a hyperlink to submit the form), because there is no way to implement this at all without using JavaScript. The Command Button component (i.e. a normal submit button) does not use JavaScript. so why not to use it to collect data from the form? It will allow to make sync and async requests to be processed alike. Also, is it possible to lock the server-side bean on a framework level, so it would be guaranteed that the bean won't get second request until the first one is serviced and responded to? Will a simple synchronized do? Synchronizing might work *if* you were talking about the same instance of the backing bean -- but that is not going to be effective if you are using request scoped backing beans. In Struts terms, it would be like trying to synchronize on a property setter of a request-scoped ActionForm -- that will not catch the duplicate submit scenario because each request woud get its own instance. Craig Or maybe to somehow swallow all identical (up to params) requests to the same resource while the resource services the first request? Kind of like Windows compresses several mouse events into one. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] - JSTL Parameter Conventions
On 5/11/06, Kalcevich, Daniel [EMAIL PROTECTED] wrote: Well, I briefly looked at it. It might not be what I am looking for if I cannot use it within my Actions, and not just on the JSP. Like I said, I haven't look at it too much yet though. If you are using JSF 1.1 today, you can execute value binding and method binding expressions programmatically. Code might look something like this: FacesContext context = FacesContext.getCurrentInstance(); ValueBinding vb = context.getApplication().createValueBinding(Hello #{ customer.name} !!!); String result = (String) vb.getValue(context); In a Java EE 5 setting (which includes JSP 2.1 and JSF 1.2), the expression language stuff has been migrated out to a separate package that can be invoked programatically using similar APIs in the javax.el package namespace, even if you're not using JSF. Daniel Craig
Re: Shale: onclick=disabled='true'; not calling Action Method. (stopping double click)
On 5/11/06, Michael Jouravlev [EMAIL PROTECTED] wrote: On 5/11/06, Craig McClanahan [EMAIL PROTECTED] wrote: On 5/11/06, Michael Jouravlev [EMAIL PROTECTED] wrote: Also, is it possible to lock the server-side bean on a framework level, so it would be guaranteed that the bean won't get second request until the first one is serviced and responded to? Will a simple synchronized do? Synchronizing might work *if* you were talking about the same instance of the backing bean -- but that is not going to be effective if you are using request scoped backing beans. In Struts terms, it would be like trying to synchronize on a property setter of a request-scoped ActionForm -- that will not catch the duplicate submit scenario because each request woud get its own instance. Yep, I meant session-scoped beans. JSF is more tolerant to session-scoped beans than Struts, or even prefers them over request scoped. So this might work. Might indeed (although you would still need the server side logic to detect the second submit and ignore it somehow), but I'd likely want to have a client side solution in place too, even if I implemented this, to improve the user experience. IMHO, session scoped backing beans in JSF have the same set of problems (as well as the same set of potential benefits) as session scoped form beans in Struts -- so the same tradeoff decisions apply in both cases. Personally, I try to use request scope for JSF backing beans (i.e. the equivalent of Action+ActionForm, or what WW2 considers to be an action instance) in my apps, and only store session scoped state for cases where I need it for a defined period of time (i.e. the conversational state in a Shale Dialog, for example, where it'll get thrown away for me when the dialog is completed). Craig
Re: [Shale] Dialog statemachine and errorconditions
On 5/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi Having been fiddling around with the Shale dialogs, there is one thing that I feel could be improved on. The way it is now, if there is an error situation or if the user navigates away from a dialog and later on navigates to say the start of the dialog, an exception is raised. There is no way out of this, short of restarting the server. I think a more elegant sultion would be if the state-engine could be queried by for instance the bean that kicks off the dialog sequence. This way one could present a more meaningful and customizeable feedback to the user. That's an interesting idea. Could you please file an Improvement ticket in JIRA to capture this idea? http://issues.apache.org/struts/ Hermod Craig * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This email with attachments is solely for the use of the individual or entity to whom it is addressed. Please also be aware that the DnB NOR Group cannot accept any payment orders or other legally binding correspondence with customers as a part of an email. This email message has been virus checked by the virus programs used in the DnB NOR Group. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Shale's dialog manager is driving me nuts!
On 5/6/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I'm a software architect and we have a major project coming where I thought our dev team should try new things. So I decided to replace Struts (default option :P) with JSF and Shale. I thought that it would be good when I personally know the limits of JSF and Shale first before I put them into our proposal. For this I've written a small app where the user has to input his personal data in wizard style (dialog) but somehow I cannot go further than the first page :( No errors or exceptions or something but the first dialog screen keeps opened again and again. I tried to understand what goes on in the Shale's usecases example app (the login and profile creation is also a dialog) and mostly copy/pasted the dialog-config.xml, the jsps and backing beans (I couldn't get the usecases login part to run btw) but with no luck :'( Then I thought my lone wolf time is up and I should go and ask someone smarter ;) Good plan :-). One issue that often bites newbies to JSF (whether or not you use Shale) is that the existence of any validation errors on a submitted page will cause the input page to be redisplayed -- but if you have no way to see the error messages, you don't know why that happened. Try putting an h:messages component in your page (set to display all messages for all input fields) and see if that helps. Craig
Re: [Shale-Clay] Offline dtds
On 5/5/06, Ryan [EMAIL PROTECTED] wrote: I seem to have a problem with running Shale-Clay offline because there seems to be a few dtds that need to be downloaded for validation purposes I assume. I was just wondering if there are plans for an Entity resolver to help with the resolution of the dtd to a local one. :) Clay uses Digester for parsing clay-config.xml files, and it already registers a local copy of its DTD. As long as you are using the correct public ID (and you don't have a broken XML parser :-) it should work fine offline (and it does for me on they Use Cases example). Make sure you're using exacly this: -//Apache Software Foundation//DTD Shale Clay View Configuration 1.0//EN Thanks, Ryan Craig
Re: [Shale-Clay] Offline dtds
On 5/5/06, Ryan [EMAIL PROTECTED] wrote: I love the response time on this list. :) Thanks for the tip Craig. I had an old version of the public id -//Apache Software Foundation//DTD Shale Clay View//EN Is there a wiki I can post this info on for others? That would be very helpful. We share the same Wiki infrastructure that the rest of the Struts community uses. You could start at [1] and either find an existing page of helpful hints, or create a new one. Thanks, Ryan p.s. I was wondering if any of the Shale team would be at JavaOne - I looked at the schedule and didn't see any. Don't I count? :-) I'm a speaker on two different sessions (TS-4372 - panel discussion on AJAX/Web 2.0/SOA, Tuesday @ 11:00, and TS-1887 - EJB 3.0, Java Persistence API, and the Web Tier, Friday @ 10:45). Of course, I'll certainly be at the Struts session on Wednesday (TS-3682, 2:45pm) and a bunch of the other web and AJAX sessions. I think Gary is also coming as an attendee. Craig [1] http://wiki.apache.org/struts/Shale
Re: How long does it take the message to appear on the list.
On 5/4/06, Vikas Phonsa [EMAIL PROTECTED] wrote: Hi Everybody, How long does it take the message to appear on the list? I posted a message about 2 hrs ago but haven't seen it yet on the list. One possible explanation for this behavior would be if you posted the message from an email address that was not subscribed to the mailing list. Such posts are sent to a human moderator, who must accept the posting before it appears on the list. Thanks Vikas Craig
Re: Two mysteries: ;jsessionid and bad img tag
On 5/4/06, Bryce Nesbitt [EMAIL PROTECTED] wrote: I've just been gifted with a struts application to maintain. Things are pretty good, but here are two little mysteries I need a little help on. The struts jsp looks like: tdhtml:link page=/html:img page=/images/logo.gif alt=XX width=326 height=111 hspace=0 vspace=0 border=0 //html:link/td And the resulting HTML is like this: tda href=/;jsessionid=XXXimg src=/images/logo.gif height=111 width=326 border=0 hspace=0 vspace=0 alt=XX/a/td Why the ; in the jessionid, instead of ? The servlet spec requires that the session identifier be a path parameter rather than a query parameter. In the syntax of a URL, you can actually add path parameters after any element of the path ( http://localhost:8080/foo;bar=baz/bop), but the session id goes on the last one. And why is there no / at the end of the img tag, which is inconsistent with the rest of the XHTML markup. Which version of Struts are you using? I vaguely recall problems like this in the very early ones, but not more recently. These two small issues annoy the Tidy HTML validator in Firefox, http://users.skynet.be/mgueury/mozilla/ It may be that the validator needs to be made to understand what a path parameter is. Visit http://www.obviously.com/ Craig
Re: Where dose JSP works in JSF request lifecycle?
On 5/3/06, 王曾wang_zeng [EMAIL PROTECTED] wrote: Oh,yeah,I see, that's why you use new keyword in the code above. private HtmlOutputText dynamicText = new HtmlOutputText(); Then,I have a pretty weird idea. If you dosen't new a HtmlOutputText,will there be a NullpointerException popped up in this case? No ... if the getter method returns null, the tag handler will create a new component instance, just as if you hadn't declared a binding attribute ... but then it will call the setter so your backing bean still has access to the component instance actually being used. -- Wang Zeng Craig
Re: Where dose JSP works in JSF request lifecycle?
On 5/3/06, 王曾wang_zeng [EMAIL PROTECTED] wrote: But the prerender() is called before the tag being processed. when the prerender() is called, the reference is still null if this is an initial request. Tree hasn't been constructed, when the prerender() is called. I guess maybe if I want to set a initial value of a component when the page is viewed the first time, the reference to the component must be assigned using a *new* keyword. Not quite. IF you use a binding attribute on your component, AND IF the getter method on your backing bean returns a component instance that has been previously configured (in the backing bean's prerender() method), THEN the component tree will include *your* instance instead of creating a new one. The nitty gritty details of how this works are found in Section 3.1.5 of the JSF 1.1specification. Craig
Re: Where dose JSP works in JSF request lifecycle?
On 5/2/06, 王曾wang_zeng [EMAIL PROTECTED] wrote: Graig, that's very kind of you. Are these aproachs feasible,when the page is requested by an inital request? When an inital request arrives, the view restoring phase is skipped and JSF goes to the response rendering phase directly. Then there should be no component tree constructed at all ,when prerender() is called. I wonder how can we access the component when they have not been constructed? Yes, both approaches work even in this scenario. In the first approach (component binding) the rules for creating the component tree the first time (which would occur during Render Response phase) are very specific -- *if* the component has a binding attribute, call the getter method, and *if* it returns a component, then use that instance in the tree instead of creating a new one. Thus, the component you have defined in your backing bean is the one that will be used. For the second approach, you do not actually care about which component instance is used -- what you care is that the bindings point at the data you want to manipulate. So, it works the first time or subsequent times as well, since the binding expressions point at your backing bean's properties. Craig -- Wang Zeng
Re: Where dose JSP works in JSF request lifecycle?
On 5/1/06, 王曾wang_zeng [EMAIL PROTECTED] wrote: 2006/4/28, Craig McClanahan [EMAIL PROTECTED]: You are correct. There is special handling defined in the Restore View phase. If that phase discovers that there is no state to be restored , then JSF will immediately forward to Render Response phase. So, how do you make sure that the right dynamic data gets loaded so that the page displays the right stuff? That's where Shale comes in handy. If your backing bean implements the ViewController interface, then prerender() will get called just before the JSP page is invoked. This is the perfect place to grab any data you need from your database to display the requested page. Craig Craig, When the page is first viewed,If I want to dynamically set the inital value of the property of the UI component (for exsample, text of a textbox), how can I set the value of it. Even if I crab the data in prerender() method, how can I get the reference to the component without a tree in session, when Restore the View phase is skiped. Two approaches to this are fairly common. * Use the binding attribute to bind a component instance into your backing bean, which will get used when the component tree is actually constructed: h:outputText binding=#{backing.dynamicText} .../ public class Backing implements ViewController { private HtmlOutputText dynamicText = new HtmlOutputText(); public HtmlOutputText getDynamicText() { return this.dynamicText; } public void setDynamicText(HtmlOutputText dynamicText) { this.dynamicText = dynamicText; } ... public void prerender() { dynamicText.setVaue(Dynamically calculated value); } } * Use the value attribute to bind the component's value property to a string property of your backing bean h:outputText value=#{backing.dynamicValue} .../ public class Backing implements ViewController { private String dynamicValue; public String getDynamicValue() { return this.dynamicValue; } public void setDynamicValue(String dynamicValue) { this.dynamicValue = dynamicValue; } ... public void prerender() { dynamicVaue = Dynamically calculated value; } } The first technique is convenient when you need to dynamically calculate more than one property of the component (just make sure you don't also try to set the corresponding attributes in the JSP page). The second technique is simpler when you just want to dynamically bind the value property, and also makes it a bit easier to build unit tests for the backing bean class. -- Wang Zeng Craig
Re: Where dose JSP works in JSF request lifecycle?
On 4/27/06, 王曾wang_zeng [EMAIL PROTECTED] wrote: Thank you,Craig. What do you mean by setup action? Is that the kind of action which grabs some data, do some encapsilation work, and stuff them into JSP scopes. Yes, that's what I meant. You say we can archive the goal with shale as well as without shale. I remeber that between phases a Phase Event will be fired. When JSF skips directly to the Render Response phase, can I use phase event listener to grab data ? Yes. The way to do this would be to define a phase listener for Render Response phase, and do your data collection in the beforePhase event handler. You also have to remember that your listener is going to receive beforePhase() calls for *all* simultaneously active requests, not just the one page you might be interested in. And, don't forget to deregister yourself as a listener when the request completes, so you don't create a memory leak. Is this approach what you think is painful? I don't know if I would call it painful, but it is certainly a lot of complexity to worry about. It is much simpler to have a framework do the hard stuff for you. Indeed, a phase listener is how Shale itself calls the relevant application event calbacks -- but it shares a single listener instance across all requests, and only makes the callback calls on the relevant backing bean -- you don't have to worry about anything except what data do I need to set up for *this* request. -- Wang Zeng Craig
Re: Where dose JSP works in JSF request lifecycle?
On 4/28/06, Bernhard Slominski [EMAIL PROTECTED] wrote: So, how do you make sure that the right dynamic data gets loaded so that the page displays the right stuff? That's where Shale comes in handy. If your backing bean implements the ViewController interface, then prerender() will get called just before the JSP page is invoked. This is the perfect place to grab any data you need from your database to display the requested page. You can do this without Shale, but there's somewhat more pain involved. So how would you do it in plain JSF without the ViewController? In the contructor? The constructor logic is going to get called on a postback as well as when a page is rendered, so you would need to distinguish the two cases. You also would not want to do the data setup if you're actually going to havigate to a different page instead. See my previous answer in this thread about using a phase listener. Bernhard Craig
Re: Where dose JSP works in JSF request lifecycle?
On 4/28/06, Hubert Rabago [EMAIL PROTECTED] wrote: On 4/28/06, Craig McClanahan [EMAIL PROTECTED] wrote: Yes. The way to do this would be to define a phase listener for Render Response phase, and do your data collection in the beforePhase event handler. You also have to remember that your listener is going to receive beforePhase() calls for *all* simultaneously active requests, not just the one page you might be interested in. And, don't forget to deregister yourself as a listener when the request completes, so you don't create a memory leak. Craig, What do you mean deregister the listener? Where is the leak from? My understanding was I register the the PhaseListener in faces-config, and the listener is active for the entire life of my application. Sorry for not being clearer. You can indeed register a listener with a phase-listener declaration -- you get an application wide singleton that has the same lifetime as your application. However, it's also possible to add a phase listener programmatically, by getinng access to the Lifecycle instance (from the LifecycleFactory), and calling addPhaseListener() on it -- the standard JavaBeans event listener registration pattern. You might, for example, want to create a request scope backing bean that registers itself for phase listener events just for the duration of this request (you still have to disambiguate whether the event is for your request or not -- easiest way to do that is to compare the FacesContext instance included in the event to the one that was active when your backing bean was created). If you do this, but don't remember to deregister at the end of the request -- and you need to be robust in case exceptions were thrown -- then the list of phase listeners will get longer and longer. And, because there are live references to them in the Lifecycle instance, they would never be garbage collected either. In the very first version of Creator, we were experimenting with request scoped phase listeners like this, and found it easier to use the single instance approach instead. Shale's design benefits from that experience as well. Hubert Craig
Re: Where dose JSP works in JSF request lifecycle?
On 4/28/06, 王曾wang_zeng [EMAIL PROTECTED] wrote: 2006/4/29, Craig McClanahan [EMAIL PROTECTED]: You also have to remember that your listener is going to receive beforePhase() calls for *all* simultaneously active requests, not just the one page you might be interested in. And, don't forget to deregister yourself as a listener when the request completes, so you don't create a memory leak. The Faces servlet acts like the Action servlet, and every request goes to it to go through the 6-phase lifecycle before they are forwarded to the JSP. Is that the reason why my listener receives beforePhase() calls for *all* simultaneously active requests? Nor really. The actual reason is that the object you are adding your listener to (the Lifecycle implementation for this webapp) is an application-wide singleton. It's execute() and render() methods are the ones that actually trigger the events, and they are called for all requests. I should also note that JSF 1.2 adds a significant simplification for phase listeners ... you can attach per-view listeners by registering them with the UIViewRoot at the base of the component tree for this particular view, and a lot of the complexity described above gets reduced. Craig
Re: Where dose JSP works in JSF request lifecycle?
On 4/27/06, 王曾wang_zeng [EMAIL PROTECTED] wrote: In JSF, when a request arrives, it should go through 6 phases to process the request. The first stage is called Restore the View , and the last stage is called Render the Response. I wonder where JSP works in these 6 phases. If JSP only works in the last phase, Which is, indeed, exactly how it works. how can JSF restore the view first time the user view the page with no existing component tree in the session, because the information about the definition of the tree resides in the JSP by the form of JSF tags. So I think maybe both the *Restore the View* and *Render the Response* need JSP to be involved. You are correct. There is special handling defined in the Restore View phase. If that phase discovers that there is no state to be restored (either because this is an initial request for the welcome page, or because this is a GET request for some other page accessed via a redirect or a bookmark), then JSF will immediately forward to Render Response phase. So, how do you make sure that the right dynamic data gets loaded so that the page displays the right stuff? That's where Shale comes in handy. If your backing bean implements the ViewController interface, then prerender() will get called just before the JSP page is invoked. This is the perfect place to grab any data you need from your database to display the requested page. You can do this without Shale, but there's somewhat more pain involved. Better to have the framework tell you Hey, I am about to render this page, do you need to set up any state?. In a Struts 1.x world, this corresponds to the kind of stuff you might do in a setup action. -- Wang Zeng Craig
Re: [shale] any public binary release available?
On 4/26/06, Ryan Wynn [EMAIL PROTECTED] wrote: Just wondering if there is anywhere I can get a binary release of shale. I looked at the release plans on the wiki for 1.0 and 1.0.1 and didn't see any checkmarks under GA. The current release was graded alpha because of a dependence on an unreleased component (Standalone Tiles) and known incompleteness in the Dialog feature. There's a chart showing the stability ratings for the various APIs in Shale[1], and I would not feel shy about starting to rely on the more stable ones like ViewController ... it is not going to change in incompatible ways. Thanks, Ryan Craig [1] http://struts.apache.org/struts-shale/api-stability.html
Re: Tiles vs. jsp:include + XHTML/CSS
On 4/25/06, Michael Jouravlev [EMAIL PROTECTED] wrote: On 4/25/06, Greg Reddin [EMAIL PROTECTED] wrote: if I have a composite page out of three JSP files, how would I run their corresponding setup actions before the page is composed? Instead of including JSP pages I would include Struts actions (Will it work with Tiles? I haven't tried it yet) like this (seems that I can use include directive instead of dynamic include tag here): The thought scares me :-) I haven't tried it like that. Tiles used to allow you to specify a Struts action as a controller. It probably still does but I haven't used that pattern in a long time and I can guarantee that Standalone Tiles will not support that. I don't see why Tiles would care what kind of resource I want to use to compose my page. At the higher abstraction level, I want to provide a URL, and Tiles should obtain response generated by resource at this URL, be it JSP fragment or Struts action or whatever else. You should really check out the Controller interface. Sorry, the documentation is non-existent currently, but it's in the pipeline. It allows you to specify a controller class that will be executed before the definition is rendered. In that class you have access to the Tiles Context and whatever else you need. The only drawback is that I don't believe you can specify a controller for each piece of the composite page. Having one controller is better than having nothing. According to the APIs, it is actually one Controller per Tile, not one Controller per page ... doesn't that give you (Michael) the hook you'd need to grab the dynamic data for each fragment? Craig Consider this. Say, most fragments do not contain dynamic data, like static header or footer. I can use Tiles or I can use two JSP includes in a separate file, and include this file. Same thing? Now, I have header and footer, and both require dynamic data from database. Who is going to pull it out? Apparently, Struts action. Which one? You said I can specify one controller. So this controller should know that it pulls data for two specific fragments. Now I have a controller tied to two fragments. Is this a good programming practice? What if I later decide to add, say, an advertisement block? Should I modify the controller to pull info from the database with ads as well? What if I want to use this ad block only on some pages. Should I have two different controllers? See, this is what I am talking about. Tiles combines view sections, not components. The point I am trying to make, it seems to me that Tiles helps with composing a page from simple subviews. But when a subview requires dynamic data, Tiles does not really help. With Tiles, actions and JSP fragments are separated. There are mostly independent JSP fragments, there are controllers (one per page), there are input actions, that process submitted data. This arraingment does not seem observable and manageable to me, contrary to what Rick and you say. Maybe I am missing something. Please excuse me if I sound pushy, I just really try to understand the benefit of Tiles. But returning back to my original question, I did not intend to badmouth Tiles and to push my own ideas. I just asked, how Tiles compares to XHTML+CSS. As I understood, the major Tiles benefit is handling dynamic data, and encapsulating it in one single place like definition file. But my example with dynamic data from database seems to show that this setup is not possible with Tiles, Struts actions must be involved. Therefore, for static headers/footers regular JSP includes seem fine. On the other hand, if I have highly dynamic data for every fragment, I need to call respective setup actions, and it is not possible with Tiles right now. As you stated, I can have only one controller per definition. In both cases, Tiles is either on par with JSP includes, or has some serious constraints. What am I missing? Michael. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tiles vs. jsp:include + XHTML/CSS
On 4/25/06, Michael Jouravlev [EMAIL PROTECTED] wrote: On 4/25/06, Craig McClanahan [EMAIL PROTECTED] wrote: According to the APIs, it is actually one Controller per Tile, not one Controller per page ... doesn't that give you (Michael) the hook you'd need to grab the dynamic data for each fragment? I guess it does. But how is this better/different than simply including Struts actions or any other resources? I found a pointer to Cedric's old web site[1] from the days before Tiles was contributed into Struts. The advanced features link there has some extended discussion of controllers (as well as a bunch of the other features of Tiles). Also, can I submit to a particular controller? Does a controller have URL? Sort of. You can define the logic that implements a controller either as a Java class that implements Controller, or as a Struts Action. But I think it's simpler to think of the execution of the Controller as a side effect of invoking the Tile's URL, immediately before the Tile is rendered. Thinking of it this way means you don't have to consciously map one kind of URL for Tiles that have controllers, and a different type for Tiles that don't. Use the URL of the Tile, and the right logic will get automatically invoked, if that particular Tile needs it (i.e. if there is dynamic data to go collect). By the way, the Tiles Controller was one of the inspirations for Shale's ViewController, where the prerender() callback is used for exactly the same sort of thing. I guess I have to go read the docs one more time. Please excuse me for heating up the discussion without checking the facts. Michael. Craig [1] http://www.lifl.fr/~dumoulin/tiles/
Re: How dose JFS deal with multi-threads
On 4/23/06, 王曾wang_zeng [EMAIL PROTECTED] wrote: Thank you, Craig. If we preserve the tree on the server, then the tree sholud be saved in session scope. If we don't save the tree on server, then everytime a request arrives, the tree should be reconstructed using the value of the hidden field. Am I right? That is correct. Note, however, that you do not need to change anything about how you actually *use* the components in your application. The setting is changed with a context initialization parameter only. Craig
Re: [Shale] AbstractViewController for Dummies
On 4/24/06, James Reynolds [EMAIL PROTECTED] wrote: My understanding of the JSF lifecycle is a bit tenuous. As a result, I'm confused about the proper use of init(), preprocess(), and prerender(). Thus far, I've just been using init() and destroy() to handle the creation and closing of Connections and other minor duties because they have just worked for what I needed. Now, I'm moving on with some more complex pages and I want to be sure that I'm leveraging the AbstractViewController for all it's worth. The documentation does a good job of explaining when and under what conditions the events are fired, however, my weakness is that I just don't know what kind of jsf programming events to stuff in each one. If I have a component that uses select items (that don't live in the application or session scopes), should I build them in init() or prerender()? These are the kinds of questions I wrestle with. That's a really useful question to help you understand the differences. The short answer is either of these will technically work. Some help, huh :-). But there is an important difference in behavior that can help you choose. * The init() method is *always* called if this view controller is ever instantiated. * The prerender() method is *only* called if the corresponding view is actually going to be rendered. If you have navigated to some different page, the prerender() method on *that* page's view controller will be called instead of this one. That can save you from having to do a bunch of expensive database queries that you do not need. So, one way to look at what event method should be used for what kind of application logic is to consider the following two questions: (1) Do I need the results of this computation in order to process a form submit? (2) Do I need the results of this computation in order to render the page? Based on the anaswers, I would suggest sorting things out like this: * Use init() for (1) and (2) * Use preprocess() for (1) only * Use prerender for (2) only And, you can always put any necessary cleanup code in destroy(). So, what's the answer for the use case you just described? It turns out that init() is actually the correct answer -- because when you the form for this view, the UISelectOne or UISelectMany component performs validation on the input value(s) against the set of select items that are defined. If you are not storing the items in session or application scope, then you will need to reload them in order for these validations to not fail. On the other hand, if you *did* have the select items in session or application scope, then you could move the logic to prerender() and only spend the effort to accumulate the items list the first time it is rendered. An actual issue that I'm working through now is this: I have a page that lists 'Contracts'. If the user clicks one, the plan is to navigate to a detail page, with the Contract's id number stored in the parameter map. The detail page's backing bean needs to instantiate a Contract object based on the id value, but do I do that in the bean constructor, the init() or the prerender() methods? Does the detail page itself have a form that can be submitted back in again? If so, then init() would be the right place -- by the same logic as above (you need it for both form processing and rendering). If the page just has navigation links, prerender() would work. Any advice would be appreciated. Thanks Craig
Re: [Shale] AbstractViewController for Dummies
On 4/24/06, Wendy Smoak [EMAIL PROTECTED] wrote: On 4/24/06, James Reynolds [EMAIL PROTECTED] wrote: I printed your answer and hung it on my cubical wall, where it will continue to help me in the future. We have a more visible place for these gems. :) * http://wiki.apache.org/struts/ShaleCoreLibrary Thanks ... you're quick! I really was thinking about doing just that, but had a con call right after I finished typing the response to James's question :-). -- Wendy Craig