Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9212187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:27:54+00:00 2026-06-18T01:27:54+00:00

Hi i want to know if exist a way to avoid duplicate code in

  • 0

Hi i want to know if exist a way to avoid duplicate code in this code. Now i have an action class named CustomerAction this class handle the behaviour of the request (it’s like a controller) and i have a CustomerPOJO with attributes like id, name, last_name etc. Now i have to add attributes to CustomerAction to handle the data submited from the form. Is there any way to bypass the action with my CustomerPOJO ?

public class CustomerAction {

private String nombre;
private String apellido;
private String dni;
private String fechaNac;
private String obraSocial;
private String nroAsociado;
private String plan;
private String password;
private String email;
private String telParticular;
private String telCelular;

private static final Log log = LogFactory
        .getLog(CustomerAction.class);

public String execute() throws Exception {
    if ("cancelar".equals(this.getAccion())) {
        log.debug("Executing 'cancelar' action");
        return "login";
    }

    if ("registro".equals(accion)) {
        log.debug("Executing 'registro' action");
        IReferenceDataBusinessDelegate ud = new ReferenceDataBusinessDelegate();
        ud.signCustomer(this.getNombre(), this.getApellido(),
                this.getDni(), this.getCorreo(), this.getContrasena());

        return "login";

    }
}

public class Customers implements java.io.Serializable {

private long id;
private String dni;
private String name;
private String lastName;
private String email;
private String password;
private String phone;
private String cellphone;
private Date birthDate;
private Date creationDate;
private Date lastAccessDate;
private byte active;
private Set<Profesionales> profesionaleses = new HashSet<Profesionales>(0);
private Set<Pacientes> pacienteses = new HashSet<Pacientes>(0);

public Customers() {
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T01:27:55+00:00Added an answer on June 18, 2026 at 1:27 am

    Yes, use ModelDriven, and use a Customers as the model.

    http://struts.apache.org/2.x/docs/model-driven.html

    You’ll need to make sure the "modelDriven" interceptor is in your stack.

    How/where to initialize the model depends on your particular usage scenario; you can do it in a getter as shown in the docs, in a prepare() method if you need to reload it from the DB, etc.

    I’m not sure what you mean by “bypass the action.”

    Please note that the ad-hoc dispatch mechanism implemented here with the accion parameter duplicates functionality provided by Struts 2 using the method attribute of the action configuration. I don’t recommend using ad-hoc dispatch mechanisms as it makes understand program flow more difficult than necessary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know if exist a way to get the number of likes
I want to know if exists any form to have the Android SDK into
I have an android app it displays web view.I want know the app idle
Want to know ways to store OBJECTS of a Class in some persistent storage.
I know pointers don't exist the way they do in C, but I was
I have this delphi code that basically download a file (using Delphi 2010 +
So I want to know if this is a good idea or a bad
I want to know if there's a way to search from a specific index
I have a list of values, and want to know which ones don't already
I'm currently building tests using Capybara/Rails, and want to know the most reliable/standard way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.