Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    #31
    Originally posted by Isomorphic
    This overview should help de-mystify the server-side processing chain. The simplest way to do what you want is to subclass the IDACall built-in servlet and override handleDSRequest. In this method, generate the XML DataSource definition dynamically and call DataSource.fromXML(). You can then take the DSRequest and pass it to DataSource.execute().
    I've discovered that by subclassing IDACall and overriding handleDSRequest I have bypassed the standard logic to handle "requiresAuthentication". Is there a super method I should be calling in the real IDACall? Or is there a better place to do this?

    Comment


      #32
      I discovered what seems to be the correct solution through a little trial and error. In my subclass of IDACall I'm overriding handleDSRequest() but only to provide a customized version of the data source definition. So instead of calling DataSource.execute() directly, I use DSRequest.setDataSource() to use my generated data source and then let the standard IDACall.handleDSRequest() take over.

      dsRequest.setDataSource(ds);
      return super.handleDSRequest(dsRequest, rpc, context);

      Comment


        #33
        That's correct. Authentication checks both happen prior to DataSource.execute() in the request processing flow, because programmatically issued server-side DSRequests should be able to bypass authentication.

        Comment


          #34
          Hello,

          After lots of errors and trials i was able to write the code suggested in this thread. But after running code i am getting following warning on runtime:

          WARN: Operation type 'fetch' not supported by this datasource.

          Below is the extended class from IDACall
          Code:
          public class SupplyMasterDS extends IDACall {
          
          	public DSResponse handleDSRequest(DSRequest dsRequest,
                      RPCManager rpc,
                      RequestContext context) throws Exception {
          		DSResponse resp = new DSResponse();
          		String xmlString =
          			    "<DataSource\r" +
          			    "    ID=\"dynamicSupplyItem\"\r" +
          			    ">\r" +
          			    "    <fields>\r" +
          			    "        <field name=\"customID\"      type=\"sequence\" hidden=\"true\"       primaryKey=\"true\"/>\r" +
          			    "        <field name=\"customName\"    type=\"text\"     title=\"CustomerItem\"        length=\"128\"       required=\"true\"/>\r" +
          			    "        <field name=\"SKU\"         type=\"text\"     title=\"SKU\"         length=\"10\"        required=\"true\"/>\r" +
          			    "        <field name=\"description\" type=\"text\"     title=\"Description\" length=\"2000\"/>\r" +
          			    "        <field name=\"units\"       type=\"text\"     title=\"Units\"       length=\"5\">\r" +
          			    "            <valueMap>\r" +
          			    "                <value>Roll</value>\r" +
          			    "                <value>Ea</value>\r" +
          			    "                <value>Pkt</value>\r" +
          			    "                <value>Set</value>\r" +
          			    "                <value>Tube</value>\r" +
          			    "                <value>Pad</value>\r" +
          			    "                <value>Ream</value>\r" +
          			    "                <value>Tin</value>\r" +
          			    "                <value>Bag</value>\r" +
          			    "                <value>Ctn</value>\r" +
          			    "            </valueMap>\r" +
          			    "        </field>\r" +
          			    "        <field name=\"unitCost\"    type=\"float\"    title=\"Unit Cost\"   required=\"true\">\r" +
          			    "            <validators>\r" +
          			    "                <validator type=\"floatLimit\" precision=\"2\" min=\"0\" errorMessage=\"Please enter a valid cost\"/>\r" +
          			    "            </validators>\r" +
          			    "        </field>\r" +
          			    "        <field name=\"inStock\"   type=\"boolean\"  title=\"In Stock\"/>\r" +
          			    "        <field name=\"nextShipment\"  type=\"date\" title=\"Next Shipment\"/>\r" +
          			    "    </fields>\r" +
          			    "</DataSource>\r";
          		
          		DataSource ds = DataSource.fromXML(xmlString);
          		resp = ds.execute(dsRequest);
          		
          		return super.handleDSRequest(dsRequest, rpc, context);
          	}
          
          }
          Getting warning on below line:
          resp = ds.execute(dsRequest);

          Can you please suggest what is missing here?

          Comment


            #35
            What's missing is any way for that DataSource to execute the request. It's not one of the built-in types (sql, etc), has no DMIs and is not a custom DataSource (serverConstructor).

            Read the overviews of how to build a working DataSource. Once you have it working as a normal .ds.xml file, make it dynamically generated via this approach instead and it will work the same way.

            Comment


              #36
              @Isomorphic

              I solved that problem by your suggested way.Thanks for looking in problems.

              Now after moving one step further i again found some questions. As per your suggestion i created one class extending the IDAcall and other servlet for JS Generation (for adding <script src = >).

              As i need to generate the dynamic xml for every call (on click any Tab from Menu corresponding tab item grid will be displayed and grid will have dynamic xml). Then how to update already created XML?

              Below is the code of IDACall and Servlet:
              SupplyMasterDS.java:
              Code:
              public class SupplyMasterDS extends IDACall {
              
              public DSResponse handleDSRequest(DSRequest dsRequest, RPCManager rpc,
                          RequestContext context) throws Exception {
                    DSResponse resp = new DSResponse();
                    String xmlString = "";
                    DataSource ds = DataSource.fromXML(xmlString);
                    String operation = dsRequest.getOperationType();
                    if (operation.equals(DataSource.OP_FETCH)) {
                    }else if () {
                    }else if () {
                    }else if () {
                    }
                    return resp;
              }
              }
              Servlet Code:
              Code:
              public class SupportServlet extends HttpServlet {
                    String xmlString = "";
                    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                      DataSource ds;
              	ds = DataSource.fromXML(xmlString);
              	JSTranslater jst = new JSTranslater();
              	String js = jst.toJS(ds);
              	response.getWriter().write(js);
              }
              }
              Here in code xmlString will contain the dynamic xml generated string. But the Grid is only displaying the fields specified in Servlet code xmlString (this servlet called once only. Right?).

              After that if i want to update the ListGrid DataSource then how to do it? Please suggest the right way.

              Comment


                #37
                Sorry, this code appears to be nonsense - follow the sample instead.

                Comment


                  #38
                  Originally posted by Isomorphic
                  Sorry, this code appears to be nonsense - follow the sample instead.

                  Sorry Isomorphic i did not got your point. As you said to follow the sample code, i already following the same code provided in this post only.

                  Can you suggest where i am being wrong? Because as you can see these code fragments have been fetched from this post only.

                  Comment


                    #39
                    Originally posted by jay.l.fisher
                    Code:
                    package com.islandpacific.gui.server.customDataSource;
                    
                    public class ItemMasterDS extends IDACall {
                    	/**
                    	 * 
                    	 */
                    	private static final long serialVersionUID = -1483088157905503631L;
                    
                    	public DSResponse handleDSRequest(DSRequest dsRequest,
                                RPCManager rpc,
                                RequestContext context)
                         throws java.lang.Exception {
                    		DSResponse resp = new DSResponse();
                    		DataSource ds = DataSource.fromXML(new FileReader("IPItemMasterDS.ds.xml"));
                    		resp = ds.execute(dsRequest);
                    		return resp;
                    	}
                    }
                    SupplyMasterDS.java code derived from this code.

                    Comment


                      #40
                      Originally posted by jay.l.fisher
                      Code:
                      DataSource ds = DataSource.fromXML(new ItemMasterDS().getDSString());
                      JSTranslater jst = new JSTranslater();
                      String js = jst.toJS(ds);
                      response.getWriter().write(js);
                      Servlet code derived from this post.

                      Comment


                        #41
                        @Isomorphic

                        I think i should depict my exact requirement so you will be the better person to tell which approach i should use.

                        It will be more meaningful if you go through demo project (created by me) which is currently in GXT + GAE (low level API). I want to convert it in smartGWT + GAE (low level API).
                        http://www.lunkadvipul.appspot.com/

                        Brief about this project (it is same like Sharepoint List mechanism):
                        Here user should be able to create model and after creating the model user should be able to perform CRUD operation on same model.
                        ADD Model : To create new Model
                        View Model : To view created model data and perform CRUD operations

                        Now as you can see the project is basically dependent on dynamic modeling. There will be no datasource description will be known in advance. If i don't know datasource description in advance then how should i use custom datasource mechanism here.

                        I have followed the approach provided in this thread but still i was not able to achieve the dynamic datasource description.

                        Can you provide your valuable suggestions which approach i should use for dynamic datasource description?

                        Please try to give replay in depth so i will not trouble you every time with my questions.

                        Comment


                          #42
                          Hello webashlar,

                          If the examples and assistance provided so far are not enough for you, we'd suggest taking advantage of our commercial services. Isomorphic consultants can either look through your existing project or provide you a working prototype of what you want to do. Training is also available.

                          Comment


                            #43
                            Originally posted by Isomorphic
                            Sorry, this code appears to be nonsense - follow the sample instead.
                            Thanks for concern i will surely look after this trainings.

                            But can you please tell why code appears to be nonsense? So i can update the code and release here.

                            And i think it will be good for other developers also who can make same mistakes.

                            Comment


                              #44
                              @jay.l.fisher
                              @rathiandi

                              Hello,

                              Hoping for your valuable inputs also so i can get through this trivial but irritating problem.

                              May be your already created code can help me out.

                              Comment


                                #45
                                The first thing that stands out in your second set of examples is that you appear to be creating the DataSource javascript from an empty string. ??

                                String xmlString = "";
                                DataSource ds = DataSource.fromXML(xmlString);

                                In your first example, as Isomorphic pointed out, you have no dataFormat or serverType specified so, although your data source has fields defined there are no operation bindings so it can't provide the standard fetch, update, remove or add methods.

                                Comment

                                Working...
                                X