Skip to content

Commit

Permalink
#676 throw a useful exception if the value attribute is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanrauh committed Apr 15, 2017
1 parent acaaf9f commit 49100ad
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ public void encodeBegin(FacesContext context, UIComponent component) throws IOEx
ResponseWriter rw = context.getResponseWriter();
String clientId = tree.getClientId();

Node value = tree.getValue();
if (null == value) {
throw new FacesException("Please set the value attribute of b:tree. ClientId of the tree without value: " + clientId);
}

// check is inside form (MyFaces requires to be)
final UIForm form = BsfUtils.getClosestForm(tree);
if(form == null) {
Expand Down Expand Up @@ -143,8 +148,9 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce
//# Start enclosure
rw.writeText("$(document).ready(function() {", null);
// build tree management javascript
Node value = tree.getValue();
rw.writeText("function getTreeData() { " +
" return '" + TreeModelUtils.renderModelAsJson(tree.getValue(), tree.isRenderRoot()) + "'; " +
" return '" + TreeModelUtils.renderModelAsJson(value, tree.isRenderRoot()) + "'; " +
"} " +

// build tree structure
Expand Down

0 comments on commit 49100ad

Please sign in to comment.