Package com.iiiss.ssh.actions

Source Code of com.iiiss.ssh.actions.ColumnAction

/*
* References:
*   https://cwiki.apache.org/WW/convention-plugin.html
*     Action annotation
*     Result annotation
*     Namespace annotation
*
* Libraries:
*   struts2-convention-plugin-X.X.X.X.jar
*/
package com.iiiss.ssh.actions;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.iiiss.ssh.actions.requests.ColumnAddRequest;
import com.iiiss.ssh.core.entities.Column;
import com.iiiss.ssh.core.services.ColumnService;

@Controller
@Namespace("/column")
@Result(name = "failure", location = "../example.jsp")
public class ColumnAction {

  private ColumnAddRequest car = new ColumnAddRequest();

  @Autowired
  private ColumnService columnService;

  private String information;

  @Action(value = "add", results = { @Result(name = "succeed", location = "../example.jsp") })
  public String add() {
    try {
      Column column = columnService.add(car.getName(), car.getParentId());
      information = column.toString();
      return "succeed";
    } catch (Exception e) {
      information = e.getMessage();
      e.printStackTrace();
      return "failure";
    }
  }

  @Action(value = "inquire-all", results = { @Result(name = "succeed", location = "../example.jsp") })
  public String inquireAll() {
    try {
      information = columnService.inquireAll().toString();
      return "succeed";
    } catch (Exception e) {
      information = e.getMessage();
      e.printStackTrace();
      return "failure";
    }
  }

  public ColumnAddRequest getCar() {
    return car;
  }

  public String getInformation() {
    return information;
  }

}
TOP

Related Classes of com.iiiss.ssh.actions.ColumnAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.