Announcement

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

  • Isomorphic
    replied
    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.

    Leave a comment:


  • webashlar
    replied
    @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.

    Leave a comment:


  • webashlar
    replied
    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.

    Leave a comment:


  • webashlar
    replied
    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.

    Leave a comment:


  • webashlar
    replied
    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.

    Leave a comment:


  • Isomorphic
    replied
    Sorry, this code appears to be nonsense - follow the sample instead.

    Leave a comment:


  • webashlar
    replied
    @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.

    Leave a comment:


  • Isomorphic
    replied
    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.

    Leave a comment:


  • webashlar
    replied
    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?

    Leave a comment:


  • Isomorphic
    replied
    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.

    Leave a comment:


  • jay.l.fisher
    replied
    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);

    Leave a comment:


  • jay.l.fisher
    replied
    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?

    Leave a comment:


  • jay.l.fisher
    replied
    In my case I created a class that reads the base ds.xml and adds fields to it with a method to return the modified xml as a string; ItemMasterDS().getDSString() in the example. Then in my servlet I used JSTranslater to convert the modified xml to javascript and send that back in the response.
    Code:
    DataSource ds = DataSource.fromXML(new ItemMasterDS().getDSString());
    JSTranslater jst = new JSTranslater();
    String js = jst.toJS(ds);
    response.getWriter().write(js);

    Leave a comment:


  • chess
    replied
    Dear Isomorphic,

    I did read the contents of this thread completely. I followed the same
    approach as Jay did. The sample code that Jay posted (posts #7 and #9)
    were very useful. The only modification I made was to create a DOM object
    from the XML and added additional fields to it. It works fine.

    I need help with the following:

    "To make the client see the dynamic fields, create a .jsp or servlet that produces the same thing the DataSourceLoader servlet produces (JavaScript DataSource definitions) by again calling DataSource.fromXML() with dynamic XML and now also using JSTranslater.toJS() to transform the dynamic DataSource to JS (which the JSP or servlet should stream back as its HTTP response). Then just point a <script src=> tag at the URL of this servlet/.jsp"

    Any sample code/example would be very helpful. I would really appreciate
    if Jay or Isomorphic can share a small example illustrating this.

    Leave a comment:


  • Isomorphic
    replied
    @chess You should start by reading the complete contents of this thread (it doesn't appear as though you have done this yet).

    Leave a comment:

Working...
X