Package com.wizriver.web.actions

Source Code of com.wizriver.web.actions.PointAction

package com.wizriver.web.actions;

import java.util.Date;
import java.util.List;

import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.PropertyFilter;
import org.springside.modules.utils.web.struts2.Struts2Utils;

import com.wizriver.entity.beans.Point;
import com.wizriver.service.account.PointManager;
import com.wizriver.web.CrudActionSupport;

@Namespace(value="/point")
@Results( { @Result(name = CrudActionSupport.RELOAD, location = "point.action", type = "redirect") })
public class PointAction extends CrudActionSupport<Point>{
   
    private static final long serialVersionUID = 1L;

    private Long id;
   
    private Point entity;
   
    private Page<Point> page = new Page<Point>(5);
   
    public Page<Point> getPage() {
        return page;
    }

    public void setPage(Page<Point> page) {
        this.page = page;
    }

    private PointManager pointManager;
    @Autowired
    public void setPointManager(PointManager pointManager) {
        this.pointManager = pointManager;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Point getEntity() {
        return entity;
    }

    public void setEntity(Point entity) {
        this.entity = entity;
    }


    @Override
    public String delete() throws Exception {
        pointManager.deletePoint(id);
        return RELOAD;
    }

    @Override
    public String input() throws Exception {
        return INPUT;
    }

    @Override
    public String list() throws Exception {
        List<PropertyFilter> filters = PropertyFilter.buildFromHttpRequest(Struts2Utils.getRequest());
        if (!page.isOrderBySetted()) {
            page.setOrderBy("id");
            page.setOrder(Page.ASC);
        }
        page = pointManager.searchPoint(page, filters);
        return SUCCESS;
    }

    @Override
    protected void prepareModel() throws Exception {
        if (id != null) {
            entity = pointManager.getPoint(id);
        } else {
            entity = new Point();
        }
    }

    @Override
    public String save() throws Exception {
        entity.setCreateTime(new Date());
        pointManager.savePoint(entity);
        return RELOAD;
    }

    @Override
    public Point getModel() {
        return entity;
    }
}
TOP

Related Classes of com.wizriver.web.actions.PointAction

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.