How an action1.java can call a method from action2.java?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • makweatan
    New Member
    • Jun 2009
    • 11

    How an action1.java can call a method from action2.java?

    Hi..I am trying to call the method in XC18Action through the xcAction. The error was:

    0000002f SystemErr R at org.apache.comm ons.beanutils.B eanUtilsBean.co pyProperties(Be anUtilsBean.jav a:221)
    0000002f SystemErr R at org.apache.comm ons.beanutils.B eanUtils.copyPr operties(BeanUt ils.java:114)
    0000002f SystemErr R at my.org.hasil.dc ms.grq.web.XC18 Action.performS edia(XC18Action .java:568)

    I dont understand what it wants...

    These are the methods :

    1.)xcAction.jav a

    Code:
    public ActionForward performSedia(ActionMapping mapping, ActionForm form,javax.servlet.http.HttpServletRequest request,javax.servlet.http.HttpServletResponse response) {
    ActionForward forward = new ActionForward();
    HttpSession httpSession = request.getSession();
    MESSession session = (MESSession) httpSession.getAttribute(DCMSConstants.DCMSConstants_MESSESSION);
    TodoparameterForm todoForm = (TodoparameterForm) httpSession.getAttribute("todoparamForm");
    	XC18BO xcbo = new XC18BO(session);
    	XC18Form xc18form = new XC18Form();
    	XcForm xcForm = (XcForm) form;
    
    	try {
    	//BeanUtils.copyProperties(xcbo, todoForm);
    	BeanUtils.copyProperties(xcbo, xcForm);
    	xcbo.setTodo_id(xcForm.getId());
    	XC18Action xc18Action = new XC18Action();
    	XC18Action.performSedia(mapping, xcForm, request, response);
    			
    			
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    		forward = mapping.findForward("success");
    		return forward;
    	}
    		
    }
    2.XC18Action.ja va

    Code:
    public static ActionForward performSedia(ActionMapping mapping, ActionForm form,javax.servlet.http.HttpServletRequest request,		javax.servlet.http.HttpServletResponse response) {
    ActionForward forward = new ActionForward();
    HttpSession httpSession = request.getSession();
    MESSession session = (MESSession) httpSession
    				.getAttribute(DCMSConstants.DCMSConstants_MESSESSION);
    TodoparameterForm todoForm = (TodoparameterForm) httpSession.getAttribute("todoparamForm");
    XC18BO xcbo = new XC18BO(session);
    XC18Form xc18form = (XC18Form) form;
    		
    
    try {
    BeanUtils.copyProperties(xcbo, todoForm);
    BeanUtils.copyProperties(xcbo, xc18form);
    xcbo.setTodo_id(xc18form.getId());
    xcbo.setStatus(DCMSConstants.USERTODO_STATUS_SEDIA);
    xcbo.processXC18();
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    		forward = mapping.findForward("success");
    		return forward;
    	}
    Please someone tell me how to solve this. Thank u.
  • chaarmann
    Recognized Expert Contributor
    • Nov 2007
    • 785

    #2
    Code:
    0000002f SystemErr R at my.org.hasil.dcms.grq.web.XC18Action.performSedia( XC18Action.java:568)
    This line tells you to look at line 568 in XC18Action.java . So what is there? Please list it here, it's impossible to guess.

    By the way, improve your programming style by ALWAYS checking the returned value. If you get a stored object from session, it might well be that it is not there, and null will be returned instead! So calling "obj=httpSessio n.getAttribute( ...)" and then right away using it with obj.method() is suicide! You should make sure that your program also behaves well in case of errors. Not checking for errors with a simple "if (obj == null) then printError()" takes much more time than the seconds you saved by not typing this code. I bet with you if you would have typed this simple if-statement everwhere you already would have solved the problem yourself which would have taken less time than asking in forum and reading answers.

    Comment

    Working...