Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9306171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:06:45+00:00 2026-06-19T00:06:45+00:00

I have static TabContainer and all the ContentPanes inside the TabContainer should be created

  • 0

I have static TabContainer and all the ContentPanes inside the TabContainer should be created dynamically from the json data which got from servlet. All the ContentPanes share the same template which only data is different. Like:

[Tab A] Tab B Tab C
Name: Jerry
Age: 28
Birthday: 2.9

When click Tab B:

Tab A [Tab B] Tab C
Name: Michael
Age: 45
Birthday: 2.10

The content of ContentPane is far more complex than this sample and it’s declaretively written in html so I cannot create it promatically like this:

var cp1 = new dijit.layout.ContentPane({
    title:"New Question",
    content:"<p>I am added promatically</p>",
});

dijit.byId("centerLayout").addChild(cp1);

So, how can I implement this by “template” or something concept in Dojo?
Maybe there is a more strong component that I don’t know can bind the queried data to all these repeated ContentPane.

Any sample code is highly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T00:06:46+00:00Added an answer on June 19, 2026 at 12:06 am

    Simple template using lang.replace

    Depending on the complexity of the ContentPane contents/template, one simple way to do it would be to use a simple lang.replace. Let’s say you make the name/age/birthday template like this (e.g. cai/personTpl.html):

    <dl>
        <dt>Name</dt><dd>{name.firstname} {name.lastname}</dd>
        <dt>Age</dt><dd>{age}</dd>
        <dt>Birthday</dt><dd>{birthday}</dd>
    </dl>
    

    In your Javascript, you can then do:

    require([..other deps.., 'dojo/_base/lang', 'dojo/text!cai/personTpl.html'],
        function(..other deps.., lang, personTpl) {
            //.. your other code .. 
            // assuming person[i] is something like:
            //   {name: {firstname: 'A', lastname: 'B'}, age: 42..}
            var cp1 = new dijit.layout.ContentPane({
                title:"New Question",
                content: lang.replace(personTpl, person[i]),
             });
             dijit.byId("centerLayout").addChild(cp1);
        }
    );//~require
    

    More about dojo/_base/lang::replace with dictionary here: http://dojotoolkit.org/reference-guide/1.8/dojo/_base/lang.html#dojo-base-lang-replace


    More complex template using a custom widget

    If the template used in each tab is more complex, e.g. having widgets on its own, using events etc, you may be better off writing a custom widget (instead of using ContentPane).

    For example, the template can be something like (cai/widgets/personTpl.html):

    <dl>
        <dt>Name</dt><dd data-dojo-attach-point='nameNode'></dd>
        <dt>Age</dt><dd data-dojo-attach-point='ageNode'></dd>
        <dt>Birthday</dt><dd>
            <input type='text' data-dojo-type='dijit/form/DateTextBox'
                data-dojo-attach-point='bdayInput' />
         </dd>
    </dl>
    

    And the widget can be (cai/widgets/Person.js):

    define([ ..other deps.., "dojo/text!cai/widgets/personTpl.html"],
        function(..other deps.., personTpl) {
            return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
                templateString: personTpl,
    
                name: "unknown",
                _setNameAttr: { node: "nameNode", type: "innerHTML" },
    
                age: 0,
               _setAgeAttr: { node: "ageNode", type: "innerHTML" },
    
               birthday: new Date(),
               _setBirthdayAttr: function(bday) { 
                   this.bdayInput.set("value", bday); 
                   this._set("birthday", bday); 
               }
            }); //~declare
        }
    ); //~define
    

    Then you can add instances of the Person widget to the TabContainer:

    require([..other deps.., "cai/widgets/Person"],
        function(..other deps.., Person) {
            //.. your other code .. 
            // assuming person[i] is something like:
            //   {name: "Jerry", age: 42, birthday: new Date(), title: "JerryTab"}
            var p = new Person(person[i]);
            dijit.byId("centerLayout").addChild(p);
        }
    );//~require
    

    More about widgets (and widgets with attributes mapped to nodes) here: http://dojotoolkit.org/reference-guide/1.8/quickstart/writingWidgets.html#mapping-widget-attributes-to-domnode-attributes

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have static method which returns me as it's name says data from domain
I have static data in a single table which I must serialize. I have
I have static method which plays music. How to return value from this method
I intended to create a class which only have static members and static functions.
I have a static class that I use as my Data Utils for my
I have a static menu in the sidebar which I include in every JSF
I have a static map that is a private data member. How do I
I have static library and another program which uses it. In the static library
I want to have static and constant two dimensional array inside a class. The
I have a jar file with several classes which have static main methods. Can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.