Add widgets dynamically

By using a special addWidget component it is possible to fill up a dynaWidget grid dynamically. With this component applications can offer a range of widgets for users to add to their individual grid.

Using the addWidget component

			<dwComp:addWidget 
				widgetGridId="myDynamicGrid" 
				widgetId="secondWidget" 
				value="click to add 'MySecondWidget' to grid" 
				initialState="{'title':'My second widget','commandEdit':'false'}"/>
				
			the grid:
			<dwComp:dynaWidgetGrid id="myDynamicGrid" 
				...
				defaultStateStore="server"
				initialState="{...}" />  
      	
What´s important here: For details on using the dynaWidget components see main components.

An example for the addWidget component

In the following example you can choose between adding 3 different widgets (which you might already know from the first example) to the grid. The same widget can only be added once - therefore it has to be removed (using the close action) before adding it again. Give it a try and play around with it!


 add 'MyFirstWidget'  add 'MySecondWidget'  add 'MyThirdWidget'

My first widget
This is the content of my first widget! There´s not much behind it, just a simple facelets page with text.