When you use a struts framework, where would you place your business logic

Showing Answers 1 - 26 of 26 Answers

preeti

  • Jun 29th, 2005
 

Business Logics are placed in the action class

  Was this answer useful?  Yes

D.S.Reddy

  • Sep 12th, 2005
 

We know how servlets and JSP's applications will be . They are all Model1 arcitectures. where we cant get the MVC (M2c) model architecture .So, we use this structs framework. And in this we can write the Business logic in Action class which is also called as Model part. And we write Presentation Logic in View Part of the architecture. And the Controller part acts as the controller and gives the mappings between the Model Part and the VIew parts of the application

  Was this answer useful?  Yes

bhore.vijay

  • Apr 13th, 2007
 

In Struts we should embed the business logic in Manager class.
 The Manager class should be instantiated in Action class.
 Using this object of Manager class a method from Manager class should be called.
e.g. LoginAction should call method from LoginManager using the instance loginManager.  All the Manager class should have the business logic in a method
e.g. method which returns boolean value 

     class LoginManager{

        public boolean authenticateUser(loginForm) {
        
              // business logic

        }
    }

  Was this answer useful?  Yes

reddyonlinenow

  • May 19th, 2007
 

Action class comes under controller it calls the model what ever we use such as business delegate or DAO.

Action class does not come under model.

  Was this answer useful?  Yes

Ram

  • Jun 21st, 2007
 

Action class forms part of the Model in struts... A class which has some logic need not always be a part of controller. The primary intention of the Action class is to Act on the Data that is submitted, and delegate it for further business processing, reiterating that it is in fact the Model component.

Even if you take in Swing, any Model class will not only have data for the corresponding component, but also have certain trigger methods such as fireXYZ(), which can be used to notify any intended recipient of change in data.

For instance, when a cell's data is changed, the controller needs to be notified by the model to render the cell appropriately. Hence, when the setValueAt() method is called, it is coded to invoke a trigger method fireTableCellUpdated, which in turn notifies any associated TableModelListener to take appropriate action.

  Was this answer useful?  Yes

aniruthmp

  • Dec 5th, 2007
 

Struts forms MVC 2 architecture.. struts-config.xml forms the "Controller". Action Class SHOULD NOT have Business logic. The reason is, Action classes are not instantiated by the user/developer. It is automatically instantiated by the Controller. Always there will be only 1 INSTANCE of the action class (you can verify this by havin a Class variable and try incrementing the same by various requests). So, from action class instantiate a new Java class for each request in which business logic should be present. 

Also, Action class is not the Model class. Please correct yourself.



            when we want to seperate the presentation logic(view ) and bussiness logic
then we go for Model view controller architecture, Struts a frame work which builds on that Arichetecture.so we use Struts.


           Bussiness logic is written in ActionServlet of struts frame work

  Was this answer useful?  Yes

When we want to develop complex applications , you can use struts framework.Strtus framework is based on MVC architecture. Actually we have model classes to develop businesslogic .you can access model classes from execute() method of Action class

  Was this answer useful?  Yes

When we are using struts the action class should not contain the business logic if we are adding in action class then it is not right because action class are instantiated by controller.So we can use other java classes like helper classes where we will keep our business logic and then we can instantiate them in action class.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions