Sandy Noble

Greenhorn
+ Follow
since Apr 30, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sandy Noble

You could try #validator. This looks for a named value called validator. When you push a value onto the value stack within the jsp itself, then need to access it that way.

13 years ago
2010-11-04 14:52:44,395 WARN - Could not create JarEntryRevision for [besjar:C%3A/Borland/BAS660/var/domains/base/configurations/... path to deployed *.war]!
java.util.zip.ZipException: The filename, directory name, or volume label syntax is incorrect

Is the "spurious" error that I'm getting in the logs, in case this is relevant.
13 years ago
As an interesting development, this one:



gives me a java.lang.NoSuchMethodException: ( ... ).day.DaytimeBookingAction.!confirm()

looking for .!confirm() which is annoying.
13 years ago
Hello, I've just updated an application from struts 2.0.6 to 2.2.1. The previous version used the dojo plugin extensively for date time pickers, but this time I have gone with the jQuery struts plugin and it's datepicker tag. There isn't much else I had to change, which was pleasing (and suspicious!)

I've come across a few niggles with warnings appearing in the server log, but they seem to be spurious and the system works. However, I have public methods in my action class called confirm(), complete(), a struts.xml that contains



and then a form like

my jsp:


This used to work fine, and would post the form to the same action that generated the page (in this case, DaytimeBooking.action), and calling the method called confirm().

Since I've updated struts, this same form now simply calls execute() instead of confirm(). I've tried a few different forms of submit:


is my standard unchanged version. This now calls execute() rather than confirm().


gives me an action not found error: There is no Action mapped for namespace /supervisor and action name DaytimeBooking!confirm. I do have <constant name="struts.enable.DynamicMethodInvocation" value="false" /> set in my xml too.



Actually works. But I don't want to hard-code the name of the action into the jsp because then I can't reuse it in other actions. This is also the reason for not having the action="DaytimeBooking" property in the <s:form ..> tag.

Has something anything changed in the way struts (or the taglib) handles these forms? Is there a better way of decoupling the jsp from the action rather than just omitting the action property?

Hope a smarter person than I can help!
Cheers
13 years ago
Please note - I've just got stuck doing this with later versions of struts and can't get it working anymore!
YMMV
----
Hi there, I do this a lot. The simplest is by simply specifying which method you want to use in your input form:

your jsp:


Each button will launch DoSomething.action but will look to try and call a method called insert() or update() instead of execute().

Cheers
13 years ago
Thanks for your help David, it's much appreciated. I think I am just fairly unclear about how struts fits into the whole http request/response cycle, and sometimes think it is being a bit more magic than it really is. You have shed some light on it.

sn
13 years ago
Hello, yes there's a cluster of application servers (Borland Enterprise Server) that all use a centralised session storage server in preference to their local stores. The centralised server is on a different physical machine so there is quite an overhead in session access.
13 years ago
Thanks for your message David, the code for ServletConfigInterceptor is much smaller than I imagined.

David Newton wrote:I'm not sure what you're talking about when you say that every "put" requires a "session refresh".



Well, exactly that though I didn't use the phrase "session refresh". If I am in my action, and I do getSession().put(blah, blah) ten times, does that hit the http session server ten times? It looks to me like it must do, since there is nothing in the interceptor that will roll up all my modifications to the session map and send them back to the http session server in one go. Unless this happens at a deeper level in the ActionContext.

Can anyone clarify? And if it _does_ do a http hit every time a value is updated, is there a way to roll them up? Actually I suppose I could just use a local HashMap for my updates and then do a getSession().putAll(localMap). Any downside to that? Am I reinventing the wheel?

Thanks!
13 years ago
Hello everyone, can a struts expert help clear up the vagueness I have about how struts 2 runs sessions? I have a large application that has action classes using sessionaware and the servletconfig interceptor is running, and it all works fine, but it does a few things more than once (belt and braces). I'm trying to optimise it a bit, to snip out some code that just duplicates activity that struts does anyway.

My understanding of the process is:
1. servletConfig (inteceptor on the way in) gets the http session from the server request and calls setSession() to put it into my action class. This creates a local version of the map that my class can use during the lifetime of the action.
2. I explicitly put some stuff into that map (in the action), and take some stuff out while doing my execute().
3. servletConfig (on the way out) puts the contents of the map into the http session.

So manipulation of the map in the action class itself has no real I/O cost, because it doesn't get fired back to the server until the action is finished. So I don't need to be worried about multiple .put()s creating lots of session traffic.

Am I right? Because I thought I had read somewhere (online) that the http session is explictly updated every time any value is put() into the map in the action class, but now I can't find that article again, and it seems a bit wasteful to be true.

To put it in context, this app historically had huge objects in the session (1MB+), and our session storage server keeps logs of all data going in or out for transactional safety, and those transactional logs were out of control (hundreds of GB a day), and there were strong suspicions that struts' way of handling sessions was making this worse than it might otherwise be, since each put() required the session map getting afresh. The size of the session objects is much (MUCH) smaller now, so it's a bit of a moot point, but I'd prefer to know exactly whats going on.

Thanks!
13 years ago
Ok thanks David, that's really helpful. I've been diverted onto other stuff right now, but will be coming back to this problem at some point, so will be bear your advice in mind.

Cheers again!
SN
14 years ago
David, thanks for you reply. I'd always been told we never had any interceptors in the application, but I think what was meant by that was that we didn't have any custom interceptors, not that interceptors weren't running at all (I could never really understand how _anything_ worked at all, if there were no interceptors - assumed it was some strutsy magic beyond my comprehension at work). Because I've just had a look at the struts-default.xml in my struts core 2.0.9 jar and it's got all the interceptors I'd expect to see there. Rrr.

So I'm back to square one really, except that I notice it's quite an old version of the struts library that we're using, so I wonder if it might be a bug that has been fixed since then?


THanks for your help, very much appreciated.
SN
14 years ago
Hi David, thanks a lot for the reply. You incredulity speaks volumes, and is almost what I was hoping someone was going to say. Yes the interceptor stack is empty (as far as I can see). The application is a bit unusual in that it was snipped weirdly off from a much larger s2 application, and has a few foibles because of that... I was experimenting with ajax-ing it up (wondering slightly why nobody had tried it before - and I guess this is why).

I suppose that's the end of that then. Is it surprising that anything works at all?

Thanks again,
SN
14 years ago
Hi gang, my first post here, but have searched high and low for an answer to this problem that works... To no avail! I hope someone can tell me to keep trying, or to give up!

I have a form for operating a PC seat booking system that I'm trying to put together using the struts2 ajax functionality.
The form has a s:datetimepicker, and a s:select field (for a seat type), and two buttons. I would like each button to trigger a different action eventually, but can't seem to figure out how to do it.

Here is the code I'm working on at the moment (I have a bean called "detail" instantiated in my action, which gets loaded with seatType and seatDateFromString, and submitValue) :



In this the form is POSTed to a handler method in the action, in which I hoped to look at detail.submitValue to see which button was pressed, and then branch based on that. detail.submitValue always just ends up as null.

I also tried

Which works lovely and goes directly to the right methods in the action that I've set up in some s:url, but it doesn't include the rest of the form data that I actually want posting. If I add formId="detailControlForm" to the s:submit tags, then both submit tags revert to submitting the base action associated with the page, though they do include the form fields.

I also tried


Which does the same: triggers Flexi.action (the base action for this page). If I remove the formId="..." from the submit tags, then the correct actions get triggered, but obviously with no field contents included.

I am sure that at least one of these should work! I don't have any interceptors in the interceptor stack however, so I wonder if that takes care of this struts magic in a way I don't understand!

Maybe someone can help me, let me know I am barking up the wrong tree entirely perhaps!

Thanks!

SN
14 years ago