private RootNode readSnippetsNodes() throws NotesException { Database db = ExtLibUtil.getCurrentDatabase(); View v = db.getView("AllSnippetsFlat"); try { RootNode root = new RootNode(); String snippetSearch = (String) ExtLibUtil.getViewScope().get("snippetSearch"); if (StringUtil.isNotEmpty(snippetSearch)) { v.FTSearch(snippetSearch); ViewEntryCollection col = v.getAllEntries(); for (ViewEntry e = col.getFirstEntry(); e != null; e = col.getNextEntry()) { Vector<?> values = e.getColumnValues(); String unid = e.getUniversalID(); String cat = (String) values.get(0); String name = (String) values.get(1); String jspUrl = (String) values.get(2); CategoryNode c = findCategory(root, cat); SnippetNode snippet = new SnippetNode(c, name, cat, unid, jspUrl); c.getChildren().add(snippet); } } else { v.setAutoUpdate(false); ViewNavigator nav = v.createViewNav(); nav.setBufferMaxEntries(500); for (ViewEntry e = nav.getFirst(); e != null; e = nav.getNext()) { Vector<?> values = e.getColumnValues(); String unid = e.getUniversalID(); String cat = (String) values.get(0); String name = (String) values.get(1); String jspUrl = (String) values.get(2); CategoryNode c = findCategory(root, cat); SnippetNode snippet = new SnippetNode(c, name, cat, unid, findUniqueUrl(c, unid, jspUrl)); c.getChildren().add(snippet); } } return root; } finally { v.recycle(); } }
@SuppressWarnings("unchecked") @Override public void beforePageLoad() throws Exception { // super.afterPageLoad(); FacesContext facesContext = FacesContext.getCurrentInstance(); Map<String, String> param = (Map<String, String>) ExtLibUtil.resolveVariable(facesContext, "param"); ViewState state = (ViewState) ExtLibUtil.resolveVariable(facesContext, "state"); byte[] bytes = (byte[]) state.document().getItemValue("State" + param.get("index"), byte[].class); ByteArrayInputStream bis = new ByteArrayInputStream(bytes); // ObjectInputStream ois = new ObjectInputStream(bis); Class<? extends ObjectInputStream> inputClass = (Class<? extends ObjectInputStream>) Class.forName( "com.ibm.xsp.application.AbstractSerializingStateManager$FastObjectInputStream"); Constructor<?> inputConstructor = inputClass.getConstructor(FacesContext.class, InputStream.class); ObjectInputStream ois = (ObjectInputStream) inputConstructor.newInstance(facesContext, bis); // Read the components in Object treeStructure = ois.readObject(); // Object componentStructure = ois.readObject(); Method readObjectEx = inputClass.getMethod("readObjectEx"); Object componentStructure = readObjectEx.invoke(ois); // IComponentNode localIComponentNode = (IComponentNode)treeStructure; // UIViewRootEx view = (UIViewRootEx)localIComponentNode.restore(facesContext); // Object viewState = componentStructure; // view.processRestoreState(facesContext, viewState); // System.out.println("view is " + view); Map<String, Object> viewScope = ExtLibUtil.getViewScope(); viewScope.put("contextTreeStructure", treeStructure); viewScope.put("contextComponentStructure", componentStructure); }