Questions tagged [model-driven]

An interface to support model component of the Struts2 MVC architecture.

An interface to support model component of the Struts2 MVC architecture. This interface should implement action classes which applying a user model as a generic parameter. If an action class implements the interface ModelDriven then it needs to return an object from the getModel() method. Struts2 will then populate the fields of this object with the request parameters, and this object will be placed on top of the valueStack once the action is executed. Validation will also be performed on this model object, instead of the action.

ModelDriven action uses it's own interceptor modelDriven which included in the defaultStack interceptor stack. Thus every action that uses that stack invokes this interceptor to check if an action is instance of ModelDriven then applying a model to it.

There's also a ScopedModelDriven interface that is used for models that has lifecycle for the specified scope.

128 questions
2
votes
1 answer

Struts2 actionError not displaying on jsp when action implemented ModelDriven

I have my Struts2 Action class as below and I am expecting the actionerror message should be displayed in my JSP page using the tag: However the message did not show up, and I've found that if I change in the getModel() method…
HK Cheung
  • 21
  • 3
2
votes
2 answers
2
votes
1 answer

How to perform XML Validation when using ModelDriven?

I've created a Struts2 project in which I used XML based validation. Model class RegistrationForm is shown below package com.projects; import com.opensymphony.xwork2.ActionSupport; public class RegistrationForm implements Serializable{ private…
Sumit Kamboj
  • 846
  • 2
  • 10
  • 17
2
votes
1 answer

How to create custom methods using Struts2 REST plugin

My problem concerns the creation of a custom method within an action. I'm using Struts2 and REST Plugin in order to implement a RESTful WebService. My action class is the following: public class SampleController implements ModelDriven
2
votes
2 answers

Why submitting a form with Ajax it's not setting model data using ModelDriven in Struts 2?

I have following situation in code: Action class: @NameSpace("/") public class MyAction extends ActionSupport implements ModelDriven { private Car car = new Cart(); @Override public Car getModel() { return car; } …
Dariusz Mydlarz
  • 2,940
  • 6
  • 31
  • 59
2
votes
1 answer

Error setting expression 'spa.amount' with value '[Ljava.lang.String;@10dd65e' )

I am trying following code to get data in spa object fields. Thus, I am using the following code but it is showing null values and giving the following error Error setting expression 'spa.amount' with value…
xrcwrn
  • 5,339
  • 17
  • 68
  • 129
2
votes
2 answers

Use YANG Tools as a Java code generator for MD-SAL in Opendaylight

Recently I study the API definition for Opendaylight. As we know, YANG is a modeling language for NETCONF. However, Opendaylight uses it as a Java code generator for MD-SAL. So I am wondering : How does YANG Tool help generate Java code for…
2
votes
2 answers

POST request doesn't load the form values into the model using ModelDriven in Struts 2

I am attempting to create a dynamic web application using the ModelDriven interface with Struts 2. I have worked with Struts1, but this is my first attempt at Struts 2. I am able to populate a form from the values stored in the database, but when I…
Todd F
  • 35
  • 9
2
votes
1 answer

Using a drop-down list in a model driven action class in Struts2

I'm populating an from database. The action class is model-driven. @Namespace("/admin_side") @ResultPath("/WEB-INF/content") @ParentPackage(value="struts-default") public final class TestAction extends ActionSupport implements…
Tiny
  • 27,221
  • 105
  • 339
  • 599
2
votes
1 answer

How to set the property value for model object in action class using ModelDriven in Struts 2?

Using this code: StudentAction.java: public class StudentAction extends ActionSupport implements ModelDriven { private List studentList; Student student; StudentDAO sdo = new StudentDAO(); public String delete() { …
manish Sahu
  • 129
  • 2
  • 5
  • 13
2
votes
1 answer

How to use the alias interceptor for the properties of utility class object in action

I have an Action class named MyFirstClass in which I have a String variable and a User variable as follows: public class MyFirstClass extends ActionSupport implements ModelDriven,Preparable { User user; private String nickName; …
SagarS
  • 21
  • 1
  • 6
2
votes
2 answers

Whats the most efficient way to define a variable and a class that are used by different methods of a class?

I have few questions about efficient memory usage. I have a form which will be submitted to receive a list of items as result. Once form is submitted its fields will be received by request variable and will be processed by submitRequest method of…
2
votes
1 answer

How to provide two forms using ModelDriven in Struts 2

I have this code to implement ModelDriven mechanism. public class Input_newAction extends CommonAction implements ModelDriven { private InputForm form = new InputForm(); @Override public InputForm getModel() { return…
emeraldhieu
  • 9,380
  • 19
  • 81
  • 139
2
votes
1 answer

How to implement validations using annotations in struts2 in action that implements ModelDriven interface?

I am trying to implement validation using annotations, but these validations don't work and the form gets submitted with null values. I don't know what is missing, how to implement validations using annotations in struts2 in action that implements…
user2077648
  • 951
  • 7
  • 27
  • 42
2
votes
3 answers

In Struts2 I am not getting form value on success.jsp page

In my application I am trying to register a user by adding his details to the database and after success fully insert these values. I need to display form input page but on result page I am not getting any output. My ACTION CLASS IS package…
Arvind
  • 1,548
  • 17
  • 23
1 2
3
8 9