Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

how to make a prepare method in struts 2

kamal.javaMar 11 2014

Hi i am having the following action in my struts application, but m stucked up wid the problem where i want to implement preparable interface and use of customize methods like prepareCreate() etc see the action below :    

package manning.chapterThree;

import static com.opensymphony.xwork2.Action.SUCCESS;

import manning.chapterThree.utils.PortfolioService;

import manning.chapterThree.utils.User;

import com.opensymphony.xwork2.ActionSupport;

import com.opensymphony.xwork2.Preparable;

/*

* This is our first version of the Register action.  This version uses

* the basic validation and message localization services provided by the

* ActionSupport help class.  By extending this class, we automatically

* receive implementations of several interfaces that allow us to do

* validation and localize our message texts with out polluting the

* execute() method of our action.  

*/

public class Register extends ActionSupport implements Preparable{

   

        @Override

    public String execute(){

               

                create();

        /*

         * Create and move the data onto our application domain object, user.

         */

           

//        User user = new User();

//        user.setPassword( getPassword() );

//        user.setPortfolioName( getPortfolioName() );

//        user.setUsername( getUsername() );

//       

//        getPortfolioService().createAccount( user );

              

        return SUCCESS;

    }

   

   

    /* JavaBeans Properties to Receive Request Parameters */

   

    private String username;

    private String password;

    private String portfolioName;

    public String getPortfolioName() {

        return portfolioName;

    }

    public void setPortfolioName(String portfolioName) {

        this.portfolioName = portfolioName;

    }

    public String getPassword() {

        return password;

    }

    public void setPassword(String password) {

        this.password = password;

    }

    public String getUsername() {

        return username;

    }

    public void setUsername(String username) {

        this.username = username;

    }

   

    /* Validateable Implementation

     *

     * The validate method validates, invoked by the validation interceptor in

     * the default stack, will validate the data already set on the action

     * by the params interceptor, also in the default stack. 

     *

     * If this method finds problems in validation it stores error messages via

     * the methods exposed by the ValidationAware interface -- already implemented

     * by the ActionSupport class that this action extends.  To complete the

     * the validation process, the workflow interceptor fires next in the default

     * stack.  It checks for error messages on the action, and if it finds them

     * it diverts workflow back to the input page where the error messages are

     * displayed to the user.  In this case, the execute method of the action

     * will not be called because the workflow was diverted, due to validation

     * problems, before execution reached the action itself.

     *

     * */

   

    public void validate(){

       

        /* Retrieve our simple portfolio service object. */

        PortfolioService ps = getPortfolioService();

       

        /* Check that fields are not empty */

        if ( getPassword().length() == 0 ){           

            addFieldError( "password", getText("password.required") );

        }

        if ( getUsername().length() == 0 ){           

            addFieldError( "username", getText("username.required") );

        }

        if ( getPortfolioName().length() == 0  ){           

            addFieldError( "portfolioName", getText( "portfolioname.required" ));

        }       

        /* Make sure user doesn't already have an account */

        if ( ps.userExists(getUsername() ) ){       

            addFieldError("username", getText( "user.exists"));

        }

       

    }

   

    /* 

     * Simple way to retrieve our business logic and data persistence

     * object.  Late versions of the portfolio app will integrate with

     * more sophisticated technologies for these services.

     */

    public PortfolioService getPortfolioService( )     {

          //   update();

       

        return new PortfolioService();

       

    }

   

   

    @Override

    public void prepare() throws Exception {

        //update();

        create();

        System.out.println("Calling prepare itself");

      //  throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

    }

   

   

    void create() throws Exception

    {

      System.out.println("Calling Update Updating ...");

    }

       

    void prepareCreate () throws Exception

    {

      System.out.println("Prepare Updating ...");           

    }

   

   

}

i called create() on line 26, the framework should call prepareCreate() prior to create , but it is not executing , only prepare method get called , any help will be appreciated , THANKS IN ADVANCE

Comments

Gyanprakash Pandey
Refer doc below:
http://docs.oracle.com/cd/E21764_01/doc.1111/e15478/webgate.htm#BABHCBGG

regards,
GP
user13714831
Hi - Did you get answer to your question? if yes - could you pls share?

Even we are using Apache 2.2.x and OAM 11.1.1.5. I wanted to know if OAM 11g Webgate is available/supported for Apache 2.2.x? As per OAM 11g webgate certification matrix it supports "Oracle HTTP Server 11gR1 (11.1.1.2+) based on Apache 2.2.x" but not sure if Apache 2.2 is certified and supported by 11g agents?
User_BR1OQ
Hi,

As of now Webgate 11g is not supported with Apache 2.2 or any other Apache version. There is a big architecture difference in OHS11g and Apache 2.2, even though OHS11g is based on Apache2.2.

If you need a webgate for Apache2.2 then you should be using 10g webgates.

~Yagnesh
1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 8 2014
Added on Mar 11 2014
0 comments
3,110 views