Results 1 to 12 of 12
  1. #1
    newbiejava is offline Senior Member
    Join Date
    Jan 2010
    Posts
    138
    Rep Power
    0

    Default java.lang.UnsupportedOperationException: Not supported yet

    Hello All,

    I am facing with "java.lang.UnsupportedOperationException: Not supported yet."

    on my code

    private Map<String, Object> session;

    public String execute() {
    Object list = session.get("mylist"); // this line thrown "java.lang.UnsupportedOperationException: Not supported yet."

    could any body please help?

    thanks & regards
    Luc

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default

    map is an interface, which declare a method get. which implementing class do you use? it looks like that this implementation, does not implement this method but throw an exception (UnsupportedOperationException)
    Last edited by eRaaaa; 10-10-2010 at 03:19 PM.

  3. #3
    newbiejava is offline Senior Member
    Join Date
    Jan 2010
    Posts
    138
    Rep Power
    0

    Default

    I am just trying the codes from Struts2 jQuery Plugin Showcase

    any comment?

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,309
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by newbiejava View Post
    I am just trying the codes from Struts2 jQuery Plugin Showcase

    any comment?
    Can you show us the result of this:

    Java Code:
    System.out.println(session.getClass().getName());
    ... before your code throws an exception.

    kind regards,

    Jos

  5. #5
    newbiejava is offline Senior Member
    Join Date
    Jan 2010
    Posts
    138
    Rep Power
    0

    Default

    Hi All,

    sorry, please ignore it .. but I am facing with this

    Java Code:
    Object list = session.get("mylist");
    if (list == null) {
        myHost = HostDAO.buildList();
    } else {
       myHost = (List<Host>) list;
    }
    why it still thrown java.lang.NullPointerException

    please help

    thanks & regards

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by newbiejava View Post
    Hi All,

    sorry, please ignore it .. but I am facing with this

    Java Code:
    Object list = session.get("mylist");
    if (list == null) {
        myHost = HostDAO.buildList();
    } else {
       myHost = (List<Host>) list;
    }
    why it still thrown java.lang.NullPointerException

    please help

    thanks & regards

    Please answer Jos's question so we all know what the issue was and please ask new questions in a new thread. In your new thread, please indicate which line throws the NPE, and which object on that line is null (easily tested by using System.out.println(myObject == null);


    Thank you for your cooperation.

  7. #7
    newbiejava is offline Senior Member
    Join Date
    Jan 2010
    Posts
    138
    Rep Power
    0

    Default

    ok. sorry for this ..
    FYI,
    I am using NetBeans 6.9 and this is my 1st struts learning app.. and I don't know to get the value of System.out.println(session.getClass().getName());
    I tried to use try.. catch .. but I still unable to get its value

    try {

    } catch (Exception ex) {
    System.out.println(session.getClass().getName());
    }

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    No, you simply place the line
    Java Code:
    System.out.println(session.getClass().getName());
    on the line above the one that caused your error in your first post. Jos suspects (as I do) that the variable causing the error does not refer to a java.util.Map object.

  9. #9
    newbiejava is offline Senior Member
    Join Date
    Jan 2010
    Posts
    138
    Rep Power
    0

    Default

    Sorry, again ..:(
    I knew the problem will not occurs if I removed "implements SessionAware" .. but I don't understandy why ?..

    so I thought the problem is not from: Object list = session.get("mylist"); line as I said before.

    could you please advise what's going on there?

    Java Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package example;
    
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Map;
    
    import com.opensymphony.xwork2.ActionSupport;
    import java.sql.SQLException;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.apache.struts2.convention.annotation.Action;
    import org.apache.struts2.convention.annotation.Actions;
    import org.apache.struts2.convention.annotation.Result;
    import org.apache.struts2.interceptor.SessionAware;
    
    /**
     *
     * @author luckay
     */
    public class JQueryGrid extends ActionSupport implements SessionAware {
    
        private String message;
        private static final long serialVersionUID = 5078264277068533593L;
        private static final Log log = LogFactory.getLog(JQueryGrid.class);
        private List<Host> gridModel;
        private Integer rows = 0;
        private Integer page = 0;
        private Integer total = 0;
        private Integer record = 0;
        private String sord;
        private String sidx;
        private String searchField;
        private String searchString;
        private String searchOper;
        private boolean loadonce = false;
        private Map<String, Object> session;
        private List<Host> myHost;
    
        @Actions({
            @Action(value = "/JQueryGrid", results = {
                @Result(name = "success", type = "json")
            })
        }) 
        @Override
        public String execute() {
            try {
                setMessage("Hello Every body in Struts 2");
                System.out.println(session.getClass().getName());
                Object list = session.get("mylist");
                if (list != null) {
                    myHost = (List<Host>) list;
                } else {
                    myHost = HostDAO.buildList();
                }
                setRecord(HostDAO.getHostCount(myHost));
    
                int to = (getRows() * getPage());
                int from = to - getRows();
    
                if (to > getRecord()) {
                    to = getRecord();
                }
    
                if (loadonce) {
                    // All Custumer
                    setGridModel(myHost);
                } else {
                    // Search Custumers
                    if (searchString != null && searchOper != null) {
                        int id = Integer.parseInt(searchString);
                        if (searchOper.equalsIgnoreCase("eq")) {
                            log.debug("search id equals " + id);
                            List<Host> cList = new ArrayList<Host>();
                            Host host = HostDAO.findById(myHost, id);
                            if (host != null) {
                                cList.add(host);
                            }
                            setGridModel(cList);
                        } else if (searchOper.equalsIgnoreCase("ne")) {
                            log.debug("search id not " + id);
                            setGridModel(HostDAO.findNotById(myHost, id, from, to));
                        } else if (searchOper.equalsIgnoreCase("lt")) {
                            log.debug("search id lesser then " + id);
                            setGridModel(HostDAO.findLesserAsId(myHost, id, from, to));
                        } else if (searchOper.equalsIgnoreCase("gt")) {
                            log.debug("search id greater then " + id);
                            setGridModel(HostDAO.findGreaterAsId(myHost, id, from, to));
                        }
                    } else {
                        setGridModel(HostDAO.getHosts(myHost, from, to));
                    }
                }
                setTotal((int) Math.ceil((double) getRecord() / (double) getRows()));
                //session.put("mylist", myHost);
            } catch (Exception ex) {
                System.out.println(session.getClass().getName());
            }
            return SUCCESS;
        }
    
        public String getJSON() throws SQLException {
            return execute();
        }
    
        public String getMessage() {
            return message;
        }
    
        public void setMessage(String message) {
            this.message = message;
        }
    
        /**
         * @return current page of the query
         */
        public Integer getPage() {
            return page;
        }
    
        /**
         * @param page
         *          current page of the query
         */
        public void setPage(Integer page) {
            this.page = page;
        }
    
        /**
         * @return total pages for the query
         */
        public Integer getTotal() {
            return total;
        }
    
        /**
         * @param total
         *          total pages for the query
         */
        public void setTotal(Integer total) {
            this.total = total;
        }
    
        /**
         * @return how many rows we want to have into the grid
         */
        public Integer getRows() {
            return rows;
        }
    
        /**
         * @param rows
         *          how many rows we want to have into the grid
         */
        public void setRows(Integer rows) {
            this.rows = rows;
        }
    
        /**
         * @return total number of records for the query. e.g. select count(*) from
         *         table
         */
        public Integer getRecord() {
            return record;
        }
    
        /**
         * @param record
         *          total number of records for the query. e.g. select count(*) from
         *          table
         */
        public void setRecord(Integer record) {
    
            this.record = record;
    
            if (this.record > 0 && this.rows > 0) {
                this.total = (int) Math.ceil((double) this.record / (double) this.rows);
            } else {
                this.total = 0;
            }
        }
    
        /**
         * @return an collection that contains the actual data
         */
        public List<Host> getGridModel() {
            return gridModel;
        }
    
        /**
         * @param gridModel
         *          an collection that contains the actual data
         */
        public void setGridModel(List<Host> gridModel) {
            this.gridModel = gridModel;
        }
    
        @Override
        public void setSession(Map<String, Object> map) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    }

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by newbiejava View Post
    Java Code:
    public class JQueryGrid extends ActionSupport implements SessionAware {
    
        //....
        @Override
        public void setSession(Map<String, Object> map) {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    }
    Can you explain this? If you can't set your session, I don't see how it will ever be usable.

  11. #11
    newbiejava is offline Senior Member
    Join Date
    Jan 2010
    Posts
    138
    Rep Power
    0

    Default

    :confused:
    sorry, I am unable to explain to you, I am still learning and got the codes from:

    Struts2 jQuery Plugin Showcase

  12. #12
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Replies: 5
    Last Post: 03-17-2011, 02:26 PM
  2. best java supported!!
    By cpanel in forum Reviews / Advertising
    Replies: 4
    Last Post: 01-10-2011, 05:54 PM
  3. Replies: 5
    Last Post: 06-02-2010, 01:05 PM
  4. Replies: 2
    Last Post: 09-18-2008, 07:30 AM
  5. Java Loader error message "UNC paths not supported"
    By Johnny562 in forum New To Java
    Replies: 1
    Last Post: 07-01-2008, 10:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •