Announcement

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

    Multi datasrouce + criteria

    Hello, I'm using
    SmartClient Version: v10.0p_2014-10-22/Enterprise Deployment (built 2014-10-22)

    I have 2 datsources (Users, Vault)

    I have to get Vault_name from Vault table. Is there some simple critera that combines datasoureces or something like that?

    I fetch current data: "USER_ID" and his "VAULT_ID" from Users.ds.xml. How can i get "VAULT_NAME" from Vault table (Vault.ds.xml) for that user? Thx

    Code:
    Criteria c = new Criteria();
    //find user with id
    c.addCriteria("DU_ID", "16297811");
    		
    //set datasource
    DataSource customDS =DataSource.get("PB_Users");
    customDS.fetchData(c, new DSCallback() {
      @Override
      public void execute(DSResponse dsResponse, Object data,
      DSRequest dsRequest) {
    				
        @SuppressWarnings("unused")
        Record[] records = dsResponse.getData();
    				
        System.out.println("User ID:"+ records[0].getAttribute("USER_ID"));
        System.out.println("Vault ID:"+ records[0].getAttribute("VAULT_ID"));
    
    
    	}
    });
    Last edited by jaandric; 11 Nov 2014, 00:56.

    #2
    Hi jaandric,

    make sure to read the FAQ and the Quick Start Guide from cover to cover (especially the DataBinding related chapters).
    Most likely you are looking for additional attributes/fields in your .ds.xml-files.
    See the DataSourceField javadocs, especially foreignKey, joinType, includeFrom and displayField.

    Best regards,
    Blama

    Comment


      #3
      Multi datasrouce + criteria

      Thx Blama, i managed to set field with FK from another .ds.xml-file and get value from that file by adding field with attribute "includeFrom".

      Is there a way of including all fields without including them in that xml? Just with field that contains FK so i don't have to add 50+ more fields from that other datasource.

      Thx.

      Comment


        #4
        Hi jaandric,

        I don't think that this is possible as the SQL-SELECT block is rendered from that list. Also, the client (if used on the client side) needs to know about the DS-definition. The ds.xml is used for so much, a default will most likely never match your needs.

        Do you know that the framework can generate a boilerplate .ds.xml for every table, making copy&paste easy? See SC.openDataSourceGenerator().

        Best regards,
        Blama

        Comment


          #5
          Yea i know that thx.

          Problem is i have 10 tables that are in serial relationship so i need copy form 10th to 9th then from 9th to 8th and so on. I'll try to combine several ds.xml-s

          Comment


            #6
            Originally posted by jaandric View Post
            Problem is i have 10 tables that are in serial relationship so i need copy form 10th to 9th then from 9th to 8th and so on. I'll try to combine several ds.xml-s
            You don't have to do that.
            Define PK/FK for 10->9->8....->1 and include only where ever you really need the field, eg. only in DS for the last table "10". JOIN-chain is generated for you.
            Last edited by Blama; 11 Nov 2014, 07:11.

            Comment

            Working...
            X