Wes Wannemacher

Greenhorn
+ Follow
since Jul 07, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Wes Wannemacher

This may be possible using the built-in validation, but I am not sure if I would trust it. You have to consider that you may have a user who uses a different format than you are hoping for... 2/1/2007 means Feb. 1, 2007 to me, but Jan. 2, 2007 to some. IIUC, Struts2 will attempt to make a "best guess" as to which date format the user will be entering, but IMO, that may not be enough. Whenever I've dealt with dates in the past, I'll make a set of dropdowns which name the month by their proper name, then a separate input for the day and a dropdown for the year. It is more work for the user entering the date, but it is cleaner for me to handle. If you were dealing with the dates as three separate input fields, you could fairly trivially create an expression that tests that the end date comes after the start date.

-W
17 years ago
The app server is finding the tag's class, so my guess is that your jar file may be corrupt, or there is a silly misspelling or something somewhere. A second set of eyes can sometimes help find these types of errors. Could you paste more of the JSP code that is throwing the error?
17 years ago
In Struts2, the Dojo framework is built in. If you are evaluating JavaScript frameworks and planning to use Struts. I would suggest using Dojo, IMO, it will be much easier since it is already integrated for you. If you are unfamiliar with Dojo, check -

http://dojotoolkit.org/
17 years ago
There really is not much to do with Tomcat integration. One starting point might be to download struts2-blank-2.x.war and deploy it in Tomcat. As far as ant integration, I would need to know a bit more. Are you planning on using ant for deploying or building/deploying? I used ant a bunch in the past, but I have not been using it as much lately.

Now, for the learning Struts, I would suggest reading up on the tutorials available online. Struts2 is a very easy to learn framework (I think), and I have a set of articles that I have written personally that might help. Check here -

http://www.wantii.com/wordpress/?cat=3

The articles are listed with the newest at the top, so you might want to start at the bottom article and work your way up.
17 years ago
another thing...

I am pretty sure that servlet-config interceptor is in the default stack. It looks like your package extends "struts-default," so unless you changed the struts-default.xml in struts2-core-2.x.jar (which I would recommend against), then your attempt to insert the interceptor in your action configuration is redundant.
17 years ago
The problem with ServletRequestAware is that your action is now dependent on the JSP/Servlet API. Writing a jUnit test is going to be very difficult. In your situation, I would ask the following - What is it exactly that you need out of the session object and is there another way to get it? Next, I would ask whether or not you might be better off placing this logic in an interceptor... It would seem that you may be trying to get this sort of info just to keep track of where a user came from, etc. By placing this logic in an interceptor, you could then configure it to work on any number of actions.

-Wes
17 years ago
I personally prefer to keep this sort of application startup logic out of Struts altogether. I would suggest creating a single method/API/class (whichever best suits your needs) and then using a ServletContextFilter to run your initialization.

Take a look at ServletContextFilters here -

http://www.onjava.com/pub/a/onjava/2001/04/12/listeners.html
17 years ago
cripe! those smileys made that post hard to read... the article is available here -

http://www.wantii.com/wordpress/?p=13

You'll have to copy/paste the url, I need some practice with UBB Code before I try to make it a real link.
17 years ago
Darnit, I wonder what I did wrong... Oh well, basically, it works like this. Your collection of objects has to implement the java.util.List interface (such as a Vector). Then, you can place a public Vector<Emp> getEmp() method in your Action. Then when you use the s:iterator tag, you tell it that you want to iterate over "emp." The tag will place one of your objects on the value stack for each iteration, which will make the attributes of your Emp class available to s:property.

Here is the code from my example -



In my example, I have a method in my action that looks like this -


The getMessages method makes the Vector available on the value stack, the s:iterator tag finds that method when I say value="messages."

-Merrill Cleaned up the smileys
[ July 09, 2007: Message edited by: Merrill Higginson ]
17 years ago
I am not sure if this is what you are looking for, but I have a post on my blog that contains an example of using <s:iterate>, you can see it here ->

Writing and Configuring Struts2 Actions

The code sample on this page that does it is called GuestBook_messages.jsp. I would suggest reading the whole post though because it will contain other helpful tidbits.

-Wes

--
Discussion of Java, Struts, Spring, Hibernate, etc. http://www.wantii.com
17 years ago
I am not completely sure it would help you, but have you looked at the Displaytag library? displaytag.sourceforge.net/11/

A flexible action that can sort and filter as loosely as you describe would be pretty difficult to maintain. I would look to see if you could retrofit your problem into using displaytag and you'll be happy you did.

-Wes
17 years ago
I have also written a set of tutorials and articles that might help you to get started using Struts 2.x. Check it out at www.wantii.com
17 years ago
If you are just starting out using Struts, I would suggest giving serious consideration to Struts 2.x. I have written a series of tutorials and articles that will help you to start from the ground up. Check it out at www.wantii.com
17 years ago