mercredi 1 juillet 2015

How to resolve Null pointer Exception in client server action in gwt?

Here is my client side class Requirement:There is object which 2 references and those 2 references are referenced to 1 more reference with same id and getting the 2 url's from the server side class.

@RegisterInGlobalFactory
public class RedirectClientAction<Context extends ClientContext, Request extends GenericRequest, Response extends GenericResponse>
        extends SubmitRequestAction<Context, Request, Response> {
@Override
protected Event processServerResponse(GenericResponse response) {
Map<String, Object> responseParams = response.getResponseParams();
String refurl_ro = (String) responseParams.get("roref");
String refurl_do = (String) responseParams.get("doref");
String ro_url= "/boeapp.salesorder.nc?object="+refurl_ro;
String do_url=" /boeapp.salesorder.nc?object="+refurl_do;
return super.processServerResponse((Response) response);
}} 

Here in server side class When Approver clicks on Approve, Retention Order should be displayed in sales order Similarly when Approver clicks on Reject button, Disconnect Order should be displayed in sales order screen..

public class RedirectServerAction implements ActionExecutor<GenericRequest, GenericResponse> {
@Override
public void process(GenericRequest request, GenericResponse response) throws Exception {

    Map<String, Object> inputParams = request.getRequestParams();
    BigInteger retentionId = getRetention(inputParams);
    Map<String, String> retentionParameters = getRetentionParams(retentionId);
    Map<String, Object> responseParams = response.getResponseParams();
    for (Map.Entry<String, String> retentionParameter: retentionParameters.entrySet())
    {
        String key = retentionParameter.getKey();
        String value = retentionParameter.getValue();
        response.setResponseParam(key, value);
    }
}

private BigInteger getRetention(Map<String, Object> inputParams) {
    String retentionIdStr = (String) inputParams.get(RETENTION_OT.toString());
    BigInteger retentionId = new BigInteger(retentionIdStr);
   return retentionId;
}

private Map<String, String> getRetentionParams(final BigInteger retentionId) throws ObjectNotFoundException,RemoteException {
    final Map<String, String> retentionParameters = new HashMap<String, String>();
    new PCUtils().performAction(new PCAction<BigInteger, RemoteException>() {

        @Override
        public BigInteger execute(PersistenceContext<MutableNCDataObject> context) throws RemoteException {

            MutableNCDataObject retention = context.getObjectByID(MutableNCDataObject.class, retentionId);
            MutableNCDataObject ro_mutable_object= retention.getReference(ATTR_RO);
            MutableNCDataObject do_mutable_object =retention.getReference(ATTR_DO);
            String status_mutable_object =(String) retention.getValue(STATUS_ATTR);                 
            ro_mutable_sales_order = ro_mutable_object.getReference(BigInteger.valueOf(9062352550013045460L));
            do_mutable_sales_order = do_mutable_object.getReference(BigInteger.valueOf(9062352550013045460L));
             if(status_mutable_object.equals("Approved"))
            {
                retentionParameters.put("roref",ro_mutable_sales_order.toString());
            }
            else if(status_mutable_object.equals("Rejected"))
            {
                retentionParameters.put("doref", do_mutable_sales_order.toString());
            }
             return null;
        }
    }, "default.persistence.unit", AllocationStrategy.REQUIRED_SAME, PresenceScope.TRANSACTIONAL);
     return retentionParameters;
}

}

When i compile my client class with gwt debugger in super dev mode the control is not going into my client class and it is not able to identify my server class and getting NullPointerException: null without any stack trace

Aucun commentaire:

Enregistrer un commentaire