Announcement

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

    how could i load the screen which contains a custom component ?

    hi:

    today i create a custom component and load it to the visual bulider's Palette. then, i create a page.
    the page is simple, only contains one custom component. i want load this page, but failed.

    who can help me ?

    this is the custom component:
    Code:
    ClassFactory.defineClass("SimpleHeader", isc.HLayout);
    
    isc.SimpleHeader.addProperties({
        width:"100%", // full width
        height:20,
    	imageSrc:"[SKIN]Window/headerIcon.png",
        backgroundColor:"white",
    	imageWidth:18,
    	imageHeight:null, // will use overall widget height if not specified
    	titleText:"Simple Header",
    	titleStyle:"tabTitle",
    
        // --- Instance Methods ---
        initWidget : function () {
            // call superclass implementation
            this.Super("initWidget", arguments);
        
            // on init, create the parts of this header
            this.addMembers([
            
                // img for logo image
                isc.Img.create({
                    ID:this.getID()+"_image",
                    src:this.imageSrc,
                    width:this.imageWidth,
                    height:this.imageHeight || this.getHeight(),
                    layoutAlign:"center"
                }),
                
                // spacer to stretch
                isc.LayoutSpacer.create({
                    ID:this.getID()+"_spacer"
                }),
                
                // label for text title
                this.label = isc.Label.create({
                    ID:this.getID()+"_title",
                    valign:"center",
                    styleName:this.titleStyle,
                    contents:this.titleText,
                    wrap:false
                })
            ]);
        },
    
        // --- Dynamic Setters ---
        setTitleText : function (newTitleText) {
            this.titleText = newTitleText;
            this.label.setContents(newTitleText);
        },
    
        setTitleStyle : function (newTitleStyle) {
            this.titleStyle = newTitleStyle;
            this.label.setStyleName(newTitleStyle);
        }
    });
    and this is the page's xml:
    Code:
    <isomorphicXML>
    	<SimpleHeader ID="SimpleHeader0" autoDraw="false"/>
    
    	<VLayout ID="mainContainer" width="300" height="300" autoDraw="false">
        	<members>
        		<Canvas ref="SimpleHeader0"/>
        	</members>
    	</VLayout>
    </isomorphicXML>
    this is the server log:
    Code:
    ISC: Configuring log4j from: file:/E:/workspace/builtinds/war/WEB-INF/classes/log4j.isc.config.xml
    === 2013-07-11 19:16:30,417 [main] INFO  ISCInit - Isomorphic SmartClient/SmartGWT Framework - Initializing
    === 2013-07-11 19:16:30,425 [main] INFO  ConfigLoader - Attempting to load framework.properties from CLASSPATH
    === 2013-07-11 19:16:30,464 [main] INFO  ConfigLoader - Successfully loaded framework.properties from CLASSPATH at location: jar:file:/E:/workspace/builtinds/war/WEB-INF/lib/isomorphic_core_rpc.jar!/framework.properties
    === 2013-07-11 19:16:30,464 [main] INFO  ConfigLoader - Attempting to load project.properties from CLASSPATH
    === 2013-07-11 19:16:30,464 [main] INFO  ConfigLoader - Unable to locate project.properties in CLASSPATH
    === 2013-07-11 19:16:30,466 [main] INFO  ConfigLoader - Successfully loaded isc_interfaces.properties from CLASSPATH at location: jar:file:/E:/workspace/builtinds/war/WEB-INF/lib/isomorphic_core_rpc.jar!/isc_interfaces.properties
    === 2013-07-11 19:16:30,466 [main] INFO  ConfigLoader - Attempting to load server.properties from CLASSPATH
    === 2013-07-11 19:16:30,467 [main] INFO  ConfigLoader - Successfully loaded server.properties from CLASSPATH at location: file:/E:/workspace/builtinds/war/WEB-INF/classes/server.properties
    === 2013-07-11 19:16:30,471 [main] INFO  Logger - Logging system started.
    === 2013-07-11 19:16:30,473 [main] INFO  ISCInit - Auto-detected webRoot - using: E:\workspace\builtinds\war
    === 2013-07-11 19:16:30,474 [main] INFO  ISCInit - Isomorphic SmartClient/SmartGWT Framework (v9.0p_2013-07-09/EVAL Deployment 2013-07-09) - Initialization Complete
    === 2013-07-11 19:16:47,896 [l0-2] INFO  RequestContext - URL: '/builtinds/sc/DataSourceLoader', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.97 Safari/537.22': Safari with Accept-Encoding header
    === 2013-07-11 19:16:47,900 [l0-0] INFO  RequestContext - URL: '/builtinds/sc/screenLoader', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.97 Safari/537.22': Safari with Accept-Encoding header
    === 2013-07-11 19:16:47,997 [l0-5] INFO  Compression - /builtinds/sc/modules/ISC_Core.js: 825464 -> 216000 bytes
    === 2013-07-11 19:16:48,012 [l0-5] DEBUG ServletTools - setting cookie 'isc_cState' to: 'ready'
    === 2013-07-11 19:16:48,471 [l0-6] INFO  Download - Returning 304: Not modified on conditional get of: E:\workspace\builtinds\war\builtinds\sc\skins\Enterprise\load_skin.js
    === 2013-07-11 19:16:48,472 [l0-0] DEBUG ScreenLoaderServlet - screenLoader - Requested screens:TestCustomCompent
    === 2013-07-11 19:16:48,472 [l0-0] DEBUG ScreenLoaderServlet - screenLoader - Processing screen "TestCustomCompent".
    === 2013-07-11 19:16:48,500 [l0-0] DEBUG XML - Parsed XML from (in memory stream): 4ms
    === 2013-07-11 19:16:48,508 [l0-2] DEBUG XML - Parsed XML from E:\workspace\builtinds\war\builtinds\sc\system\schema\builtinTypes.xml: 4ms
    === 2013-07-11 19:16:48,522 [l0-2] INFO  PoolManager - SmartClient pooling started for 'simpleTypes' objects
    === 2013-07-11 19:16:48,554 [l0-2] DEBUG XML - Parsed XML from E:\workspace\builtinds\war\ds\supplyItem.ds.xml: 2ms
    === 2013-07-11 19:16:48,558 [l0-2] DEBUG XML - Parsed XML from E:\workspace\builtinds\war\builtinds\sc\system\schema\DataSource.ds.xml: 4ms
    === 2013-07-11 19:16:48,600 [l0-2] DEBUG XML - Parsed XML from E:\workspace\builtinds\war\builtinds\sc\system\schema\DataSourceField.ds.xml: 3ms
    === 2013-07-11 19:16:48,618 [l0-2] DEBUG XML - Parsed XML from E:\workspace\builtinds\war\builtinds\sc\system\schema\ValueMap.ds.xml: 1ms
    === 2013-07-11 19:16:48,622 [l0-2] DEBUG XML - Parsed XML from E:\workspace\builtinds\war\builtinds\sc\system\schema\Validator.ds.xml: 2ms
    === 2013-07-11 19:16:48,655 [l0-2] DEBUG DataSourceLoader - For DataSource 'supplyItem', got instanceId 10
    === 2013-07-11 19:16:48,659 [l0-0] DEBUG XML - Parsed XML from E:\workspace\builtinds\war\builtinds\sc\system\schema\isomorphicXML.ds.xml: 1ms
    === 2013-07-11 19:16:48,665 [l0-0] DEBUG XML - Parsed XML from E:\workspace\builtinds\war\ds\SimpleHeader.ds.xml: 1ms
    === 2013-07-11 19:16:48,670 [l0-0] DEBUG XML - Parsed XML from E:\workspace\builtinds\war\builtinds\sc\system\schema\HLayout.ds.xml: 1ms
    === 2013-07-11 19:16:48,673 [l0-0] DEBUG XML - Parsed XML from E:\workspace\builtinds\war\builtinds\sc\system\schema\Layout.ds.xml: 2ms
    === 2013-07-11 19:16:48,691 [l0-0] DEBUG XML - Parsed XML from E:\workspace\builtinds\war\builtinds\sc\system\schema\Canvas.ds.xml: 5ms
    === 2013-07-11 19:16:48,724 [l0-0] DEBUG XML - Parsed XML from E:\workspace\builtinds\war\builtinds\sc\system\schema\MethodDeclaration.ds.xml: 2ms
    === 2013-07-11 19:16:48,731 [l0-2] DEBUG XML - Parsed XML from E:\workspace\builtinds\war\ds\animals.ds.xml: 2ms
    === 2013-07-11 19:16:48,733 [l0-2] DEBUG DataSourceLoader - For DataSource 'animals', got instanceId 30
    === 2013-07-11 19:16:48,735 [l0-0] DEBUG XML - Parsed XML from E:\workspace\builtinds\war\builtinds\sc\system\schema\VLayout.ds.xml: 2ms
    === 2013-07-11 19:16:48,742 [l0-2] DEBUG XML - Parsed XML from E:\workspace\builtinds\war\ds\employees.ds.xml: 2ms
    === 2013-07-11 19:16:48,746 [l0-2] DEBUG XML - Parsed XML from E:\workspace\builtinds\war\builtinds\sc\system\schema\OperationBinding.ds.xml: 1ms
    === 2013-07-11 19:16:48,755 [l0-2] DEBUG DataSourceLoader - For DataSource 'employees', got instanceId 37
    === 2013-07-11 19:16:48,760 [l0-0] DEBUG ScreenLoaderServlet - screenLoader - Generated response:
    	{
        ID:"SimpleHeader0",
        autoDraw:false
    }
    
    	isc.VLayout.create({
        ID:"mainContainer",
        autoDraw:false,
        height:300,
        width:300,
        members:[
            SimpleHeader0
        ]
    })
    
    === 2013-07-11 19:16:48,877 [l0-2] INFO  RequestContext - URL: '/favicon.ico', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.97 Safari/537.22': Safari with Accept-Encoding header
    === 2013-07-11 19:17:10,260 [l0-0] INFO  RequestContext - URL: '/favicon.ico', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.97 Safari/537.22': Safari with Accept-Encoding header

    the attach picture is the error picture from chrome browser.
    Attached Files
    Last edited by kaloon; 11 Jul 2013, 03:31.

    #2
    chrome browser says it's SyntaxError, i guess the reason is server generate a bad js code:
    Code:
    {
      ID:"SimpleHeader0",
      autoDraw:false
    }
    may be the right code should be:
    Code:
    SimpleHeader.create({
      ID:"SimpleHeader0",
      autoDraw:false
    });
    but how can generate the right code by screenLoader ?

    Comment


      #3
      Take a look at the Component XML and Component Schema topics.

      You can use the XML as you have it if you create a Component Schema.

      Otherwise you need to use an <HLayout> tag with the "constructor" attribute.

      Comment


        #4
        ths for your help!

        i read the component schema topic again and find out my problem:

        my wrong schema:
        Code:
        <DataSource ID="SimpleHeader" serverType="component" 
                    inheritsFrom="HLayout" clientConstructor="SimpleHeader">
            <fields>
                <field name="titleText" type="string" group="title"/>
                <field name="titleStyle" type="CSSClassName" group="title"/>
            </fields>
        </DataSource>
        right schema should be:
        Code:
        <DataSource ID="SimpleHeader" serverType="component" 
                    inheritsFrom="HLayout" instanceConstructor="SimpleHeader">
            <fields>
                <field name="titleText" type="string" group="title"/>
                <field name="titleStyle" type="CSSClassName" group="title"/>
            </fields>
        </DataSource>
        the right schema works now. server can generate the right js code:
        Code:
        isc.SimpleHeader.create({
            ID:"SimpleHeader0",
            autoDraw:false
        })
        but still have a js error:
        Uncaught TypeError: Cannot call method 'create' of undefined.

        i have already add the dependency js and schema,
        the dependency js path is :
        webroot/tools/visualBuilder/dependencies/SimpleHeader.js

        globalDependencies.xml :
        Code:
        <dependencies>
           <dependency type="js" url="dependencies/SimpleHeader.js"/>
           <dependency type="schema" id="SimpleHeader"/>
        
        </dependencies>
        so, how can i fix this problem? wait your reply.
        Attached Files

        Comment


          #5
          Sounds like your .js file with the custom component definition (the defineClass() call, etc) just isn't being loaded.

          The reason might be as simple as the URL to the file being wrong. Use Firebug or a similar tool to see if the request to retrieve the file is happening at all, and whether it succeeds.

          Comment


            #6
            thank you!

            i add the component's js to host page's head section
            Code:
              <head>
                <meta http-equiv="content-type" content="text/html; charset=UTF-8">
                <title>BuiltInDS</title>
            	<script> var isomorphicDir = "builtinds/sc/"; </script>	
                <script type="text/javascript" language="javascript" src="builtinds/builtinds.nocache.js"></script>
                <script type="text/javascript" language="javascript" src="builtinds/tools/visualBuilder/dependencies/SimpleHeader.js"></script>
              </head>
            it works! thank you again.

            but I think the steps to load a screen page is little cumbersome:

            first, i create a page within visual builder.

            second, i copy the page's xml code, make a xxx.ui.xml, placed the xxx.ui.xml inside the /share/ui folder

            third, in the host page, i have to add "screenLoader" js. if the page contains a custom component, also have to add the custom component's definition js in the host page.

            last, if i want to load the screen, these code are needed:
            Code:
                	Canvas canvas = Canvas.getById("VLayout0");
                	if(canvas != null)
                	{
                		canvas.draw();
                	}
            Those mentioned above can load a screen. Is there an easy way to achieve?

            by the way, if i want to Build a WYSIWYG application, with this app, user can customize the page, also, they can save the page's data to database, how should i do? can you give some pointers ?

            Comment


              #7
              See this FAQ (which applies equally to SmartClient): developers don't usually create a screen in Visual Builder.

              Other than that you are loading a .js file with logic and an .xml file with a layout. There don't seem to be simplifications, and these are mostly one time steps (or perhaps once during the building of entire screen).

              Comment


                #8
                About having users customize the page - the Component XML overview explains how you can load dynamic Component XML - this is how you would load it from a database.

                As far as creating an interface for screen customization, this very much depends on what you want the users to be able to customize.

                For maximum customization, you can embed Visual Builder itself in your application, typically in a customized form that turns off features you don't want your end users to be able to do (such as connecting to arbitrary databases and creating arbitrary tables..) - this is called Visual Builder OEM and requires a separate license.

                Comment


                  #9
                  Thank you for your patience to help me.

                  Comment

                  Working...
                  X