Re: struts2 and tiles
On 31/01/2009, at 6:23 AM, Tom Pop wrote: Hello, please, can you show me on this example how to convert tiles from struts1 to struts2? This example defines localized page title attribute passed to template in struts1: bean:define id=messages name=%= org.apache.struts.Globals.MESSAGES_KEY % type=org.apache.struts.util.MessageResources/ bean:define id=locale name=locale type=java.util.Locale scope=session / % String docTitle = messages.getMessage(locale, page.title); % tiles:insertDefinition name=layout-main tiles:putAttribute name=document-title value=%= docTitle % / /tiles:insertDefinition Tiles2 is used the same way in Struts 2 as in Struts 1. Include the tiles dependencies and its listener and the insertDefintion tag will work within a JSP as you'd expect. Include the tiles plugin for improved integration (eg. tiles result type). What you DO need to change in your example is the use of bean:define and the inline scriptlet which are unrelated to Tiles and unnecessary in Struts 2. Reading one of the articles about upgrading from Struts 1 to Struts 2 will help you understand this (plus the Struts2 pages on i18n). Hope that helps, Jeromy Evans - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Problem with Dojo in struts2
On 29/01/2009, at 6:36 PM, Srikanth Goud wrote: Hi, I am presently working on struts 2.0. Whenever i use strutsUI tags(with theme=ajax) nothing is rendered on page. Have a look at the source of the page to see what's rendered. Is it the page you expected and does it contain javascript to load Dojo? If not, then it's a configuration simple configuration error. If it's there, can you please test it in Firefox with the FireBug plugin installed? That plugin allows you to inspect the requests (and many other useful things) and my guess is it's failing to find the Dojo javascript files, and so failing to initialise. If it made the requests okay, check if it requested any html that was accidentally decorated by Sitemesh (and became invalid). You may need a no-decorate setting on /struts/* (I can't recall what Tree uses) Finally, is the tree supposed to contain anything? Your example doesn't provide sufficient attributes. Also don't do too much at once; ensure sitemesh works, then tiles works, then that the widgets work. Hope that helps a little, Jeromy Evans - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [s2] rest plugin and rss output with Rome
On 29/01/2009, at 2:48 PM, Dave Newton wrote: Bill Stilwell wrote: To me, this implies that there needs to be code to map whatever the particular model is to the needs of the RSS feed. Well yeah. I think maybe I'm just completely misunderstanding what your system looks like. The systems I've worked on tend to have a pretty orthogonal type hierarchy that makes doing things like this trivial-- it's been only a rare occasion when I've had to convert a slew of completely different types into one format. Dave Hi Bill, Two other options: - (preferred) define a binding (annotations/xml) that can map the properties of your model(s) to a SyncFeed instance. The ContentTypeHandler performs the mapping and returns a SyncFeed. I'd be surprised if a binding implementation doesn't exist already. - If the resource is always a SyncFeed, then don't try to pretend it's not. eg. Have your action mapper direct the request to a different controller to create the alternative model. regards, Jeromy Evans - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: IE ajax theme form data problem
Try turning off the loading text. It's a guess, but it sounds similar to the loadingText bug due to Dojo in IE. If the target div contains the source form and loadingText enabled, the loadingText overwrites the form before the its new values are read. Details are mentioned several times in this mailing list. On 29/01/2009, at 3:50 PM, Robert Dietrick wrote: Hi, I have a page which uses a tabbedPanel with three tabs. In each of the three tabs, I load a separate div: s:tabbedPanel id=profileTabs s:div id=profile_personal label=Personal href=%{viewProfileUrl} theme=ajax cssClass=tab/s:div s:div id=profile_privacy label=Privacy href=%{viewUserPrefsUrl} theme=ajax cssClass=tab/s:div s:div id=profile_game_prefs label=Game Prefereces href=%{viewGamePrefsUrl} theme=ajax cssClass=tab/s:div /s:tabbedPanel In each of the tabbed divs, there is a form which uses the ajax theme and targets the div in which the for resides. E.g., s:form action=updateProfile theme=ajax s:textfield name=user.firstName label=First name / ... s:submit theme=ajax targets=profile_personal value=Save / /s:form Under IE (6 7), when I modify the data in the form fields and submit the form, somehow the original form data (before my modifications) is being sent to the server. Has anyone seen this before? Thanks. -rob - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Embedded Maps as arguments
On 27/01/2009, at 4:57 AM, Matthew Seaborn wrote: As I have grid of checkboxes I am currently trying to use embedded maps as arguments in Struts 2, for example using @CreateIfNull( value = true ) @Element( value = HashMap.class ) public MapInteger, MapInteger, Boolean getTestMap() { return testMap; } Using /testAction.action?testMap[1][2]=true Although it places the value in the right place, it is always ognl.noConversionPossible Hi Matt, I haven't tried this myself, but I'd take the following steps to try to isolate it: 1. instantiate the empty map of maps yourself prior to the params getting set. Erasure may be preventing OGNL from instantiating the inner map because it can't determine the type. 2. I'd try quoting those numbers so it's unambiguous that it's addressing an entry and not an index. Shouldn't matter though, but I don't trust it.
Re: Struts 2: What do i need to do to be able to upload files
ryan webb wrote: Thanks for your kind reply but I have commons-fileupload-1.1.1.jar and commons-io-1.2.jar in my lib folder. With those jar files included, doesn't that mean that I should be able to do file uploads automatcally? Yes. The unable to load bean MultiPartRequest (jakarta) message implies there's still a configuration problem though. Is there a caused by in the stack trace? You must be very close. Can you change the name of your file field to something else, say upload. Your action should then have the setters: void setUpload(File file); void setUploadFileName(String fileName); void setUploadContentType(String contentType); That's slightly different than your quoted configuration (as calling the File file implies there should be a setFileFileName method). That shouldn't cause a 500 error though. On Thu, Nov 20, 2008 at 2:56 PM, Jeromy Evans [EMAIL PROTECTED] wrote: ryan webb wrote: Hello, first I would like to thank you for reading my email. I am trying out some examples for uploading a file. And I always get HTTP 500 error from tomcat. I can't see why, I followed and copied the example. For sure I missed something but I don't know what? I tried debugging but I failed because IDE don't enter the execute() method. Ensure you have included the add on dependencies described here: http://struts.apache.org/2.x/docs/file-upload.html There are good examples and explanations for Struts 2.0.x and 2.1.x on that page. - 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: Problem customizing dojo
Pablo Vázquez Blázquez wrote: Hi all! I have followed the instructions in http://cwiki.apache.org/S2WIKI/creating-a-custom-dojo-profile-for-struts-20x.html, with a dojo-0.4.3 release. Now, my s:datetime tags don´t work, neither the images of a tabbedpannel are loaded. Any idea? Thanks. If the datetime tags don't work, you're probably missing the nls directory that contains the locale-dependent information created by dojo. If the images are missing, you probably forgot to copy something out to your static path. Your directory structure must match step 6. Firebug will tell you what its looking for and where they should be. There struts tags in 2.0.9(ish) are for dojo 4.0.0, not 4.0.3, so there may be some API conflicts that you simply cannot work-around. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Use Same JSP Page For Several Modes (View, Edit, Approve, Create)
Alberto Flores wrote: The way I did was to override the backing components of the struts tags. I added logic there to simple control which template is used (depending on the role). I felt that I could use the Components (and Tag objects) as controllers for this purpose. I've taken a similar approach. The Component and/or component templates check the mode/role/etc from the context and/or parameters. With this approach, I can create one page that contains, say a form, and the mode of the form (view/edit/edit) and buttons depend on the context. It's not generic though. I also use Tiles and substitute tiles based on the context (eg. role/theme). The Tiles Kaolin project aims to provide a consistent solution to this common problem: http://wiki.apache.org/incubator/KaolinProposal - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Form submitted twice (no AJAX!)
Milan Milanovic wrote: Hi, I have a simple jsp form: head s:head theme=ajax debug=true / /head s:form action=showReport namespace=/reports validate=true snip And when user click submit button, this form get submitted twice, i.e. showReport form action method is called twice! I'm NOT USING AJAX here, I DON'T HAVE ANY Javascript functions in this page. You DO have javascript in your page and you ARE using ajax. s:head theme=ajax instructs struts to include the dojo javascripts, and sets the default theme to ajax. s:form ...valudate=true instructs struts to include client-side javascript validation (or possibly ajax validation; I can't recall if that requires the theme on the form itself or not). Viewing the source of your page would tell you this. Firefox with Firebug will tell you what's happening. Clean it up and see how you go. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 2: What do i need to do to be able to upload files
ryan webb wrote: Hello, first I would like to thank you for reading my email. I am trying out some examples for uploading a file. And I always get HTTP 500 error from tomcat. I can't see why, I followed and copied the example. For sure I missed something but I don't know what? I tried debugging but I failed because IDE don't enter the execute() method. Ensure you have included the add on dependencies described here: http://struts.apache.org/2.x/docs/file-upload.html There are good examples and explanations for Struts 2.0.x and 2.1.x on that page. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2 OGNL Problem
PhoenixelRay wrote: I tryed it like this s:iterator value=%{#attr.myListAttribute} with the same Problem. tiles:importAttribute places the object into page scope if not specified otherwise. This means in OGNL it's only available via #attr. First, confirm you can access the attribute from JSP EL and that's the object is type that can be iterated over. Then s:iterator value=#attr.myListAttribute will definitely iterate over it. Within your sample code you referenced #item but that doesn't exist. When inside the iteration, the top of the stack is the item being iterated over, so s:property value=link/ will get the property name link of the current item, and so on. Hope that helps, Jeromy Evans - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tabbed panel performance
Pablo Vázquez Blázquez wrote: Any idea about why am I getting increasing response times each time I access to the page? I have already a great response time the first time I access to the page (which is also a problem), but my main problem is that after 6 or 7 accesses it in unmanageable... Thanks! I don't recall the 0.4 dojo tabbed panel being particularly slow to render, other than the extreme initial page load while Dojo makes too many http requests. I can't think of any reason why it would get slower after a genuine page reload with the same content (if it's reloading via ajax though, then there's a good reason). The reload problem is not evident in the showcase: it's consistently unbearably slow for each reload at planetstruts. Dojo parses your html for widget markup, so it there's a lot of mark-up inside the tabs it's going to be slooowww (such as tables). Whenever I had a dojo problem I created a simplified page of html with just the one widget on it to isolate the cause. You're putting yourself through unnecessary torture by not using a newer client-side library though. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Tabbed panel performance
Hi Pablo, Consider creating a custom profile for dojo. This makes a significant improvement to the page load time as it reduces the number of http requests (read on first though) http://cwiki.apache.org/S2WIKI/creating-a-custom-dojo-profile-for-struts-20x.html The reload problem you're encountering is that you're either accumulating too many objects in memory or too many nodes in the DOM. Use Firebug to make sure the previous versions of the tabs are not still in the DOM somewhere. Next, you'll have to ensure the widgets objects Dojo created are released from memory before creating them again after the reload (I've never done this...not sure how to ask dojo to dispose of them), and finally you'll have to ensure any listeners attached to DOM nodes inside your tabs are released (this causes major memory leaks in IE if they're not). All of this has to be controlled using the Dojo API, not the struts 2 tags. The dojo struts2 tags in 2.1 include an attribute to control whether dojo should parse the content for widgets. This makes a significant performance improvement rendering tabs that contain a lot of markup. This feature is available in Struts 2.0 version of dojo, but not as an attribute of the Struts2 tag. Again, you'll have to dig into the Dojo/widget API to enable the feature. When I reached that point of complexity (and slowness) I stopped using Dojo and switched to another library. When you're using the Dojo API the benefit of the struts2 tags is completely lost. Most people love JQuery. I use YUI. Dojo1.x looks good too, but I was too burnt to try it. Migrating from the struts2 tags may be a significant effort if you have a lot of notifiers in there, but JQuery and YUI are such a pleasure to use compared to the Struts2 tags so I think you'll find conversion a positive experience without regret. Good luck! regards, Jeromy Evans Pablo Vázquez Blázquez wrote: Just a bit more information. I have profiled (using firebug) the action (always the same action with the same content) with and without the s:tabbedpanel tag and here are the results: Without: --- 1727.355ms 1424.947ms 1748.429ms 1523.518ms 1539.649ms 1606.369ms 1657.058ms 1599.767ms 1632.157ms 1564.907ms With: 2294.719ms 2513.386ms 3398.823ms 4414.39ms 5716.896ms 7383.391ms 10188.268ms 12604.345ms 15876.5ms 20576.395ms As you can see, executing the action with the tag multiplies by 10 the response time!, while when not using the tag, response times are more or less equilibrated. Jeromy Evans escribió: Pablo Vázquez Blázquez wrote: Any idea about why am I getting increasing response times each time I access to the page? I have already a great response time the first time I access to the page (which is also a problem), but my main problem is that after 6 or 7 accesses it in unmanageable... Thanks! I don't recall the 0.4 dojo tabbed panel being particularly slow to render, other than the extreme initial page load while Dojo makes too many http requests. I can't think of any reason why it would get slower after a genuine page reload with the same content (if it's reloading via ajax though, then there's a good reason). The reload problem is not evident in the showcase: it's consistently unbearably slow for each reload at planetstruts. Dojo parses your html for widget markup, so it there's a lot of mark-up inside the tabs it's going to be slooowww (such as tables). Whenever I had a dojo problem I created a simplified page of html with just the one widget on it to isolate the cause. You're putting yourself through unnecessary torture by not using a newer client-side library though. - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using CompositeActionMapper
Allen Lee wrote: Hey there, Has anyone successfully gotten CompositeActionMapper to work and how? !-- Define the action mappers -- bean type=org.apache.struts2.dispatcher.mapper.ActionMapper name=addressMapper class=com.mycompany.actionmapper.CustomActionMapper / bean type=org.apache.struts2.dispatcher.mapper.ActionMapper name=compositeMapper class=org.apache.struts2.dispatcher.mapper.CompositeActionMapper / !-- configure the composite order (custom mapper and the default rest plugin action mapper) -- constant name=struts.mapper.composite value=addressMapper,rest / !-- enable the composite mapper -- constant name=struts.mapper.class value=compositeMapper/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Performance and High CPU utilization
Dave Newton wrote: --- On Thu, 9/18/08, sajanv007 wrote: It is a solaris box and has 16 GB memory and 4 CPU it is high end server class machine . Some how I suspect it is the OGNL or Freemarker rendering issue. Perhaps, but if so, I'll stick with my old dev box with a P4 and 2G running WebSphere, because I don't see anything remotely approaching that kind of usage. Or the T2000's used at my last job. Same question, preferably with more info this time: what JVM, how many tags, etc. You may want to take this up with FreeMarker and/or whoever does your JVM. FreeMarker/OGNL is slow, but it's not *that* slow that it'd take up 90% CPU like that. Dave We also need to know if you're doing anything particularly innovative, especially in your use of OGNL. A test case (jsp+action) would be great. I've been profiling Struts2 in YourKit lately and would be happy to probe deeper if given a concrete example of the problem. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Maven Archetype
Yanis Kekatos wrote: HI all, I am trying to run the Struts Maven Archetype following the instructions of the page http://struts.apache.org/2.1.2/docs/ready-set-go.html but I get the following error. Any help on this? The starter archetype for 2.0.11.2 is here: http://people.apache.org/builds/struts/struts-archetypes/2.0.11.2/starter-m2-staging-repository awaiting formal release to the maven repository. Something like this should work: $mvn archetype:create -DgroupId=be.realdolmen.struts2 -DartifactId=tutorial \ -DarchetypeGroupId=org.apache.struts \ -DarchetypeArtifactId=struts2-archetype-starter \ -DarchetypeVersion=2.0.11.2 \-DremoteRepositories=http://people.apache.org/builds/struts/struts-archetypes/2.0.11.2/starter-m2-staging-repository There's no 2.1.x archetype available except those that Lucasz has released himself. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: URL Mapper Best Pracitices Question
Frans Thamura wrote: http://www.jroller.com/fthamura - my login fthamura There's several ways to do this in struts 2. The best approach depends on what else your application does. Option 1. Low effort Implement a custom ActionMapper. It'll contain the logic to detect that the URI references a user and select the appropriate action with the username as a param. Option 2: Higher effort, but generic a. Use Struts 2.1 b. enable the NamedVariablePatternMatcher (instead of with WildcardPatternMatcher) c. Implement a custom ActionMapper that supports IndexActions. (or an action to invoke when no action is named) d. Create an IndexAction with namespace /{username}. It'll be invoked with the username as a param. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] Velocity Integration
Christopher Schultz wrote: I'm an S1 user and a member of the Velocity team. I recently posted a message to the velocity-dev list regarding the ugly syntax required by the S2 tag Velocity implementation. Hi Chris, It's probably worth posting to the struts-dev list with a more specific subject line. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] Avoiding usage of struts-tags
Andreas Mähler wrote: Hello Everyone, do you know if the communication between the S2 Action and the struts-tags is standardised? Or am I opening a black box if I replace sth. like s:textarea id=description name=object.description cols=40 rows=6/ with a VanillaHTML+JSTL version like textarea id=description name=object.description cols=40 rows=6${object.description}/textarea ? This approach is okay. You will struggle with collections though (like populating the values of a select) An edge case is radio buttons as they include a hidden field (or was that checkboxes). Just check the templates for what they render as html. It is currently working; but can I rely on it? Do you know how the field- and action-errors can be accessed with JSTL-EL? ${actionErrors} is a CollectionString ${actionMessages} is a CollectionString ${fieldErrors} is a MapString, ListString where the key is the name of the field The reason I do this is because I don't like the struts-tags and OGNL. That's understandable, but the template system of the tags is quite good and it may be more productive to create better templates. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] Avoiding usage of struts-tags
Andreas Mähler wrote: I've already tried that, but I don't know Freemaker yet and I don't even like the code that is generated by the simple theme. (e.g: it was my intention to write a 100% JavaScript-free webinterface) I also think that the interface is quirky and not as straightforward as JSTL's (at least the core tags - i rarely use the other stuff) - but that's just my opinion. I think I've also discovered a bug in the s:colgroup tag, so I can't use it. I've opened a ticket[1], but I think that I'm not allowed to schedule it to - say - the 2.1.3 release (at least if I don't provide a patch). Greetings, ~Andreas I didn't even know s:colgroup existed. I've been through the same pain and have many times started writing new tag implementations (less optional attributes, leaner templates) but its much larger than I expected. Even though I dislike the tags too, they do have many things going for them to the credit of the original developers; automatically include field errors in the right place and (usually) selecting the correct option in a select, populating values from collections etc. Complex forms become a mess if you don't use them. FreeMarker is overwhelming at first because the numerous #rt tags distracting from the important fields. I threw together this tool (http://www.freemarker-tool.com/) specifically for tweaking struts2 tag templates (see the examples). In one of my projects, prior to struts 2.0.9, I created a lot of JSP tags (.tag files) that wrapped struts2 simple tags with more behaviour/markup. eg. textfields that included a radio button to enable it first and an attribute to set the radio value. In 2.0.9 EL in struts2 tags was disallowed so eventually I had to rewrite them as custom struts 2 tags. Creating the new tags and templates was surprisingly straight-forward and definitely more productive that copy pasting the relevant JSP into every page. Anyway, hopefully just giving you some ideas. cheers, Jeromy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2 + Dojo 0.4 + unbeforeunload problem
I don't really know as i don't use dojo or the ajax tags for any more for all the same reasons you're experiencing. Dojo's event model is based on AOP concepts; which allows you to bind functions to the event, before the event or after the event. So you need a listener attached to before the unload event and tell it to not proceed with the default operation...somehow... If this was native javascript you'd simply call event.preventDefault() Related example: ie. So, if you were doing a confirm for a submit, the submit button would publish a topic (/submit) You attach a listener to the before /submit topic It prompts Are you sure? If they say no, you cancel the event by setting the event.cancel flag. In the case of a beforeunload event caught via dojo...not sure. But if you can get the listener invoked by dojo, then either the scope (this) or the argument (event) will reference an event object that probably has the cancel flag. Otherwise you could try a e.preventDefault using plain old javascript if you have a reference to the native event object. The recipes below are for Dojo 0.4.x; so even though they use 2.1.x tags, the javascript itself also works in Struts 2.0.x; you just have to write the javascript yourself thats included by within the new tag widgets. http://struts.apache.org/2.x/docs/ajax-and-javascript-recipes.html Pablo Vázquez Blázquez wrote: script type=text/javascript var form = document.forms[0]; if ((form) amp;amp; (formIsDirty(form))) { var a = confirm(There are unsaved changes. Do you want to continue?); if (!a) { dojo.event.topic.publish(/cancelNavigation); //HOW TO CANCEL NAVIGATION?? } } onbeforeunload = function(e) { if (formIsDirty(document.forms[0])) { e.returnValue = There are unsaved changes.; } } /script When calling topic /cancelNavigation the event paremeter is undefined... Do you know any way to cancel navigation? I mean, cancel rendering the served page. Jeromy Evans escribió: Pablo Vázquez Blázquez wrote: Using dojo.addOnUnload(function) neither works. Besides that, I would need sht like dojo.addOnBeforeUnload, but it does not exist. I don´t think I should subscribe for an ajax-request-completion event, but for the beforeunload one, don´t I? Thanks. Use the dojo.connect function to listen to an arbitrary event. See the comments to this related post: http://dojotoolkit.org/forum/dojo-core-dojo-0-9/dojo-core-support/when-does-unload-event-get-fired I don't use it myself. Just pointing you in the right direction. Also, if the script is inline within your ajax response, see the recently updated notes on Handling AJAX Responses here: http://struts.apache.org/2.x/docs/ajax-tags.html (its written for 2.1 but mostly applies) I'd consider turning on separateScritpts as well. - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JBoss 5 RC1 and Struts 2 : Simple validation error (URI scheme is not file)
Bobby Mitch wrote: hi, thanks for the explanations. Which means if you work from a snapshot version of xwork it's fixed (which is a 2.1 stream though, which you don't want). What do you mean here ? I didn't realise you could move to 2.1.x. It's not a trivial migration normally. A link to the migration guide is provided below. There's two options. 1. build it from source, which is pretty easy as all the dependencies are resolved automatically. This is your most reliable option. *Actually, there is no second option. I can't find xwork-2.1.2-SNAPSHOT for download anywhere. 2. download the snapshot jars from the following locations: http://people.apache.org/repo/m2-snapshot-repository/org/apache/struts/struts2-core/2.1.3-SNAPSHOT/ or (and parent directory/plugins for the necessary plugins) and then download the xwork-2.1.2-SNAPSHOT binary fromahhhI don't know. I can't find it anywhere. I'd just check out the source. http://struts.apache.org/2.x/docs/building-the-framework-from-source.html Migration guide: http://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] PropertyTag display data
Jeromy Evans wrote: Roger wrote: Hi s:iterator value=valueables status=status s:textfield name=valueables[%{#status.index}].description/ s:property value=%{valueables[%{#status.index}].description}/ s:property value=valueables[%{#status.index}].description/ /s:iterator The textfield property correctly displays the value , neither of the property tags display anything at all. What's the correct syntax for the property value attribute? Regards This is best, as its an iterator, for a for loop: correction: This is best, as its an iterator, NOT a for loop: - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] PropertyTag display data
Roger wrote: Hi s:iterator value=valueables status=status s:textfield name=valueables[%{#status.index}].description/ s:property value=%{valueables[%{#status.index}].description}/ s:property value=valueables[%{#status.index}].description/ /s:iterator The textfield property correctly displays the value , neither of the property tags display anything at all. What's the correct syntax for the property value attribute? Regards This is best, as its an iterator, for a for loop: s:iterator value=valueables s:textfield name=description/ s:property value=description/ /s:iterator The complication is that the iterator places a new object on the top of the stage: the object returned by iterator.next, so it's first trying to get valueables[i] from valueables[i], which is a waste of effort. Anyway, using your syntax, these should work s:iterator value=valueables status=status s:textfield name=valueables[#status.index].description/ s:property value=valueables[#status.index].description/ /s:iterator But I haven't check as its not the approach I'd use. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] PropertyTag display data
Dave Newton wrote: My first response was to say it was because you spelled valuables wrong and the framework is just really snooty. he he, I'd be in a lot of trouble if it was narky about typos. Obviously for the text field you'd still need to set the name appropriately using the status object. Oops, i missed that important point: To re-emphasise: s:iterator value=valueables status=status s:textfield name=valueables[%{'#status.index'}].description value=%{description}/ s:property value=description/ /s:iterator ie. the name of the textfield is valuables[0].description and the value is whatever the description is - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] Indexed Lists
Roger wrote: Hi I'm trying to get indexed lists working so that I can get any amendments back into my model. At the moment I've got In the last line, did you confirm that count has the correct value? What if the list is empty? (in that case count has never been set) s:textfield name=valueables[%{#count}].text value=%{text}/ The issue could relate to how valueables is being constructed. Are you creating it, or leaving it to the framework to create it? It should be able to add extra elements to a list For added entertainment, could anyone point me to a dojo/javascript tutorial that would allow me to add a further empty line when ever the user completes an empty line without, if possible, submitting the form? Or someother technique that allows the addition of unknown number form fields? in pure javascript: var inputEl = document.createElement(input); inputEl.type =input; inputEl.name =valueables[+count+]; var parentEl = document.getElementById(thePositionId); parentEl.appendChild(inputEl); and so on. or parentEl.innerHTML = input type='text' name=valueables[+count+]; and so on. where count is an argument passed to your function (eg in response to a click in the next empty row) You'll find plenty of tutorials along those lines. The latter approach is faster but vulnerable to more browser querks. Good javascript libraries include function to make the DOM manipulation less verbose. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Newbie question about Struts HelloWorld example
UseTheFork wrote: When I refresh my browser with http://localhost:8080/tutorial/HelloWorld.action, I do not get any WARNING or SEVERE kind of messages in the Glassfish Logs. I only get more of the above. I have also checked for CONFIG, FINE, FINER, FINEST messages, but I don't get any. The Glassfish Admin Console is works fine, which make me think that Glassfish is working fine !!! The most common initial problem is usually: some of the jars are missing from the lib directory of your web application when ir's deployed; or the configuration is referencing something incorrectly (like an invalid classname) The effect is that the struts filter (in your web.xml) fails to start. If it fails to start, you get the 404 error in the browser and no new messages logged (as struts isn't running). As dave says, it's really imported to either find the logs that show struts failed to start, or started and rejected the config; or double-check the config and deployment. (or post the config here as Dave suggested) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2 + Dojo 0.4 + unbeforeunload problem
Pablo Vázquez Blázquez wrote: No idea or miss-explanation? Use dojo's event model. You need to register a listener/subscriber for the event via dojo. If you assign a listener directly to onbeforeunload or onload you'll overwrite the listeners that dojo needs to assign (or vice-versa, dojo will overwrite yours). Check the dojo docs for examples. I can't think of it off the top of my head. Also, there should be a dojo-specific event you can subscribe to for the completion of an ajax request, rather than the page-related events. Check the recipes for that. Hope that helps a little. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2 + Dojo 0.4 + unbeforeunload problem
Pablo Vázquez Blázquez wrote: Using dojo.addOnUnload(function) neither works. Besides that, I would need sht like dojo.addOnBeforeUnload, but it does not exist. I don´t think I should subscribe for an ajax-request-completion event, but for the beforeunload one, don´t I? Thanks. Use the dojo.connect function to listen to an arbitrary event. See the comments to this related post: http://dojotoolkit.org/forum/dojo-core-dojo-0-9/dojo-core-support/when-does-unload-event-get-fired I don't use it myself. Just pointing you in the right direction. Also, if the script is inline within your ajax response, see the recently updated notes on Handling AJAX Responses here: http://struts.apache.org/2.x/docs/ajax-tags.html (its written for 2.1 but mostly applies) I'd consider turning on separateScritpts as well. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JBoss 5 RC1 and Struts 2 : Simple validation error (URI scheme is not file)
Bobby Mitch wrote: The Xwork issue is this one : http://jira.opensymphony.com/browse/XW-649 They have not fixed it yet ... Can someone fix it with the changes described below on the method private static void parseValidators() { ...} of the class com.opensymphony.xwork2.validator.ValidatorFactory ? And then recompiled the source and send me the newly compiled xwork-2.0.4.jar ? By the way, I saw that they turned it into an interface in the latest version : http://svn.opensymphony.com/svn/xwork/trunk/src/java/com/opensymphony/xwork2/validator/ValidatorFactory.java Thanks for your help. Hi Bobby, Musachy provided the link to the issue in the S2 issue tracker (WW-2653) which includes a comment that was committed to xwork in revision 1874 on 9 June 08. Which means if you work from a snapshot version of xwork it's fixed (which is a 2.1 stream though, which you don't want). For 2.0.x, you could check out the latest 2.0.x tag yourself, apply the same minor change, build it into a jar and it'll be fixed for you. Then you could contribute back the patch for everyone else. That's how we all got involved in Struts2 and Xwork ourselves. So you could have this all complete and closed yourself within an hour instead of waiting around for someone to volunteer to do it for you... regards, Jeromy Evans - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: error when rendering - java.net.SocketException: Broken pipe
sharath karnati wrote: Hi All, In weblogic server log, I found these error multiple times. Is anyone come accross this kind of problem? 2008-09-11 07:12:47,415 ERROR [org.apache.struts2.components.UIBean] - error when rendering java.net.SocketException: Broken pipe One cause is that the client terminated the connection early. ie. the server was sending something and the user clicked on a link so the browser interrupted the connection. In this case a tag was trying to write to the output stream but the stream was connection had been closed. If its frequent, it could be indicative of a non-critical problem (such as a slow page load). I'm not sure what else to read into it. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JBoss 5 RC1 and Struts 2 : Simple validation error (URI scheme is not file)
Bobby Mitch wrote: yes, but i wrote that with this XML file or without this XML file, that is with annotations only (@Validation etc), i still get the same error. So i do not see the point of me trying to change that file. And I want this to work with annotations too. Thanks anyway for helping. If you have the default ValidationInterceptor in your stack, it will still attempt to read any validation XML file it detects for the invocation. (even if using annotations). So at least ensure they're all removed. It is possible the problem is occurring in the default validators file. Anyway, I'm just guessing. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JBoss 5 RC1 and Struts 2 : Simple validation error (URI scheme is not file)
Bobby Mitch wrote: ok, well for your information I asked about that problem in the JBoss problem, thinking that the problem could come from JBoss, and I just posted the question on the XWORK forum where i hope they will help me fix it. http://forums.opensymphony.com/thread.jspa?threadID=454261 http://www.jboss.com/index.html?module=bbop=viewtopicp=4175490#4175490 It seems that it is a problem related to xwork, not Struts 2 itself. What do you think ? It is probably in Xwork, but Struts2 is so tightly coupled to Xwork it's much the same thing. Most S2 developers can change Xwork code. Looks like you received from good help in the jboss forum. Now that you know where the error occurs, place a breakpoint inside parseValidators to find out *exactly* which URI is causing the problem. IteratorURL urls = ClassLoaderUtil.getResources(, ValidatorFactory.class, false); while (urls.hasNext()) { URL u = urls.next(); File f = new File(u.toURI()); It's strange that getResources() is returning a non-file url. What URL is it returning that causes the exception to be thrown? (normally you get these exceptions when opening a FileInputSream on, say, an http: URL) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
please remove: [EMAIL PROTECTED] - User unknown!
Anyone listening that has the kudos to remove [EMAIL PROTECTED] from struts-dev and struts-user? I've grown weary of the warning received whenever I post a message to either list. Original Message Subject:Warning: [EMAIL PROTECTED] - User unknown! Date: Wed, 10 Sep 2008 16:37:00 +0530 From: MDaemon at usindia.com [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] - no such user here. There is no user by that name at this server. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ajax validation issue
Gawain Hammond wrote: A really nice solution so far has been to an action tag to populate forms, which has worked nicely the rest of the time. I've really liked using this approach to fill drop-downs, like so: s:action namespace=/admin name=crud.Group.listAll id=groupAction/ ... s:select label=Group name=user.group.id value=%{user.group.id} list=%{#groupAction.list} listKey=id listValue=name/ That's a novel approach. I like it. Using %{#groupAcation.list} to populate the drop down works great, but the only work around I've seen to fill the select box after validation returns to the form is rather messy: http://struts.apache.org/2.1.2/docs/how-do-we-repopulate-controls-when-v alidation-fails.html I don't see why the above approach wouldn't be working after a validation failure. When the INPUT result is returned it presumably renders the same JSP (and doesn't do a redirect). The problem occurs when the context/valuestack doesn't contain something you're expecting (such as the list for the select). Can you confirm whether crud.Group.listAll is invoked after a validation failure? Knowing ajax validation will only work with xhtml/css_html theme is helpful, I've been using ajax all along which may explain some issues. That should read client-side validation. You said to use the default interceptor stack for 2.1.2, and the documentation I read says to use 'jsonValidationWorkflowStack' do I need both of them or will just the default stack work? jsonValidationWorkflowStack is correct one. The autocompleter works because it performs a separate request to populate the permitted values. Your case is just that the list for the selects is empty or null. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JBoss 5 RC1 and Struts 2 : Simple validation error (URI scheme is not file)
Musachy Barroso wrote: this ticket: https://issues.apache.org/struts/browse/WW-2653 ? Yeah, that's a fix for the same issue. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JBoss 5 RC1 and Struts 2 : Simple validation error (URI scheme is not file)
Bobby Mitch wrote: Any other suggestion, anyone ? Thanks for helping. Did you try my suggestion of changing the doctype to point to a local file? Or a local catalog? Or perhaps even removing the doctype? It appears to be failing to parse the XML and the only URI present is in the doctype. java.lang.IllegalArgumentException: URI scheme is not file at java.io.File.(Unknown Source) at com.opensymphony.xwork2.validator.ValidatorFactory.parseValidators(ValidatorFactory.java:323) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JBoss 5 RC1 and Struts 2 : Simple validation error (URI scheme is not file)
Bobby Mitch wrote: hi, thanks again for helping. What XML file exactly are you talking about ? The decriptor file strugs-tag.tld from the The validators XML file you provided in your original email: ?xml version=1.0 encoding=UTF-8? !DOCTYPE validators PUBLIC -//OpenSymphony Group//XWork Validator 1.0.2//EN http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd; Try removing the doctype, or changing the PUBLIC reference to one that points to a local copy of xwork-validator-1.0.2.dtd using the file protocol, or register this URI in an XML catalogue. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ajax validation issue
Gawain Hammond wrote: ... That's a lot of problems, and to work-around each problem you've moved to a more sophisticated and complicated solution hoping for the best. You'll need to get the plain-old-validation working first. If validation fails, your action's execute method is not invoked, so you need to ensure all the data needed by the page is available in that case. eg. If you have a select that needs a list of values, then populate the list in the prepare method rather than the execute method. Client-side validation is then generated from your server-side validation settings. It'll only works with xhtml or css_xhtml theme'd forms with validate=true. If it fails in individual tags it's possible there's something wrong with the markup. When you isolate it to certain fields your browser can help you work this out. If you want to use ajax validation you'll need to ensure you're using the default interceptor stack for 2.1.2. It'll use your server-side validation settings. You'll need the sx:head tag in your page and need to be attentive to where you use ajax theme'd tags verses other themes (eg. if you don't want the form posted via ajax). I suggest you go back to basics; create a new minimal form with a minimal action and it get it to work. Hope that helps, Jeromy Evans - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JBoss 5 RC1 and Struts 2 : Simple validation error (URI scheme is not file)
Bobby Mitch wrote: Well, I upgraded to the beta version and I am getting errors in the struts-tags.tld file that i extracted from struts2-core-2.1.2.tld and put under WEB-INF/ Upgrading to 2.1.2 is a major effort, so I don't recommend that (too late...). You'll have to read the release notes and migration guide on the download page. Downgrading to 2.0.11.1 sounds reasonable if there's an actual explanation for it. I'm not familiar with the exception but I recommend one of these approaches: - change the DOCTYPE to reference a SYSTEM URI. It appears to not like that there's a URI using http. Perhaps change it to FILE and point to a local copy. - create an XML catalog file so the URI's are all registered on the local machine (so it doesn't have to validate using an external file). Here's the tutorial I follow: http://www.sagehill.net/docbookxsl/WriteCatalog.html (it relates to DocBook XML but the principle applies) Hope that helps. Jeromy Evans - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] s:select and Integer lists
Lyallex wrote: I'm starting to feel that way about Struts2, the other day I wanted to add some params to a url .. lo and behold the framework automatically appended all the params available on the action to the URL ... bloody madness. I ended up turning this ludicrous 'feature' off and doing it myself. I want to be in control, not have someone else tell me what I need ... So, I guess you didn't notice the url tag has includeContext (default true) and includeParams (default false) attributes. Is this because: a. your IDE didn't suggest them? b. there's too many attributes so they were lost in the noise? c. the documention for the tag was inadequate? d. the default behaviour is not the most frequently needed behaviour (in your case) e. other I've been through the same growing pains myself. Mostly it was b, c or d. But then, often I forget how painful it was to not use struts2. As for the list of Integers, I'm not sure what more it could do... it saw you were referencing a list of integers so it tried to populate the keys and values of the select appropriately. When you tried to override the behaviour and force it to calculate a different key it stopped working. Short of better warning message that the listKey resolved to null, or more examples, I'm not sure what else is a fault here. It certainly beats mapping the integer list to a Map to populate a select manually. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Default includeParams value, was: Re: [S2] s:select and Integer lists
Dave Newton wrote: The default value defines this behavior--you told it what to do implicitly by not changing it. Barring disagreement from others I'm changing the default to none as other people have also had an problem reading the documentation, and personally, I also think the default is counter-intuitive. Dave +1 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: REST plug-in Tiles
[EMAIL PROTECTED] wrote: I don't understand how the codebehind or convention plug-in could provide the inheritance and layout functionality of tiles. Moreover, we use conventions to tag CSS to tile definitions. Can you elaborate please? Maybe I misinterpreted your intent. Codebehind/Convnetion is responsible for selecting a result. it'll first check if there's an explicit result (@Result); then search for a JSP matching the convention (eg. order-show.jsp or whatever); then search for a FTL and or VM file matching the convention. The Tiles plugin could augment this process, so if none of the above are matched: search for a Tile with a name matching (prefix.order.show, or whatever). So it wouldn't replace Tiles; it would just allow for the selection of Tiles based on a similar convention. Similarly, the UnknownHandler could attempt match a Tile if no action, jsp, ftl or vm file is found. I never looked further into it than that, but I expect the Tiles plugin could detect the presence of a convention plugin and augment its behaviour. We're not supposed to introduce dependencies between plugins though. None of this affects using tiles within pages. I've just been phasing out the use of TilesResult to use result-by-convention selection so I didn't have to write the above code. My main purpose for using TilesResult (that is, to override the tiles at runtime) hasn't come up on a REST application yet. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: REST plug-in Tiles
stanlick wrote: Does the plug-in support tiles definition names in its search? No. It was discussed briefly once in srtuts-dev that the codebehind plugin tiles plugin together could support tiles naming conventions. eg. if OrderController.show() is invoked then search for a tile called (prefix.order-show). I think that would be generally useful whether used with REST or not. However the main reason I use tiles results is because they're easy to override (eg. by theme and or locale). When I started to look deeper into the this I saw the codebehind or convention plugin could easily do the same when selecting results...so I've start to ween myself off tiles results and try to head towards zero configuration by following the convention. I've found I still need a lot of @Result annotations though so its not there yet. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic include of a CSS stylesheet
Roger wrote: I often use: link type=text/css rel=stylesheet href=/css/main.css link type=text/css rel=stylesheet href=${pageContext.request.contextPath}/css/main.css link type=text/css rel=stylesheet href=${initParam.css}/main.css where ${initParam.css} refers to an init param in web.xml (useful if it needs to change with the deployment, such as a version number) Could you point me at some code examples on how to set this up. I've a need to load a different style sheet depending upon either the locale of the user, or a user selected locale. If dealing with Locale, I'd take a different approach. Struts2 sets the locale on the response object, and the i18n interceptor allows it to be overridden with the request_locale parameter. So you could: a. Reference the locale directly eg. link type=text/css rel=stylesheet href=/css/${pageContext.response.locale}/main.css or b. use the s:text tag to reference a path specified in a resource bundle for the current locale eg. link type=text/css rel=stylesheet href=s:text value=env.csspath/main.css or c. Use Tiles and Sitemesh to include a different tile/decoration based on the locale (as both support this). eg. tiles:includeDefinition name=page.cssIncludes/ I don't have any non-trivial i18n experience, so there's probably better ways. It really depends on what else needs to change on the page; if you're using a lot of s:text then that's a good approach; if you're using different tiles then that seems a good approach. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: on the chrome bandwagon
dynamicd wrote: Well i Just caught something. For some reason my listentopics or action from the form is not working It shows loading.. in the Chrome browser. but never loads. nothing in the logs Works on both firefox and IE s:div s:form id=selectreport theme=ajax action=ShowConfigureDZ s:select id=REPORTNAME name=REPORTNAME list=reportList.{prettyname} onchange=dojo.event.topic.publish('showConfigure_topic');return false; theme=ajax / /s:form /s:div s:url id=showconfigureDZ value=/ShowConfigureDZ.action / s:div id=configureDZ href=%{showconfigureDZ} formId=selectreport notifyTopics=showConfigure_topic theme=ajax/s:div Any Ideas So when they change the select value, the selectreport form is submitted and the configureDZ div is refreshed with the response. I can't see anything wrong... You may have to enable dojo debugging to see if any messages are displayed. I haven't played with any of the Chrome developer tools yet to see if that helps. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic include of a CSS stylesheet
Al Sutton wrote: Any reason not to use; link type=text/css rel=stylesheet href=s:url value='/css/main.css'/ or did I miss something? Al. That had never occurred to me! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] REST Plugin + Validation
alvins wrote: Thanks for the response Jeromy. I am actually already using that setting actually - I have two sets of different validations - one on the create method and one on the update method. However the problem is that when validation fails - I need an input result which is specific for each method. I hope that clarifies the problem. Ah, sorry, I understand now. I don't actually know how to solve that. Perhaps changing to a custom workflow interceptor to allow results other than input depending on the method. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: REST Showcase 2.1.2
Al Sutton wrote: Scott, Annotations serve a very useful purpose, and unless you're using a JRE less than version 5 they're worth the effort. Similar thoughts here. I found using validation annotations within actions and XML validation for models (visitor validation) was a good compromise. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] REST Plugin + Validation
alvins wrote: Hmm I might just have to do that. I am guessing alot of people will run into this issue with the REST plugin - might be an idea to get some annotation into conventions or rest plugin (not sure where it would go) to allow for method specific result for validation failure? How do these things get proposed - Jira? Yeah, raising a feature request in Jira. It could be adopted by convention/codebehind/rest. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] RestfulActionMappers and Namespace
alvins wrote: I've added comments to the REST plugin wiki - not sure if these want to get filed as Jira's? Alvin I think that's worth raising as an issue. I don't understand why this happens. Thanks for reporting it! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Some Idea On REST mapping
Ryan Wong wrote: I have changed the rest action mapper class to apply Ruby Style . there is draft, post here to find a better way to build RESTful app with struts2 I thought the RestActionMapper was already a copy of the RoR convention? I think it already matches all your mappings except new is called editNew. I'm no expert though. Besides, you could use Parameters and Parameter annotations with Regular Expression to support custom url pattern and Request Parameter Mapping. @Parameters( { @Parameter(pattern = page/(\\w+), property = page) }) public class TopicsController(){ } thus, get http://localhost/namespace/controller/page/1 will call controller's index() method with parameter {page=1} Sounds interesting. While it makes for a nice URL, some may argue against including params for a resource like this.. For params before the Controller (in the namespace) you may appreciate the NamedVariablePatternMatcher. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic include of a CSS stylesheet
Alexander Baetz wrote: Hi, ok, this is not really a struts question but we came to it while creating tiles pages. it might be that i'm thinking wrong. scenario: in writing a tiles template. there i want to include an external stylesheet x. when an action (domain/namespace/myAction.action) is executed the result creates a page that uses this stylesheet. now the problem: i want to avoid to include the stylesheet with the full path, including the domain. i would rather like to use the relative path. But how can i do that? Correct me if i'm wrong, but the relative path differs, depending on the url of the action. how can i create a link to the stylesheet that works for all actions? I often use: link type=text/css rel=stylesheet href=/css/main.css link type=text/css rel=stylesheet href=${pageContext.request.contextPath}/css/main.css link type=text/css rel=stylesheet href=${initParam.css}/main.css where ${initParam.css} refers to an init param in web.xml (useful if it needs to change with the deployment, such as a version number) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Some Idea On REST mapping
Ryan Wong wrote: Thanks Jeromy... There is not any document about this one.. So i missed that feature... Yeah, the NamedVariablePatternMatcher is only documented within messages in struts-user so far. I quite like it, although messing with the namespace introduces other complications as other struts2 features don't expect that. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Some Idea On REST mapping
Ryan Wong wrote: But there is still a question. With the namespace we have to place the parameter like prefix... eg. http://example.org/namespace/page/1/posts to call postsController index() method. It seems it cannot handle urls like http://example.org/namespace/posts/page/1 The follow one is more easily to accept by user, isn't it? Correct, it's just for the namespace, so it can't handle URLs like your parameter handling does. I agree your URL looks better. My preference is the following: The first page of the first post http://example.org/namespace/posts/1?page=1 the first page of posts: http://example.org/namespace/posts?page=1 the index of posts: http://example.org/namespace/posts And, although this isn't a good example, using the NamedVariablePatternMatcher: The first page of the first post: http://example.org/namespace/posts/1/page/1 in which case a PageController is being invoked (useful for genuine parent-child relationships between resources). But it really doesn't matter that much. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
on the chrome bandwagon
I don't often jump on bandwagon's and I'm not really an early-adopter, but I think many struts users would appreciate the chrome comic strip: http://www.google.com/googlebooks/chrome/ javascript hidden class transitions... mmm... i like that To put this on topic, has any one tested the struts 2 dojo tags in chrome yet? cheers, Jeromy Evans - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: REST Showcase 2.1.2
stanlick wrote: Also, what is the naming convention for validation xml files using the Code Behind/REST plug-in? I've tried several combinations of naming, but none seem to work. The short answer is: you can't. It doesn't work. Fortunately annotation validation works correctly in 2.1, so the approach I've used is: - the action carries validation annotations on the applicable methods; - the model's use XML validation as they can be used together and it's well suited to ModelDriven. The problem is that the DefaultValidatorFileParser in Xwork that reads the XML file has no way to specify which method it should be applied to. It applies to the entire class. With wildcards in 2.0 you could get around this because the action alias included the method name. It's the same reason using method='update' spefied in struts.xml never worked properly with XML validation. The parameter was ignored by the XML validator. This had always frustrated me. Fortunately somebody fixed the annotation interceptor so it can distinguish between the methods being executed. Unfortunately that fix (validateAnnotatedMethodOnly) is not enabled by the rest plugin by default. Further compounding the problem is that rest plugin has disabled validation for the edit, editNew and other relevant methods. (I'm not sure why...there must have been a reason for that). What I've done is replace the rest default stack with one that includes the validation interceptor with better configuration: interceptor-ref name=validation param name=excludeMethodsinput,back,cancel,browse,index/param param name=validateAnnotatedMethodOnlytrue/param /interceptor-ref interceptor-ref name=restWorkflow param name=excludeMethodsinput,back,cancel,browse,index/param /interceptor-ref I've been tempted to delve in a fix this but so far I've stayed out of xwork. The rest plugin does the right thing setting up the ActionInvocation with the action name and method name; the XML validation config reader just needs to use the method name to select the file (eg. to load OrdersControler-action-method-validation.xml if it exists). But I feel it already searches for far too many combinations, so I've been reluctant to touch it. stanlinck also wrote: Would you share the interceptor stack to fold paramsPrepareParamsStack capabilities into the restDefaultStack? I haven't experimented with this much with the rest plugin as I try to avoid it . It's reasonable logical... The actionMappingParams interceptor is the one responsible for setting the id, so it needs to appear before the prepare interceptor. If you need other params, before prepare, you also need params before prepare. The actionMappingParams and params are then required after prepare again. ie. set the id, load the object, set the id and params It's different because the ActionMapper obtained the id from URI. If you use other variables in the namespace you also need this interceptor before prepare. Hope that helps, Jeromy Evans - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] REST Plugin + Validation
alvins wrote: Hi guys, I have been wrestling with the REST plugin for the last couple of days and have posted some notes in another thread. I have hit a problem which I need a little help with. Basically in my REST controller I have a create and update method as per the REST guidelines. I need separate validations for each of these which I do via annotating the methods respectively. A problem arises as I need to separate INPUT results in the case of validation failure 0 one for the create and one for the update but of course this is not doable. I posted a similar response to this list a a few minutes ago. Here's a paraphrase for your specific question: The default configuration for the validation interceptor is not suitable for this. The parameter validateAnnotatedMethodOnly needs to be sets to true so the annotations only apply for the specific method instead of the entire class. What I've done is replace the rest default stack with one that includes the validation interceptor with better configuration: interceptor-ref name=validation param name=excludeMethodsinput,back,cancel,browse,index/param param name=validateAnnotatedMethodOnlytrue/param /interceptor-ref interceptor-ref name=restWorkflow param name=excludeMethodsinput,back,cancel,browse,index/param /interceptor-ref Hope that helps. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Rest Plugin + IndexController and disabling content types
rakeshxp wrote: Hi All, I have 2 questions regarding the struts-rest plugin ( 2.1.3-snapshot) 1) How can I write a controller that will handle the request on / ( i.e http://www.myhost.com )? No, there isn't. If you substitute the CodeBehind plugin for the Convention plugin, then you can (probably) use an IndexConroller for that. I haven't attempted it myself. The Convention plugin is in the sandbox (not released, and not likely to be until 2.2.x) but Musachy made it work with the rest plugin. Otherwise, create a custom ActionMapper that detects that URI. I create a simple one in an application that instead of returning null (action not found), just returned index; if an IndexController exists it will be invoked. I've found the CompoundActionMapper quite useful to split conventions rather than extending the RestActionMapper. 2) As I understand, the rest plugin by default handles XML and JSON extensions too ( http://struts.apache.org/2.x/docs/rest-plugin.html ) . Is there a way to disable these extensions ? ( Other than overriding struts.rest.handlerOverride.EXTENSION and providing a dummy implementation ) Thanks! You can probably change the struts.action.extension property back so one that excludes xml and json. Otherwise I don't think there's a way to disable an existing ContentTypeHandler other than the way you suggest. Eventually this will need to be controlled on a per package or per action case. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: REST Showcase 2.1.2
stanlick wrote: So any ideas why the model is being created inside the action and not injected by the framework? private Order model = new Order(); I think Don was just being lazy in the quick example ;-) I load or create the model in the appropriate prepare method. All that matters is that is exists (is non-null) prior to properties being set because it uses ModelDriven. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: REST 2.1.2
[EMAIL PROTECTED] wrote: Has anyone experienced a problem with a trailing front slash being added to the generated URL? I've seen it before. I can't look at my code right now, but I think it's because you have a trailing slash on a property either in struts xml (default namespace?) or in the @Namespace annotation. CodeBehind doesn't append the paths together correctly; it just assumes they can be concatenated. Now I think about it, I recall rewrting that bit of codebeind. There may be a fix in 2.1.3-SNAPSHOT, but it's possible I never committed though and just removed the unexpected /. I remember being very annoyed with it. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Next Struts Release with support dojo 1.x i.e. digits
deepakdabas wrote: I want to know when apache is planning to have the release of struts with support of dojo1.x i.e. support of digits in Struts tags. Have you tried using dijit? If so, I'm interested to hear what benefit you think struts tags would provide over using dijit directly? It looks good the way it is. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: REST 2.1.2
stanlick wrote: Thanks Jeromy :jumping: Have you considered the transparency of the REST URL as it relates to security and tampering? Would something like Acegi provide a solution? Also, have you considered the likliehood of a user discovering parms that can be passed and mapped onto your action? I am getting push back from folks in security about how Struts 1.X could block this behavior by including only acceptable parmaters in the ActionForm Peace, Scott Hi Scott, I'm not a REST expert, or a REST purist. I like the approach because it makes most things simpler (purists have made it seem complicated and elitist, which is stupid). Generally, I think simpler is good for security administration. If every resource (or service) has a unique URI, then filters (like Acegi) can easily control access to that resource. As soon as params are used to control behaviour it gets complicated. eg. /user/add is easier to filter than userManager.do?action=add Also by following the restful convention for http methods (gets for reads, others for modifications) you can also filter who can invoke the read, update or deletes. Role-based filters can be applied to the request (eg. only admin can post) and to action method's (only admin can invoke create()). It becomes consistent.. None of this solves the discovery of hidden params that can be passed into the action As an example, I suppose if you can create a User and a User has a hidden flag that indicates that they're an admin, and only an admin can set that flag, then there's no good way to filter than other than in the action directly or via the DI framework/java security. eg. you could prevent that method from being invoked by Subjects that don't have the admin role if the DI container allows that or a security manager is setup. I'm not an expert on Acegi either! So yeah, it may help a little because you use keep things simple and follow a convention. You don't need the REST plugin to do any of this though. It just requires an actionmapper slightly better than the default one in Struts 2.0.x. cheers, Jeromy Evans - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to set remoteuser
Hardik Shah wrote: hi we can get remoteuser using request.getremoteuser() but how we can set it? - One approach is to wrap the request object. Create a Filter, decorate the HttpServletRequest with one the implements setRemoteUser() and delegates all other methods to the original. When getRemoteUser is invoked it checks it's local value first and if not set delegate to the wrapped request object. Only your code needs to be aware of the special implementation in order to set the remote user. A proxy of HttpServletRequest that does the same thing may also be possible. Not sure... A better approach is to use the container's authentication as intended so the remoteUser is managed by it.. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to set remoteuser
Hardik Shah wrote: Jeromy Evans - Blue Sky Minds wrote: A better approach is to use the container's authentication as intended so the remoteUser is managed by it.. i think u are saying about jdbc realm for container's authentication! Correct. It's not as bad as it first seems if you manage the entries in the two tables (for tomcat) yourself. Otherwise the next step is a third party library like Spring Security. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to set remoteuser
Hardik Shah wrote: my first and last goal about that i want to maintain single sign on without storing user information in session i have also integrated hibernate with it ,can i use for achieve somthing like or not? Do you mean single sign-on as in across multiple domains or webapps? If so, this will probably be container specific. If you mean a stateless authentication approach (ie. they sign in once, then each subsequent request includes the credentials so you don't have to maintain a session for them), then: - use HTTP basic (or digest) so the browser must authentic each request - this will need to be setup in your container - if you use a JDBC realm, then, with tomcat at least, you can allow tomcat to access the tables directly and use your own webapp to add/remove users in those tables. To avoid the terrible browser pop-up for credentials: - if the user has javascript, perform login via an asynchronous request; - if the user doesn't have javascript, allow the container to redirect them to a plain old J2EE login page When you have a HTTP server in front of your J2EE container it gets a little more complicated; I'm not too sure about that. This isn't as trivial as it should be. There may be a better approach. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to set remoteuser
Hardik Shah wrote: Jeromy Evans - Blue Sky Minds wrote: Correct. It's not as bad as it first seems if you manage the entries in the two tables (for tomcat) yourself. Otherwise the next step is a third party library like Spring Security. try to use jdbcrealm but when submit gives error like HTTP Status 400 - Invalid direct reference to form login page finding solution from 2 days ,even no good tutorial found for that ,i surprised why this topic not included in struts 2 tutorial Get it to work without a login page first. Just allow it to popup with the browser dialog and for the container to authenticate via JDBC. When that works, investigate how to configure you container to redirect to a login page. I suspect most users implement their own custom authentication strategy, which means the Principle isn't valid, or they use Spring Security. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: S2: TypeConverters and Spring Injection
[EMAIL PROTECTED] wrote: Is there something unique about the StrutsTypeConverter class that causes auto-wire by name to work successfully (without even a bean definition of the converter), but not @Transactional/@PersistenceContext annotations? Thank you. It's a guess, but I would say yes. StrutsTypeConverter instances are created by the ObjectFactory, which is implemented by the Struts2 Spring Plugin. By default, the plugin calls on an AutowritringCapableBeanFactory to instantiate everything requested via the ObjectFactory so you don't require bean definitions for S2 actions, S2 converters or S2 interceptors. I suspect what you're seeing is that: - beans created via the ObjectFactory are using one wiring strategy; but - beans created directly via your application context are using a different wiring strategy. The autowire strategy can be changed via a plugin property. It should be possible to instruct the plugin to use a strategy that recognises the annotations (but perhaps its not supported). - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to set remoteuser
Hardik Shah wrote: this approach in single webapp thanks i should go with spring security ,but it works fine with s2? \ Yes, others definitely use it with S2 and Spring. It takes substantial amount of effort to learn. You may have to ask for specific help about that after going through the tutorials. I don't use spring security myself as I mainly use Guice/Warp which requires a different solution. Spring Security/Acegi is much more common. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Extending EJBInjection interceptor
Alexander Baetz wrote: Hi, i'm currently working on a new Interceptor for EJB Injection on Actions. I allready extendet it to work on fields and methods. But since i dont like to make my own Annotation type i wanted to use the javax.ejb.ejb anotation. But there is a small problem with that: the annotation used by the ejb3-plugin for struts 2 has a field that determines if the bean is statefull or stateless. I don't have this bean, so how do i determine for the injection if the bean is statefull? I'm not familiar with the plugin, but why does it need to know whether the bean is statefull or stateless? I don't think that should affect the lookup or injection into the action, should it? Only the Container that instantiates the bean and provides the instance cares, doesn't it? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to set remoteuser
Hardik Shah wrote: could you provide basic stuff or link for implementing Guice/Warp with s2 - he he, that's also a major decision if you want to go down that path. I don't recommend jumping after whichever approach seems least effort (btw, your original approach to use a realm or not using the principal at all is least initial effort if you don't want to learn another framework). http://code.google.com/p/google-guice/ Guice includes a plugin for s2 in their downloads page. It is as simple to get started with as the spring plugin. Warp includes persistence module and a better servlet filter. http://www.wideplay.com/home You can't just switch from spring to guice to no DI. framework. You have to pick one and take the time to learn it I'm afraid :-). Learning J2EE's security, spring's security or guice+warp are time well spent. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 2 + Rest URLs
rakeshxp wrote: Hi All, I am migrating from struts 2.0.10 to 2.1.2 ( for need of restful URLs). Could someone help me understand the following ? 1) Is it better to use Annotations or Codebehind for Restful URLs? ( I some how like the annotations more than assuming some standard for resources) This is a approach is fine. The annotations are a feature of CodeBehind in 2.1 (used by CodeBehind to create the configuration) Note that CodeBehind will be replaced by the ConventionPlugin in 2.2ish but the annotations won't need to change (much...). 2) I am stuck at running the restful URLs using codebehind plugin. Here are the details: In web.xml, I have actionPackages = com.struts.example.action and I have the following package struture: com.struts.example.action - No files com.struts.example.action.account - AccountController com.struts.example.action.help - HelpController expecting that, I will get the following URLs: http://localhost:8080/myapp/account Close, but not quite right. It works like this: com.struts.example.action.AccountController will be at http://localhost:8080/myapp/account com.struts.example.action.account.AccountController will be at http://localhost:8080/myapp/account/account http://localhost:8080/myapp/help But this does not work. Could someone help me in figure out what is happening ? Going forward, I wanted URLs of the following format http://localhost:8080/myapp/account http://localhost:8080/myapp/account/logout http://localhost:8080/myapp/help http://localhost:8080/myapp/displayname ( so if it is not account or help, then it would be a displayname and hence I want to process it specifically ). CodeBehind itself doesn't include any support for index actions, so you have to set this as follows: com.struts.example.action.AccountController - http://localhost:8080/myapp/account com.struts.example.action.account.LogoutController - http://localhost:8080/myapp/account/logout com.struts.example.action.HelpController - http://localhost:8080/myapp/help Not sure what you mean with display need. You probably need this: com.struts.example.action.DisplayController - http://localhost:8080/myapp/display/displayname Where displayname will be set as an ID for the DisplayController Otherwise you'll need to customize the actionmapper a little. Hope that helps. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 2 + Rest URLs
Jeromy Evans wrote: rakeshxp wrote: Hi All, I am migrating from struts 2.0.10 to 2.1.2 ( for need of restful URLs). Could someone help me understand the following ? 1) Is it better to use Annotations or Codebehind for Restful URLs? ( I some how like the annotations more than assuming some standard for resources) This is a approach is fine. I really need to reread my emails before sending them. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 2 + Rest URLs
rakeshxp wrote: Jeromy Evans - Blue Sky Minds wrote: This is a approach is fine. The annotations are a feature of CodeBehind in 2.1 (used by CodeBehind to create the configuration) Note that CodeBehind will be replaced by the ConventionPlugin in 2.2ish but the annotations won't need to change (much...). Regarding annotations, is it given higher preference than Codebehind? So for example, can I create a LogoutController in com.struts.example.action.xyz.LogoutController ( instead of com.struts.example.action.account.LogoutController ) and have this annotation? @Namespace(value=/account/logout) Thanks! Yes. The CodeBehind plugin checks for the presence of the annotation when generating the namespace and gives precedence to the annotation. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 2 + Rest URLs
I need to sign off, but have a look at the REST showcase included in the apps directory of struts2.1 The location of results is best described here: http://struts.apache.org/2.x/docs/codebehind-plugin.html Codebehind doesn't have much flexibility in the result location. If you use freemarker results you will get locale support - not sure about JSP. rakeshxp wrote: Excellent. Thanks! So now, I have the following com.struts.example.action.AccountController com.struts.example.action.account.LogoutController When I hit, http://localhost:8080/myapp/account/logout , then I get the following exception No result defined for action com.struts.example.action.account.LogoutController and result index The LogoutController looks like this: public HttpHeaders index() { return new DefaultHttpHeaders(index).disableCaching(); } I have a logout-index.jsp directly under the webapp folder ( along with account-show.jsp, help-show.jsp etc ). So is it the proper name structure ? Also, 1) How to specify the location of the JSPs ? I wanted to have custom folders like this i18n/en_US/help/index.jsp i18n/en_US/help/show.jsp i18n/en_US/account/show.jsp i18n/en_US/account/logout.jsp etc So that I can problematically serve the appropriate locale JSPs ( When using struts 2.0.10, in the action XML, I was using something like this result name=success/jsp/i18n/${userLocale}/account/show.jsp/result ) 2) The reason I wanted /displayname is something like this http://localhost/myapp/help - help pages some more static pages anything which does not match the above, could potentially be a profile page which has the url http://localhost/myapp/username. So I wanted something like catch all , so that I can check if it happens to be a username. 3) Just curious, when running the above code, while tomcat was starting, I was getting class:class com.struts.example.action.AccountController parent:null current:com.struts.example.action. class:class com.struts.example.action.account.LogoutController parent:null current:com.struts.example.action.account what does parent property mean ? Thanks! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Extending EJBInjection interceptor
Struts Two wrote: Now seeing that Jeromy is working on a new Interceptor, I wonder if all the servers follow the same lookup pattern. I'm not working on any interceptors related to this. For JNDI lookups in S2 in the past I've used the DI framework's features rather S2. ie. Both Spring and Guice can be setup to inject dependencies that are looked up via JNDI. Spring or Guice is then responsible for appropriate caching based on the scope of the bean/resource. I found reusing those easier than writing a custom interceptor to detect @EJB and related annotations in actions. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts 2 Rest + Prevent Session creation
rakeshxp wrote: But this does not seem to work. When I hit any restful URL, then there is a JSESSIONID cookie being set. Could someone point out what is wrong with the above config ? Thanks! CodeBehind is responsible for setting up the packages. I don't know the history, but codebehind uses a separate property the specify the default package. Try setting both properties: constant name=struts.configuration.classpath.defaultParentPackage value=mydefault / constant name=struts.codebehind.defaultPackage value=mydefault / - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Default bundles with JDK6
Repko, Brian wrote: There's been no reply to this - is there something more that I can give folks for help on this? Sounds like a bug. This section has always seemed messy to me. There's been several changes here in the 2.1 branch. I don't completely understand your approach, but presume you have a common base class for your actions that delegates to your TextProvider implementation instead of the default. If not, you should (replace/extend ActionSupport and delegate to your TextProvider mixin). As the action is (usually) at the top of the stack, the first TextProvider found will be your implementation of the various getText methods and you can do whatever you like before delegating to XWork. Or have I misunderstood the need? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Can anyone help me with an example of REST with mutiple paras
Ryan Wong wrote: how can I apply the URL http://localhost:3000/ontrack/1/sprints/1 to action to show item with ontract id - 1 and sprints id - 1 Here's an example using the REST plugin: http://www.blueskyminds.com.au/url-hierarchy/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] ModelDriven: model not pushed on stack?
There is something else at play here. If you put a break-point in the interceptor it should become clear. I vaguely an update or concern recently relating to automatic refreshing of the model in the ModelDriven interceptor; the interceptor gets the model and re sets it on the stack when it thinks it should. There was a concern about it corrupting the stack order... or something... Maybe it's broken as a result of that change. Sorry I can't be more specific but it'll show up in struts-dev or struts-jira if you search around those terms. Pierre Thibaudeau wrote: 2008/8/26 Pierre Thibaudeau [EMAIL PROTECTED] [...] suddenly, on my most recent action, the model does not find its way to the top of the stack, and I cannot find where the problem might be. I dug deeper into this issue and found something very surprising. The strange behaviour centres around the execute() method. I am very tempted to call it a severe bug (for Struts 2.1.2)... To make things simple, I produced a test case (see below): two very simple ModelDriven Action classes. The first one works as expected, and pushes the Model (SmallObject) on top of the ValueStack. The second action surprisingly fails to push the Model on the stack (though the Model is still accessible through the Action being on the stack). In short, it seems that the model is not pushed on the stack when its value is last assigned inside the execute() method!!! Am I forgetting something, or is this truly a bug? It might be worth knowing from others if the same problem occurs with version of Struts earlier than 2.1.2. // /* /test.jsp */ // htmlbody Model on the stack: ${foo}br/ Action on the stack: ${model.foo} /body/html // /* struts.xml */ /*/ struts package name=default extends=struts-default abstract=false namespace=/ default-interceptor-ref name=paramsPrepareParamsStack/ action name=successfull class=com.myapp.SuccessfullActionresult/test.jsp/result/action action name=failing class=com.myapp.FailingActionresult/test.jsp/result/action /package /struts /**/ /* SmallObject.java */ /**/ public class SmallObject { private String foo; public String getFoo() { return foo; } public SmallObject(String str) { foo = str; } } /***/ /* SuccessfullAction */ /***/ public class SuccessfullAction extends ActionSupport implements ModelDrivenSmallObject, Preparable { private SmallObject obj; public SmallObject getModel() { return obj; } public void prepare() { obj = new SmallObject(bar); } public String execute() { return SUCCESS; } } /**/ /* FailingAction */ /**/ public class FailingAction extends ActionSupport implements ModelDrivenSmallObject, Preparable { private SmallObject obj; public SmallObject getModel() { return obj; } public void prepare() { /* do nothing */ } public String execute() { obj = new SmallObject(bar); return SUCCESS; } } No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.6.9/1636 - Release Date: 26/08/2008 7:09 PM - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: S2: Unable to undeploy app in Tomcat
Paul Benedict wrote: I can't see how this could be a Tomcat or Windows problem. With Struts 2.1.2 and setting antiJARLocking=true, I was able to undeploy. However, the necessity of the option tells me Struts (or XWork) is leaky somewhere and is not properly cleaning up its house. When running under Windows, files are only locked when they are open, and if Tomcat can't GC due to uncollectable references, then it's proof there's a leak. I don't think this problem should be ignored. I agree, but it hasn't deserved the same priority as the numerous other S2 + Xwork problems because there's a reasonable work-around. If you can isolate it that would be great! For me, the inability to release PermGen space (consumed by cglib others) overrules the need to re-deploy quickly because that kills Tomcat on any platform faster than an open file or unallocated resource consumed by S2. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] Re: MySQL Monitoring
Frans Thamura wrote: On Mon, Aug 25, 2008 at 10:21 PM, Dave Newton [EMAIL PROTECTED] wrote: --- On Mon, 8/25/08, Frans Thamura wrote: my concept is like programmer factory Oh. That sounds depressing. i make this program because several reason, snip Your motiviation is great. You seem to worry too much about whether this technology is the right technology. I think that doesn't matter; S2 is pretty good and pretty easy to learn so it seems a good place to start with Java. If, in the worst case, all interest in S2 disappears in a year or two, the skills obtained are still relevant to any other request-oriented Java framework. I'd also go so far as to so that by learning a request oriented framework rather than a component-oriented one they will have a better understanding of the fundamentals. I have met many ASP.net developers that have no idea whatsoever what a postback is and can't differentiate between client-side and server-side handling which is a concern to me but fine for people that need to output a quick short-lived website. Your training program should try to introduce them to all methodologies and the benefits of each; it's all good and all positive. Prepare your program for the possibility that technology trends change; make that a core strength of your program (developing their skills to be good programmers and adapt to the changes). - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: S2: Unable to undeploy app in Tomcat
Hi Paul, I'm not 100% sure as I've never investigated this in detail myself. Now that you've mentioned it though, I recall another issue with Struts 2 leaving files open. It related to the FreeMarker template caching and someone had setup a task to monitor open file counts at run-time. That would also cause the problem you're seeing and there's probably an issue in JIRA about that one too. I rarely attempt to undeploy myself as the application servers run out of PermGen space eventually anyway requiring a restart. I prefer a reliable slow restart rather than a fast redeployment with an occasional failure. Paul Benedict wrote: Jeromy, I wrapped a try/finally in the init and destroy method as you and the ticket described, but there was still a memory leak that locked down the Struts 2 core library. Are you sure these are the only things to be done? @Override public void init(FilterConfig filterConfig) throws ServletException { try { super.init(filterConfig); } finally { ActionContext.setContext(null); } } @Override public void destroy() { try { super.destroy(); } finally { ActionContext.setContext(null); } } Paul On Sat, Aug 23, 2008 at 12:20 AM, Jeromy Evans [EMAIL PROTECTED] wrote: Paul Benedict wrote: https://issues.apache.org/struts/browse/WW-2167 Yes, it's easy to retrofit to 2.0. It only requires a finally statement in the init and destroy methods. - 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] Double conversion issue
Milan Milanovic wrote: Uf, bug again :-(((. Is there any custom type-converter for Double-s that doesn't have this error ? -- Milan A custom type-converter means you can write one yourself for that specific property. It's very simple: http://struts.apache.org/2.0.11.2/docs/type-conversion.html Personally I never use Double in an action and instead opt for BigDecimal to maintain precision correctly. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] Struts and blob image from Oracle
Your configuration is okay but you have misused the action tag. You can't embed an inline image within an HTML page. ie. you've started sending a result, which is from JSP, and then part-way though you've attempted to output some binary data in the same output stream. You do not need special tags. As Gabriel suggested, you simple need an image tag. default.jsp: pThe image follows/p img src=pgetpicture.action alt=generated image/ That means there's first an HTML stream (from the JSP), then separately browser opens the image stream from your action. Hope that makes sense. Jeromy Evans Alessio Bandini wrote: I'm sorry again. The mailing list manager does not allow attached files. But the problem is still the same. I get the image from DB, but I see binary characters and not the image. Probably I have to use some special tags but I cannot understand what. Thanks. Alessio Bandini wrote: Thanks, I'm sorry, I intend mistake, writing the modules, not error. The image is stored in an Oracle DB, not in a file system. I get the BLOB from DB, but when I try to view the image what I see is in the file attached to this mail. I see binary characters and not the image. Thanks. Gabriel Belingueres wrote: Please post the error (stack trace?). I suppose that if you want to show the image, you need some img tag in your html page result. s:action tag doesn't generate img tags for you AFAIK. 2008/8/21, Alessio Bandini [EMAIL PROTECTED]: Hello, I have a web application that must get image from blob field stored in an Oracle DB, but I cannot find how to examples. Here is my sources. Where is the error? default.jsp --- s:action name=pgetpicture executeResult=true s:param name=id value=2950 / /s:action struts.xml -- package name=pgetpicture extends=struts-default action name=pgetpicture class=pgetpicture.PGetPictureAction result name=success type=stream param name=contentTypeimage/jpeg/param param name=inputNameimg/param param name=bufferSize1024/param param name=contentDispositioninline/param /result /action /package PGetPictureAction.java -- package pgetpicture; import com.opensymphony.xwork2.ActionSupport; import maps.SqlMapConfig; import java.io.*; @SuppressWarnings(serial) public class PGetPictureAction extends ActionSupport { private Integer id; private PGetPicture imgobj; public String execute() throws Exception { imgobj = (PGetPicture)SqlMapConfig.getSqlMapIstance().queryForObject (getpromopicture, getId()); return SUCCESS; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public InputStream getImg() { return imgobj.getImg(); } } PGetPicture.java package pgetpicture; import java.sql.SQLException; import com.ibatis.sqlmap.client.SqlMapClient; import java.util.*; import java.io.*; public class PGetPicture { private byte[] img; public void PGetPicture(){ //super(): } public InputStream getImg() { InputStream is = new ByteArrayInputStream(img); return is; } public void setImg(byte[] img) { this.img = img; } } PGetPicture.xml --- ?xml version=1.0 encoding=UTF-8? !DOCTYPE sqlMap PUBLIC -//iBATIS.com//DTD SQL Map 2.0//EN http://www.ibatis.com/dtd/sql-map-2.dtd; sqlMap namespace=pgetpicture typeAlias alias=picture type=pgetpicture.PGetPicture/ resultMap id=picture-map class=picture result property=img column=img jdbcType=BLOB / /resultMap select id=getpromopicture resultMap=picture-map SELECT b_imgbkg as img FROM table_name WHERE i_id = #id# /select /sqlMap Please, help me. - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Informazione NOD32 3375 (20080821) __ Questo messaggio è stato controllato dal Sistema Antivirus NOD32 http://www.nod32.it - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] Double conversion issue
I've seen this reported previous as a bug in S2/Xwork (appending an extra 0 character). I can't recall where I saw that. Write a custom type-converter for that field to work-around it. Milan Milanovic wrote: This is some wierd Struts behaviour for Double conversion, e.g., if my prop attribute in JSP was 2232.435, when user click on this Delete link, in my action class for prop attribute I get: 2232435.0 ?! -- Milan Milan Milanovic wrote: Hi, I have this code in my jsp: s:iterator value=someObject status=rowstatus ... s:url id=removeUrl action=remove s:param name=prop value=prop / /s:url s:a id=a_%{prop} href=%{removeUrl} theme=ajax notifyTopics=/delete targets=fruitsDelete/s:a ... /s:iterator This remove.action is mapped into remove() method in my action class, and prop is a double property with get/set methods in my action class. What happens now, when user enter, e.g. 1234.0 for prop, it is well represented here, e.g. prop value is 1234.0 in jsp and my list in action class, but when user click on the link above to delete it, in my action class remove() method for prop I get: 12340.0 ! Zero is always added at end of the number, does anyone know why this could happen ? -- Regards, Milan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: S2: Unable to undeploy app in Tomcat
Paul Benedict wrote: I am unable to have Tomcat delete the physical directory of my webapp when I undeploy from Tomcat Manager. My application gets undeployed, but there is a lock is on the struts2-core library. Anyone encounter this problem? I am using 2.0.11.2 and Tomcat 6.0.16. Paul Yes. I don't think there's a work-around in 2.0. I think there's an issue in JIRA and recall it relates to the threadlocal ActionContext not being released. A work-around was applied to the FilterDispatcher in 2.1 that would force it to release the ActionContext. Sounds like you're using windows. On that platform I always perform an undeploy, stop, then a reliable delete, then start, then deploy. Linux platforms don't experience the same file locking issue. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: S2: Unable to undeploy app in Tomcat
Paul Benedict wrote: https://issues.apache.org/struts/browse/WW-2167 Yes, it's easy to retrofit to 2.0. It only requires a finally statement in the init and destroy methods. PS. stop developing java on windows... ;-) My estimate is that Sun's java compiler is at least 50% faster (perhaps more) under Linux. I don't know the reason, but that alone makes for a significant productivity difference when working with struts. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts2: simple ajax form - returns value to a new page (not to a DIV)
MyAshok wrote: Hi all, Thanks for all your response. Finally i isolated the problem and found that the problem is with the ajax submit of the same div. (i.e) my form and the submit targets to the same div. This scenerio creates the problem that the values in the jsp is not populated to the action by autowiring. That sounds an awful lot like the previously mentioned Dojo/IE bug. Turn off the loading text (showLoadingText=false) on the widget that generates the request and see how you go. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts2: simple ajax form - returns value to a new page (not to a DIV)
Dave Newton wrote: - On Wed, 8/20/08, MyAshok wrote: Can you tell me whats might be the problem with my IE. It's IE. Dave He he he. I don't know for certain, but I think it's due to IE's non-standard event-handling (event ordering) and Dojo's/widget's failure to accommodate that in this specific case. In effect, the DOM is updated with the loading text before the code reads the values from the form; The result is that the body of the request is empty. Here's the interesting details: http://www.quirksmode.org/js/events_order.html It's the responsibility of the widget to accommodate it, but it's better to use the indicator attribute instead of the loading text anyway. I've lost count of how many times we've responded to questions about this this frequently encountered problem. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Authentication way: Should I interceptor s:url or s:a before it render?
Haulyn R. Jason wrote: Hi,all I have an Authentication problem. I use Interceptor to authenticate actions and methods, based on different member and different role. Everything works well.But my client can not access some resource, for example a url, so they should not see the url. I think maybe I can re-write s:a tag or using an Interceptor to check should a s:a /tag be rendered to the clients. I can not find any reference. Without this way, does struts2 have it's own way to solve the problem? Thanks! None of the struts 2 tags are aware of role. In my opinion, it's better to leave that consideration out of these tags as you don't want security checks scattered through all the tag variations. Instead customize the view using tags that render its body only if the user has the specified role(s). Either: - use tags from an existing library (Tiles tags can check role I think); or - create a custom tag that only renders the body if the principal has the specified role(s) eg. security:guard role=admin s:a href=adminpage/ /security:guard Otherwise every tag needs to be modified and that leads to mistakes. *More importantly* secure the server-side first and foremost. Consider customization of the view based on role only as a way to improve the user's experience as it doesn't actually help secure your application. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[OT] Re: sitemesh +yui problem
Hardik Shah wrote: i am trying to use several yui elements in strtus 2.0.11.2 problem is that it can not get its styles (for exp tab shows only in link format ,it can not use tabview.css) when i try to exclude action like cflist.do in decorators.xml then yui works fine (bt my constant view also exclude) i can not understand how to solve this problem y sitemesh filter all this css files please help me according to that thanks in advance It's really a sitemesh question. In sitemesh.xml, ensure your page-parser is setup only for text/html. You don't want it to attempt to decorate other content types. In decorators.xml, you can probably decorate /*. You shouldn't need any exclusions unless you serve undecorated html as well. You need to isolate whether your css file is being served accidentally decorated, or not served at all. Use FireBug to find out. If it's not being served at you, your problem is not with sitemesh but with your configuration/deployment of the container. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] Re: sitemesh +yui problem
Hardik Shah wrote: i can not get perfectly you ,can you be more descriptive about you say(what i have to do for this problem) You're welcome. Use the FireFox browser and install the FireBug extension. Load your page, open FireBug and view the Net tab. Determine whether error's occurred trying to load the files for your page (eg. a 404 occurred loading the CSS file), whether the file was found but decorated by sitemesh (eg. the file content is invalid), or whether it received all files correctly. When you know exactly what's wrong: - check you sitemesh.xml file to ensure it has the correct page-parser - check your decorators.xml file to ensure it has the correct mapping and exclusion If that doesn't help, come back here with more information about happened (eg. file not found or file invalid). - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts2: simple ajax form - returns value to a new page (not to a DIV)
MyAshok wrote: I do have the same issue. on click of submit, the loadingtext is displaying but the result in a new page as i am redirect to a action. Any solutions? please asap. action name=activateSubscriber class=subscriberAction method=activateSubscriber result name=success type=redirect-actionviewPartners/result /action Waiting for reply.. If it's performing a full-page redirect, then your form did a plain old post/get to the action, not ajax. You will need to isolate why the request wasn't sent via XHR. That means it's a client-side problem, not a struts.xml problem. As a guess, without any context, if you've only tested in IE so far, turn off the loadingText message. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: NullPointer Exception On IE7
Dave Newton wrote: So... we still have no idea what exception is being thrown. That makes it really hard to even begin. Dave I think MemberId is null: memberID = memberID.substring(memberID.lastIndexOf('\\') + 1); Or pageRequested is null searchForm.setPageRequested(Integer.parseInt(pageRequested)); Or sortByField is null: searchForm.setSortByField(Integer.parseInt(sortByField)); Just a hunch. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts2: simple ajax form - returns value to a new page (not to a DIV)
Dave Newton wrote: I'd be immediately suspicious of your manual form submission; as a guess I'd say that bypasses the normal form submission process, making it a non-XHR request. Off-the-cuff guess, though. Dave Absolutely positive that's it. This line: document.getElementById('SubscriberForm').submit(); performs a plain only non-ajax request. MyAshok, see the dojo ajax recipes for how to cause an ajax submit using the publish/subscribe event model. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts2: simple ajax form - returns value to a new page (not to a DIV)
Martin Gainty wrote: var xmlhttp=dojo.hostenv.getXmlhttpObject() var response= xmlhttp.responseXML; var parsed_response=SomeXMLParser(response); document.getElementByTagId(div).innerHtml = parsed_response; -- /script yes/no? Martin That would work, but dojo already includes code to invoke the right XML parser depending on the browser and includes code to strip the javascript out of the parsed response and execute it after updating the DOM. So it's best to reuse that code (which is behaviour of the widget) rather than rewrite an 80% complete solution. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Could not find property [struts.valueStack] using struts 2.1.2
David N. Arnold wrote: You're not the only one. I can't remember if I was running trunk or 2.1.2, but I have seen the same messages. On Thu, Aug 14, 2008 at 9:47 AM, Stephan Schröder [EMAIL PROTECTED] wrote: 14.08.2008 15:12:34 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn WARNUNG: Could not find property [struts.valueStack] They are normal in struts 2.1.2 as logging verbosity was increased. Turning off devMode MAY hide them (I don't recall) Otherwise disable the via your logging implementation. It essentially means some time was wasted searching for something in the valuestack that didn't exist. It reveals some significant inefficiencies and are present because they should be resolved by S2 developers one day. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with no configaration found
Muralidhar Y wrote: s:form action=executePoPSearch.action It's an (annoying) warning caused by the line above. It means it searched for an action in the configuration called executePoPSearch.action but couldn't find it, so it's going to use the literal value executePoPSearch.action instead. The form tag includes code to generate an appropriate URL. First it tries to see if you're referencing an action by name, and if so, it asks the ActionMapper to generate a URL for it. If it wasn't found, it assumes you're specifying the URL directly. Make it go away using: s:form action=executePoPSearch - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts2 Application Structure
Al Sutton wrote: Not sure where you get the action-per page is the generally accepted norm, but if your page is purely static (i.e. accesses no variables and includes no forms), go straight to the html page. Not only does this save you the JSP compile/post-compile interpretation time it also allows you to move the page onto an separate Apache HTTPD server to improve performance. Al. If you can't go down that path, the CodeBehind plugin is exactly what you need. If no action exists but a JSP exists, it invokes a default do nothing action so the JSP has access to all the usual Struts2 context and tags. http://struts.apache.org/2.0.11/docs/codebehind-plugin.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]