Hi

I'm having troubles in obtaining my data from the getCurrentRowObject
becasue it returns only object and I cant cast it back to ArrayList. In my
entity class it is List<Category> parents = new ArrayList<Category>();  I
didnt get solutions from google. Can anyone please help me out??? I really
need this to make my own decorator so that I can show that list of data in
the display:column.......Please help me. Many thanks..

======= Category.java ==========

import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.*;

/**
 *
 * @author xingxing
 */
@Entity
@Table(name="category")
public class Category extends BaseObject {

    /**
         * 
         */
        private static final long serialVersionUID = -2439698589359221687L;
        private Long id;
    private String name;
    private String description;
    private Date create_time;
    private Date update_time;
    private List<Category> children = new ArrayList<Category>();
    private List<Category> parents = new ArrayList<Category>();
    private String parent_name = "";
    
    @Column(name="create_time", nullable=false)
    public Date getCreate_time() {
        return create_time;
    }

    public void setCreate_time(Date create_time) {
        this.create_time = create_time;
    }
    @Column(name="description", length=2048)
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
    @Id @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name="cid")
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
    @Column(length=50, nullable=false)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    
    public Date getUpdate_time() {
        return update_time;
    }
    @Column(name="update_time")
    public void setUpdate_time(Date update_time) {
        this.update_time = update_time;
    }

    
    
    /**
         * @return the category_rel
         */
    
    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name="category_rel",
        [EMAIL PROTECTED](name="parent_id")},
        [EMAIL PROTECTED](name="child_id")}
    )
        public List<Category> getChildren() {
                return children;
        }

        /**
         * @param category_rel the category_rel to set
         */
        public void setChildren(List<Category> children) {
                this.children = children;
        }

        
        
        /**
         * @return the parent_name
         */
        @Transient
        public String getParent_name() {
                
//              return "cc";
                
                return this.parent_name;
        }

        /**
         * @param parent_name the parent_name to set
         */
        public void setParent_name(String parent_name) {
                this.parent_name = parent_name;
        }

        /**
         * @return the parents
         */
        @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name="category_rel",
        [EMAIL PROTECTED](name="child_id")},
        [EMAIL PROTECTED](name="parent_id")}
    )
        public List<Category> getParents() {
                return parents;
        }

        /**
         * @param parents the parents to set
         */
        public void setParents(List<Category> parents) {
                this.parents = parents; 
        }

        @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Category other = (Category) obj;
        if (this.id != other.id && (this.id == null ||
!this.id.equals(other.id))) {
            return false;
        }
        if (this.name != other.name && (this.name == null ||
!this.name.equals(other.name))) {
            return false;
        }
        if (this.description != other.description && (this.description ==
null || !this.description.equals(other.description))) {
            return false;
        }
        if (this.create_time != other.create_time && (this.create_time ==
null || !this.create_time.equals(other.create_time))) {
            return false;
        }
        if (this.update_time != other.update_time && (this.update_time ==
null || !this.update_time.equals(other.update_time))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 23 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 23 * hash + (this.name != null ? this.name.hashCode() : 0);
        hash = 23 * hash + (this.description != null ?
this.description.hashCode() : 0);
        hash = 23 * hash + (this.create_time != null ?
this.create_time.hashCode() : 0);
        hash = 23 * hash + (this.update_time != null ?
this.update_time.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
//        throw new UnsupportedOperationException("Not supported yet.");
        String retval = "";
        retval = this.id + " " + this.name + " " + this.description + " (P) " +
this.parents.toString()+ " C " + this.children.toString();;
        return retval;
    }

}


=========== categoryList.jsp ==============

<%@ include file="/common/taglibs.jsp"%>

<head>
    <title><fmt:message key="categoryList.title"/></title>
    <meta name="heading" content="<fmt:message
key='categoryList.heading'/>"/>
    <meta name="menu" content="CategoryMenu"/>
</head>

<c:set var="buttons">
    <input type="button" style="margin-right: 5px" class="button"
        onclick="location.href='<c:url value="/editCategory.html"/>'"
        value="<fmt:message key="button.add"/>"/>

    <input type="button" class="button" onclick="location.href='<c:url
value="/mainMenu.html"/>'"
        value="<fmt:message key="button.done"/>"/>
</c:set>

<c:out value="${buttons}" escapeXml="false" />

<display:table name="categories" class="dataTable" requestURI=""
id="categoryList" export="true" pagesize="25"
decorator="org.saascentral.app.util.MyDecorator">
    <display:column property="id" class="hidden" sortable="true"
href="editCategory.html" media="html"
        paramId="id" paramProperty="id" titleKey="category.id"/>
    <display:column property="id" media="csv excel xml pdf"
titleKey="category.id"/>
    <display:column sortProperty="create_time"  sortable="true"
titleKey="category.create_time">
         <fmt:formatDate value="${categoryList.create_time}"
pattern="${datePattern}"/>
    </display:column>
    <display:column property="description"  sortable="true"
titleKey="category.description"/>
    <display:column property="name"  sortable="true"
titleKey="category.name"/>
        <display:column property="parent_name"  sortable="true" 
titleKey="Parent"/>
        <display:column property="parents"  sortable="true" 
titleKey="Parentsss"/>
    <display:column sortProperty="update_time" sortable="true"
titleKey="category.update_time">
         <fmt:formatDate value="${categoryList.update_time}"
pattern="${datePattern}"/>
    </display:column>

    <display:setProperty name="paging.banner.item_name"><fmt:message
key="categoryList.category"/></display:setProperty>
    <display:setProperty name="paging.banner.items_name"><fmt:message
key="categoryList.categories"/></display:setProperty>

    <display:setProperty name="export.excel.filename"><fmt:message
key="categoryList.title"/>.xls</display:setProperty>
    <display:setProperty name="export.csv.filename"><fmt:message
key="categoryList.title"/>.csv</display:setProperty>
    <display:setProperty name="export.pdf.filename"><fmt:message
key="categoryList.title"/>.pdf</display:setProperty>
</display:table>

<c:out value="${buttons}" escapeXml="false" />

<script type="text/javascript">
    highlightTableRows("categoryList");
</script>

============ CategoryAction.java ==========

package org.saascentral.app.webapp.action;

import java.util.List;

import org.saascentral.app.model.Category;
import org.saascentral.app.service.GenericManager;

import com.opensymphony.xwork2.Preparable;


public class CategoryAction extends BaseAction implements Preparable {
    private GenericManager<Category, Long> categoryManager;
    private List categories;
    private Category category;
    private Long  id;
    
    public void setCategoryManager(GenericManager<Category, Long>
categoryManager) {
        this.categoryManager = categoryManager;
    }

    public List getCategories() {
        return categories;
    }

        /**
     * Grab the entity from the database before populating with request
parameters
     */
    public void prepare() {
        if (getRequest().getMethod().equalsIgnoreCase("post")) {
            // prevent failures on new
            String categoryId = getRequest().getParameter("category.id");
            if (categoryId != null && !categoryId.equals("")) {
                category = categoryManager.get(new Long(categoryId));
            }
        }
    }

    public String list() {
        categories = categoryManager.getAll();
        return SUCCESS;
    }

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

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    public String delete() {
        categoryManager.remove(category.getId());
        saveMessage(getText("category.deleted"));

        return SUCCESS;
    }

    public String edit() {
        if (id != null) {
            category = categoryManager.get(id);
        } else {
            category = new Category();
        }

        return SUCCESS;
    }

    public String save() throws Exception {
        if (cancel != null) {
            return "cancel";
        }

        if (delete != null) {
            return delete();
        }

        boolean isNew = (category.getId() == null);

        categoryManager.save(category);

        String key = (isNew) ? "category.added" : "category.updated";
        saveMessage(getText(key));

        if (!isNew) {
            return INPUT;
        } else {
            return SUCCESS;
        }
    }
    
}




Regards
xing
-- 
View this message in context: 
http://www.nabble.com/-Newbie-getCurrentRowObject-tp19730239p19730239.html
Sent from the DisplayTag - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
displaytag-user mailing list
displaytag-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to