struts2

Setting the default value in Struts2

Hi all, I am setting the value(kind of default value) for a drop down select value from action class in a page(given below). When the page loads the value is beig displayed but the other elements of the dropdown list is not displayed. here is the code. Inside the action class if(getTypeId() == null){ String typeId = request.getPa...

Execute method with arguments through action mapping in struts 2

How would I execute a method with an argument in my model based on the URL? Ie, http://server/MyAction_Arg.action maps to MyClass.MyMethod(Arg)? I tried this: <action name="MyAction_*" method="MyMethod({1})" class="example.MyClass"> <result>page.jsp</result> </action> but I get java.lang.NoSuchMethodException at runtime ...

What can I do about ambigous wildcard patterns in Struts?

I have a problem finding the right wildcard pattern to extract parts of my URL into action parameters in Struts. This is how I set up the action. The intent of the pattern is to capture the last two path elements and then everything that might precede them. <action name="**/*/*" class="com.example.ObjectAction"> <param name="filter">...

How to validate a select tag in struts 2 framework

Hi people, I am a newbie into programming and i am currently employed as a junior programmer. I am currently having some problems validating the select tags in one of my forms. What i actually trying to do is to ensure that one item is selected before the user submits the form . In the form i have; <s:select list="assessmentTypes" head...

Dependency Injection failing - hibernate with struts2 using the full-hibernate-plugin

Hi, i'm trying to use hibernate in a struts2 example using the struts2 full hibernate plugin (http://code.google.com/p/full-hibernate-plugin-for-struts2). I've placed all the Jars in my lib folder: antlr-2.7.6.jar commons-collections-3.1.jar commons-fileupload-1.2.1.jar commons-io-1.3.2.jar commons-lang-2.3.jar commons-logging-1.0.4.ja...

struts2 action avoiding literal duplication

In my struts.xml file, I have: <action name="preregister"> <result>/WEB-INF/views/user/register.jsp</result> </action> <action name="register" class="com.dentlak.user.RegisterAction"> <result name="input">/WEB-INF/views/user/register.jsp</result> <result name="success">/WEB-INF/views/user/email-verification-needed.jsp</resu...

struts2 action not calling properly

On default I want my struts2 app to forward to an action: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"&gt; <struts> <constant name="struts.enable.DynamicMethodInvocation" value="false" /> ...

Problem: no headerValue when list is empty <s:select>

i am using struts 2 i have a tag <s:select list="list" headerKey="All" headerValue="All" multiple="true" name="selectedList" listKey="id" multiple="false" theme="simple" listValue="Name" size="20"> </s:select> When the List is empty it shows the "ALL" in the drop down, i dont want the headerValue to come in drop down when ...

How can one read a text file in a Struts 2 app.

Hi guys. Developing a Struts 2 app I run in a following problem. I need to read a text file that is deployed in web server with my app. How can I access it knowing its relative path. In other words how can I find absolute path if I know relative path inside the deployed directory. When I had similar problem with servlets I used to use t...

Struts Action Validation

Hey People. I have been recently validating Struts 2 actions. In One of my action class, the save method to be precise must have two id's. That is an assessmenttype id and a course id. this is what is have so far. @Test public void testSave() { Assessment assessment = new Assessment(); assessment.setAssessmentType(assessment.get...

In Struts2, how do you share your common html across all pages?

In Struts2, how do you share your common html across all pages? In Asp.net, you've got Master pages, and in Rails there are Layouts. The idea is that your common html (eg the header, menu, and styles) are all easy to maintain because they are in one place, but for the life of me i can't find the equivalent feature in Struts2. Is it cal...

Forcing classpath precedence with Tomcat 5.5 under eclipse

I am currently developing a web application based upon Struts2 & Spring components combined with a set of tier libraries in a company-made framework. These librairies expose sets of spring beans, through blahblah.xml files embedded in the provided jar files. I need to replace some of the implementation classes exposed through such bean...

Getting sitemesh to work with struts2

I'm trying to integrate sitemesh into my struts2 app, but i'm finding that it's not making any difference and isn't showing any errors (or anything sitemesh related at all) in the logs. I've started by following all the documentation on the sitemesh site, had no luck, so now i'm trying to copy what's been done in the sitemesh-example do...

web.xml filter-mapping not forwarding to struts

Hello, I am trying to do something trivial and can't see what I'm missing. I have the following web.xml... <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.do</url-pattern...

Struts 2 data transfer and type conversions for primitive types.

Hi. I'm using java beans with automatic data transfer and type conversion. Ex: public class MyAction { public String execute(){ // .... } private double price; public getPrice(){ return price; } public setPrice(double price){ this.price=price; } } Let my request to be http://localhost:8080/my.action?price=21.3 Then in th...

struts2 - understanding the value stack

I have a question regarding the struts2 value stack. Let's say I have an Action class called RegisterAction that has an execute method as follows: public String execute() { ValueStack stack = ActionContext.getContext().getValueStack(); stack.push(new String("test string")); return SUCCESS; } My struts.xml looks like this: ...

To get multiple checkboxes value

Hi All, I am using Struts 2, JSP and JPA in my project. I have nearly 50 checkboxes in a single page. If i want to get the value of each checkbox in Action class, then i have write 50 getters and setters. Is there any easy way to get the values of all checkboxes in Action class. Thank you, ...

How do I find absolute URL of an action in Struts 2.

Suppose I have two actions details and edit I need to display in the view that corresponds to details action an link that points to edit action. The problem is that I need this link to be absolute. How can I find the URL of edit action? ...

OSGi - How mature is this technology?

I have a requirement where I need to share some web resources (jsp, html, js, images, css etc.) across different Spring based Struts 2 applications. And seems like OSGi can be used to achieve this? Can some one give some pointers on how to achieve this with OSGi? And secondly I want to know is OSGi mature enough to be used in producti...

Struts2 back button and linking

Hello! I am using Struts 2.1.6 with Dojo plugin, whole app has ajax links (sx:a). Did anybody succeed to implement back button functionality and linking to certain content? Does anybody have any experience how to implement? I am planning to implement (if there is no good solution already) something like so: changing address bar li...