Quantcast

Error: Tried to register widget with id==xxx but that id is already registered

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Error: Tried to register widget with id==xxx but that id is already registered

carek

Hi. I am stucked with interesting problem and I can't cope with it.
To make things simple let's say I have got some kind of index page and I
create programmatically two widgets with passed by me id:

...
<body>
<script>
var widget1 = x.y.z.Widget1({id : widget1});
widget1.startup();
var widget2 = x.y.z.Widget2({id : widget2});
widget2.startup();
</script>
...

and let's say somewhere lower in index.jsp body I have got two buttons in
accordion and contentPane in center area. Those buttons are supposed to
change center area content like dijit.byId("centerArea").set('content',
dijit.byId(widgetX)) based on passed widget param (one of those two)... the
problem is when I call that setter I 've got following error:

Error: Tried to register widget with id==widget but that id is already
registered

I know it's cause... etc... I googled it for 7 hours... the problem is I
don't want to destroy those widgets because I want them to hold their
contents as long as the user is visiting my web interface. They are actually
tab containers and I wish that created tabs inside them to be undestroyed no
matter what... So when a user clicks a button and one of those widgets gets
loaded into center area and then creates some tabs inside it, I want them to
be in that widget even if user decides to select the other widget to be
displayed in center area. So when he come backs to the first widget he can
see created earlier tabs.

Sorry for my English and confusing description. In case something is unclear
feel free to ask for more details... and please help me with resolving that
problem
--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Error-Tried-to-register-widget-with-id-xxx-but-that-id-is-already-registered-tp2009098p2009098.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Tried to register widget with id==xxx but that id is already registered

Ted Scott-3
If I've understood you, rather than destroy the pane and then add a new
one back into in your accordian, you just want it to display.

Something like this may work:
accordian.selectChild(dijit.byId("widget1"));

I have a function that figures out if one of my panes is already
displayed, and will redisplay it instead of destroying and recreating it.

On 12/2/2010 7:58 PM, carek wrote:

> Hi. I am stucked with interesting problem and I can't cope with it.
> To make things simple let's say I have got some kind of index page and I
> create programmatically two widgets with passed by me id:
>
> ...
> <body>
> <script>
> var widget1 = x.y.z.Widget1({id : widget1});
> widget1.startup();
> var widget2 = x.y.z.Widget2({id : widget2});
> widget2.startup();
> </script>
> ...
>
> and let's say somewhere lower in index.jsp body I have got two buttons in
> accordion and contentPane in center area. Those buttons are supposed to
> change center area content like dijit.byId("centerArea").set('content',
> dijit.byId(widgetX)) based on passed widget param (one of those two)... the
> problem is when I call that setter I 've got following error:
>
> Error: Tried to register widget with id==widget but that id is already
> registered
>
> I know it's cause... etc... I googled it for 7 hours... the problem is I
> don't want to destroy those widgets because I want them to hold their
> contents as long as the user is visiting my web interface. They are actually
> tab containers and I wish that created tabs inside them to be undestroyed no
> matter what... So when a user clicks a button and one of those widgets gets
> loaded into center area and then creates some tabs inside it, I want them to
> be in that widget even if user decides to select the other widget to be
> displayed in center area. So when he come backs to the first widget he can
> see created earlier tabs.
>
> Sorry for my English and confusing description. In case something is unclear
> feel free to ask for more details... and please help me with resolving that
> problem

_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Tried to register widget with id==xxx but that id is already registered

carek

well you almost got it ;) hehe actually I am not willing to add elements to
accordion. The accordion is filled with those "slide-tabs" under which I
have got buttons and depends on which one is clicked, the appropriate widget
should be displayed in main area... maybe I will post some code:

This is my index.jsp:

...

<body class="claro">
        <script>
                var sourceMonitoring = new
pl.edu.agh.drum.dashboard.widgets.SourceMonitoring();
                sourceMonitoring.startup();
                var statMonitoring = new
pl.edu.agh.drum.dashboard.widgets.StatMonitoring();
                statMonitoring.startup();
        </script>
        <div dojoType="dijit.layout.BorderContainer" gutters="true"
id="mainBorderContainer">

        ...

                <!-- Main area -->
                <div dojoType="dijit.layout.BorderContainer" liveSplitters="false"
design="sidebar" region="center" id="mainSplit">
               
                        <!--  Accordion container -->
                        <div dojoType="dijit.layout.AccordionContainer" minSize= "17em"
style="width: 18em;" id="leftAccordion"
                                region="leading" splitter="true">
               
...
       
                                <div dojoType="dijit.layout.ContentPane" title="Monitoring"
selected="true" style="text-align: center">
                                        <button dojoType="dijit.form.Button" style="width: 100%">
                                                Stat Combobox
                                                <script type="dojo/method" event="onClick">
                                                        var pane = dijit.byId("centerArea");
        pane.set('content', statMonitoring);
                                                </script>
                                        </button>
               
                                        <button dojoType="dijit.form.Button" style="width: 100%">
                                                Source Combobox
                                                <script type="dojo/method" event="onClick">
                                                        var pane = dijit.byId("centerArea");
        pane.set('content', sourceMonitoring);
                                                </script>
                                        </button>
                                </div>

...

                        </div>
       
                        <!-- Center Area -->
                        <div region="center" dojoType="dijit.layout.ContentPane" title="Stat
chart example" id="centerArea">
                                <jsp:include page="startPage.jsp"/>
                        </div>
                </div>
    </div>
</body>

...

so I would like the content of center area to be switched depends on which
button is clicked in accordion... but when I do
dijit.byId("centerArea").set('content', choosen widget)

I got the error connected with parser that I try to register already
registered widget's id. Which isn't anything unusual since the parser wants
it to parse create and register again after it destroys previous content...
the question is how to switch those widgets without destroying previous one
and only setting the selected one (without creating/cloning and registering
it again... I think setContent method clones passed as argument widget)

once again thanks a lot for any help. I could use any advice, especially
because the project I write is my master degree work so... heh I need to
make it done as fast as possible... well it seems I extended myself a little
;)
--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Error-Tried-to-register-widget-with-id-xxx-but-that-id-is-already-registered-tp2009098p2010824.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Tried to register widget with id==xxx but that id is already registered

carek
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Tried to register widget with id==xxx but that id is already registered

Dustin Machi-2
In reply to this post by carek
It sounds to me like your center area should be a tabcontainer, not a content pane.  When the user clicks a button you create a new widget with a specific id and make that a child of your tab container. For this part, if you use a specific id, and then do if (dijit.byId('something")) { dijit.byId('tabContainer').selectChild(dijit.byId('something')); } else { var w = new x.y.z.Widget({id: "something"); dijit.byId("tabContainer").addChild(w);}

You can also remove tabs from the tabContainer with out destroying them and simply add them back when you want to see them again.

Dustin



On Dec 2, 2010, at 7:58 PM, carek wrote:

>
> Hi. I am stucked with interesting problem and I can't cope with it.
> To make things simple let's say I have got some kind of index page and I
> create programmatically two widgets with passed by me id:
>
> ...
> <body>
> <script>
> var widget1 = x.y.z.Widget1({id : widget1});
> widget1.startup();
> var widget2 = x.y.z.Widget2({id : widget2});
> widget2.startup();
> </script>
> ...
>
> and let's say somewhere lower in index.jsp body I have got two buttons in
> accordion and contentPane in center area. Those buttons are supposed to
> change center area content like dijit.byId("centerArea").set('content',
> dijit.byId(widgetX)) based on passed widget param (one of those two)... the
> problem is when I call that setter I 've got following error:
>
> Error: Tried to register widget with id==widget but that id is already
> registered
>
> I know it's cause... etc... I googled it for 7 hours... the problem is I
> don't want to destroy those widgets because I want them to hold their
> contents as long as the user is visiting my web interface. They are actually
> tab containers and I wish that created tabs inside them to be undestroyed no
> matter what... So when a user clicks a button and one of those widgets gets
> loaded into center area and then creates some tabs inside it, I want them to
> be in that widget even if user decides to select the other widget to be
> displayed in center area. So when he come backs to the first widget he can
> see created earlier tabs.
>
> Sorry for my English and confusing description. In case something is unclear
> feel free to ask for more details... and please help me with resolving that
> problem
> --
> View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Error-Tried-to-register-widget-with-id-xxx-but-that-id-is-already-registered-tp2009098p2009098.html
> Sent from the Dojo Toolkit mailing list archive at Nabble.com.
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://docs.dojocampus.org
> [hidden email]
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Tried to register widget with id==xxx but that id is already registered

carek

hmm well yeah it would solve the problem, but it wouldn't be elegant. Two
widgets mentioned earlier are designed to be tab containers so adding them
as a child to a tab container would look bad... what's more I'd like a
center area to be a pane that displays not only widgets but jsp page also
(by href property). So I need some cleaver way to switch it content to
display page by href or widgets other time... I don't know maybe there's a
way to connect the widget as a child of center area ContentPane and then get
it render in a way the user can't see a difference if it directly switched
or connected as a child?

Thanks again for any piece of advice
--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Error-Tried-to-register-widget-with-id-xxx-but-that-id-is-already-registered-tp2009098p2015891.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Tried to register widget with id==xxx but that id is already registered

Dustin Machi-2
Oh, I thought that was you were describing.  If you just want to have two different tab container altogether, you can do the same basic thing but use a stackcontainer at the top level, where each 'tab' contains a tabcontainer itself.  Note with a stack container there are no buttons, so its kind of like stacks of paper where any one of them is on top at any one time.

Dustin

On Dec 3, 2010, at 8:32 PM, carek wrote:

>
> hmm well yeah it would solve the problem, but it wouldn't be elegant. Two
> widgets mentioned earlier are designed to be tab containers so adding them
> as a child to a tab container would look bad... what's more I'd like a
> center area to be a pane that displays not only widgets but jsp page also
> (by href property). So I need some cleaver way to switch it content to
> display page by href or widgets other time... I don't know maybe there's a
> way to connect the widget as a child of center area ContentPane and then get
> it render in a way the user can't see a difference if it directly switched
> or connected as a child?
>
> Thanks again for any piece of advice
> --
> View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Error-Tried-to-register-widget-with-id-xxx-but-that-id-is-already-registered-tp2009098p2015891.html
> Sent from the Dojo Toolkit mailing list archive at Nabble.com.
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://docs.dojocampus.org
> [hidden email]
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Tried to register widget with id==xxx but that id is already registered

carek

hmm... well need to investigate that stackContainer... It's late now so I
will let you know if it works tomorrow... thanks for that tip :)
--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Error-Tried-to-register-widget-with-id-xxx-but-that-id-is-already-registered-tp2009098p2016077.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Tried to register widget with id==xxx but that id is already registered

asantiago

Hi carek,
I run into similar problems. In my case I have a refresh button which
updates the content of a dataGrid with buttons in a column. So I got the
same error than you.

I solved finally simply checking if a given dijit exists, if so return it,
if not create a new one with the ID. Remember if you don't destroy a widget
it continues existing.

Hope it helps.

-----
|---------------------------------------
| http://acuriousanimal.blogspot.com
| http://theballoonproject.blogspot.com
|---------------------------------------
| _ __
| /_| ( _ _/'_ _
|( |. __)(//)//(/(/()
| _/
|---------------------------------------
--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Error-Tried-to-register-widget-with-id-xxx-but-that-id-is-already-registered-tp2009098p2017249.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error: Tried to register widget with id==xxx but that id is already registered

carek

well StackContainer was exactly what I was looking for. Thanks a lot guys for
all your replies :)
--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Error-Tried-to-register-widget-with-id-xxx-but-that-id-is-already-registered-tp2009098p2018165.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Loading...