1

I want Array of JSON object at server side stagewiseMenuDisplayViewValueList by request -- Below is my client code written in angularJS app file

    var url={};
    
    url.objectId =tabconfig.objectId;
    url.objectRevision =tabconfig.objectRevision;
    url.objectName =tabconfig.objectName; 
    url.Selected_sub_tab = tabconfig.selectedSubTabId;
    url.stagewiseMenuDisplayViewValueList = stagewiseMenuDisplayViewValueList;
    
    var urlString = ResourceUtil.fnBuildRequestString(null,url,null);

    var dataUrlDefault = "projectData.do?action=getAddStagewiseMenuAttributeListJSON&"+urlString;
    var c = this;
    c.formData = [];

    FormLoaderService.getFormConfiguration(tabconfig,'Create',dataUrlDefault).then(function(data)
    {
        $scope.attributeJsonArr = data.attributeJsonArr;
        
        $scope.workflowStages = $scope.attributeJsonArr[4];
        $scope.selectedWorkflowStage = selectedStageValue;

        angular.forEach($scope.attributeJsonArr,function(value,index)
        {
            $scope.metaAttribute.push(value);
        });
    }, function()
    {
        $log.error('Could not receive names.')
    });

I get all the data at server side sent by client except stagewiseMenuDisplayViewValueList Here's my server side code in struts Action file-

public void getAddStagewiseMenuAttributeListJSON(HttpServletRequest request, HttpServletResponse 
response) throws HWServerException, HWJDBCException
{
    String transName    = TransactionUtil.generateTransactionName(this);
    Connection conn     = null;
    String contextName  = ContextConfiguration.getContextName();
    HttpSession session = request.getSession();
    Login loginBean     = (Login)session.getAttribute("loginBean");

    String objectId   = request.getParameter(PLMConstants.OBJECT_ID_PARAM);
    String objectRevision   = request.getParameter(PLMConstants.OBJECT_REVISION_PARAM);
    String objectName   = request.getParameter("objectName");
    String Selected_sub_tab     = request.getParameter(ConfigToolConstants.Selected_sub_tab);
    String stagewiseMenuDisplayViewValueList    =       
    request.getParameter("stagewiseMenuDisplayViewValueList");

  //code
  }
  • You need to convert that to `JSONObject` and then pass same to `JSONArray` to access value inside it .Check [this](https://stackoverflow.com/a/18998203/10606400) answer might help you. – Swati Jul 14 '20 at 07:32
  • U mean In this way?? String jsonString = ... ; //assign your JSON String here JSONObject obj = new JSONObject(jsonString); String pageName = obj.getJSONObject("pageInfo").getString("pageName"); – Satish Hawalppagol Jul 14 '20 at 07:39
  • Yes here `//assign your JSON String` you need to pass `request.getParameter("stagewiseMenuDisplayViewValueList");` and change name of json object and array accordingly. – Swati Jul 14 '20 at 13:53

0 Answers0