Another way of setting a data source to a diagram view
is to use the dataSource
and XMLDataSource
components.
These components allow you to create and configure a data source.
The data source is stored in memory and is ready to be set on a diagram
component.
Setting a data source on a diagram component
<jvdf:XMLDataSource filename="data/molecule.xml" id="xmlDataSource" />
<jvdf:dataSource value="#{diagrammerBean.datasource}" />
<jvdf:diagrammerView id="diagrammer" data="xmlDataSource" [...] />
<h:commandButton type="button" value="Set XML Data Source"
onclick="diagrammer.setDataSourceId(‘xmlDataSource’)" />
<h:commandButton type="button" value="Set Bound Data Source"
onclick="diagrammer.setDataSourceId(‘dataSource’)" />
This example creates two data sources: one filled from
an XML file and another one from a bound diagram data source.
The two data sources are present in memory. It is then
possible to query the server for switching the data source and updating
the image without a complete page refresh by clicking one of the command
buttons. To perform this task, use the client-side JavaScript proxy
of the diagram view.
The initial data source of the diagram view is configured
through the data
tag attribute that must
match the id
attribute of the desired data
source component.
The
diagrammer
property allows
you to bind an existing
IlvDiagrammer instance
to be reused by the
diagrammerView
component.
<jvdf:diagrammerView [...] diagrammer="#{diagrammerBean.diagrammer}" />