How can I generate dynamic menu & menu items from a list generated at Action? I tried this approach but it is generating only main menu but not sub-menus. Action class: JSP: What can i do to get Menu with menu items? Example classes structure: How to configure this in JSP page with sj:menu tag? Answer The <sj:menu> tag generates
Tag: struts2
404 error when referencing fileUpload interceptor in Struts 2
I am using struts.xml file which is described below : It was working before I added the last action upload. When I start the server it is showing me the 404 error. Can somebody help me out in resolving the issue. I am feeling that the issue is due to <interceptor-ref name=”fileUpload”>. Answer Try to add after <interceptor-ref name=”fileUpload”> <interceptor-ref
Where is the best place to begin transaction using Hibernate in a tired web application with Struts 2?
I got this Java web application which uses Struts 2 and Hibernate. In the most upper layer comprises of the Struts 2 action classes. Then there are my business logic classes which are responsible for the logic of the application. Finally there is a DAO layer (called Database Bridge) which is responsible for communicating with the database. Currently I open
How to pass an object from front-end to Struts 2
I am trying to send value of a field to Struts2 back-end through JavaScript but it returns NullpointerException. Once form is submitted the request will be sent to the following JavaScript method to be sent to back-end. the request will be created and sent as following But in back-end when I try to show the value it returns NullPointerException. Java:
Save drop-down list value to database in Struts 2 with Hibernate
I want to save the selected value of drop-down list into the database. First index.jsp is loaded. From index.jsp, we can go to register.jsp when we click register URL of index.jsp. struts.xml: index.jsp: register.jsp: Action class is: the drop down list is actually only one of the form fields. there are other fields also in the form. All values other
How to pass an action name using hyperlink in Struts 2?
I have a hyperlink named “Click for new User”. Once I click the link, I got NullPointerException instead of opening RegisterPage.jsp page. I post my code here, I can’t find my mistake index.jsp: struts.xml: Login.java(Action Class): Exception: Answer When you click on hyperlink you don’t supply the request URL with parameters username and password (the parameters aren’t set by the
No action mapped error while running Struts 2 app on Netbeans 7.3.1
Trying to build a Struts 2 app which directs the user to a page (Display.jsp) that shows the color of a user defined RGB color configuration. I get the example from the Struts 2 Tutorial by Budi Karniawan. When I manually cut and paste the source code and build the app manually as an NB Web application, it runs fine
How to use DispatcherListener in Struts 2
There is a interface DispatcherListener in Struts2. The docs says “A interface to tag those that want to execute code on the init and destroy of a Dispatcher.” But how to use this interface. If I create a class that implements this interface, how should I configure it to Struts2? Answer When a Dispatcher is instantiated, it could send to
Identifying each field in Multiple File upload
When trying to upload multiple files with Struts 2 using ArrayList, how to identify each field? For example, if I have two file fields, File1 and File2 and on the client side, I choose to upload only File2, Struts 2 only creates one element in the list and I am not able to correctly map File1 as empty and File2
Struts 2 workflow interceptor and actions that do not have an INPUT result
If I understand, the Struts 2 interceptor stack correctly, the workflow interceptor looks to see if any validation failures have been reported by the validation interceptor. If it finds that there have been validation failures, it returns ( by default ) Action.INPUT If this is the case, what happens if the Action that is being executed does not have an