Page 1 of 1
Dashboard with dynamic source
Posted: 27 Jan 2011, 19:45
by mshrestha
Hi All,
I came across one situation when using dashboard component of primefaces.
Running code bellow gives me following error
Caused by: javax.faces.FacesException: Cannot find dashboard "board" in view
What could be possible solution if I need to have scenario like following?
Code: Select all
<p:growl id="growl" showDetail="true" />
<p:dashboard id="board" model="#{dashboardBean.model}"
reorderListener="#{dashboardBean.handleReorder}"
onReorderUpdate="growl"/>
<table>
<ui:repeat var="species" value="#{dashboardBean.speciesList}">
<tr>
<td>
<p:panel id="travel" header="Travel" toggleable="true" closable="true" style="width:200px">
<h:outputText value="#{species.name}" />
</p:panel>
<p:draggable for="travel" dashboard="board" helper="clone"/>
</td>
</tr>
</ui:repeat>
</table>
Re: Dashboard with dynamic source
Posted: 27 Jan 2011, 21:19
by mshrestha
Sorry for bothering,
adding full path for board as dashboard=":board" helped me out
Re: Dashboard with dynamic source
Posted: 24 Nov 2011, 18:23
by llper
Sorry for re-opening this thread,
but I have exactly the same problem, and I've tried with the ":board" id for the draggable's dashboard attribute, but still it does not find the component in the tree.
here the code:
Code: Select all
<ui:define name="centerArea">
<p:fieldset legend="Available Widgets" styleClass="hidden startClosed avWidget">
<p:dataGrid id="availableWidgets" var="widget" value="#{dashboardBean.availableWidgets}" columns="1">
<p:column>
<p:panel id="pnl" header="#{widget.name}" style="text-align:center">
<h:panelGrid columns="1" style="width:100%">
<h:outputText value="#{widget.description}" />
</h:panelGrid>
</p:panel>
<!--p:draggable for="pnl" revert="true" helper="clone" handle=".ui-panel-titlebar" stack=".ui-panel" opacity="0.3" scope="w" dashboard="board" /-->
<p:draggable for="pnl" helper="clone" dashboard=":board" />
</p:column>
</p:dataGrid>
</p:fieldset>
<p:dashboard id="board" model="#{dashboardBean.dashboardModel}" style="min-height: 400px;">
<p:panel id="sports">
Sports Content
</p:panel>
<p:ajax event="reorder" listener="#{dashboardBean.handleReorder}" />
</p:dashboard>
</ui:define>
Strangely the component is not found, even if the whole UIView root is traversed!
Could somebody help me?
Thanks and regards,
Davide
Re: Dashboard with dynamic source
Posted: 28 Nov 2011, 09:47
by llper
I've figured out the correct id to use in order for JSF to find my component.
The problem was that the dashboard component with id 'board' was under a htmlform named 'centerAreaForm'.
Going through the JSF componentBase class, the findComponent method (here below):
Code: Select all
private static UIComponent findComponent(UIComponent base,
String id,
boolean checkId) {
if (checkId && id.equals(base.getId())) {
return base;
}
// Search through our facets and children
UIComponent result = null;
for (Iterator i = base.getFacetsAndChildren(); i.hasNext();) {
UIComponent kid = (UIComponent) i.next();
if (!(kid instanceof NamingContainer)) {
if (checkId && id.equals(kid.getId())) {
result = kid;
break;
}
result = findComponent(kid, id, true);
if (result != null) {
break;
}
} else if (id.equals(kid.getId())) {
result = kid;
break;
}
}
return (result);
}
does not search recursively 'NamingContainer' objects. Since the HTMLForm is a NamingContainer, that part of the tree was skipped.
Changing the id to lookup in ':centerAreaForm:board' in my example above fixed the problem, sinche first is the NamingContainer resolved, and the the board.
Cheers,
llper
Re: Dashboard with dynamic source
Posted: 28 Nov 2011, 10:13
by cagatay.civici
Thanks for sharing.