Hallo,
ich verwende in einer Repeat Control Sections, deren Header zur Laufzeit berechnet wird (s.u.).
Die Daten der Repeat Control kommen aus einer SessionScope Variable, die einen JSONstring enthält.
Funktioniert soweit alles ganz gut.
<xp:repeat id="repeat1" rows="30" indexVar="ind" var="item" value="#{sessionScope.navString.children}" repeatControls="true">
<xp:panel style="padding-left:15.0px" rendered="true">
<xp:section id="section1" header="#{javascript:item.name}" initClosed="true" styleClass="dynNavSection">
...........
</xp:section>
</xp:panel>
</xp:repeat>
Ich habe einen Button, der alle Sektionen, bis auf eine Bestimmte zuklappen soll.
Das Zuklappen selbst (alle Sections) funktioniert mit folgendem Code:
function navRepeatCloseAll(rep){
for (aa in rep.getChildren()) {
var repContainer:com.ibm.xsp.component.UIRepeatContainer = aa;
for(bb in repContainer.getChildren()){
if(typeof bb == "com.ibm.xsp.component.UIPanelEx"){
var repChildren:com.ibm.xsp.component.UIPanelEx = bb;
for(cc in repChildren.getChildren()){
if(typeof cc == "com.ibm.xsp.component.xp.XspSection"){
var sec:com.ibm.xsp.component.xp.XspSection = cc;
sec.setClosed(true);
}
}
}
}
}
}
onClick-Event des Buttons:
var rep:com.ibm.xsp.component.UIRepeat = getComponent("navRepeat");
navRepeatCloseAll(rep);
Jetzt möchte ich aber den Code so erweitern, dass bestimmte Sektionen (abhängig vom Headerstring) nicht zugeklappt werden.
Mein erster Versuch war der:
function navRepeatCloseAll(rep,headerstring){
for (aa in rep.getChildren()) {
var repContainer:com.ibm.xsp.component.UIRepeatContainer = aa;
for(bb in repContainer.getChildren()){
if(typeof bb == "com.ibm.xsp.component.UIPanelEx"){
var repChildren:com.ibm.xsp.component.UIPanelEx = bb;
for(cc in repChildren.getChildren()){
if(typeof cc == "com.ibm.xsp.component.xp.XspSection"){
var sec:com.ibm.xsp.component.xp.XspSection = cc;
if(sec.getHeader() != headerstring){
sec.setClosed(true);
}
}
}
}
}
}
}
Leider steht ein berechneter Header hier nicht zur Verfügung, was auch der Auszug aus dem SSJS-Debug aussagt (siehe Anhang)
Beim Aufruf von sec.getHeader() bekomme ich den Fehler:
com.ibm.xsp.exception.EvaluationExceptionEx: Error while executing JavaScript action expression
at com.ibm.xsp.binding.javascript.JavaScriptMethodBinding.invoke(JavaScriptMethodBinding.java:126)
at com.ibm.xsp.application.ActionListenerImpl.processAction(ActionListenerImpl.java:60)
at javax.faces.component.UICommand.broadcast(UICommand.java:324)
at com.ibm.xsp.component.UIEventHandler.broadcast(UIEventHandler.java:366)
at com.ibm.xsp.component.UIDataPanelBase.broadcast(UIDataPanelBase.java:400)
at com.ibm.xsp.component.UIDataPanelBase.broadcast(UIDataPanelBase.java:400)
at com.ibm.xsp.component.UIViewRootEx.broadcast(UIViewRootEx.java:1535)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:307)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:428)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:94)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:210)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:96)
at com.ibm.xsp.controller.FacesControllerImpl.execute(FacesControllerImpl.java:256)
at com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:228)
at com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:157)
at com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
at com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)
at com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
at com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:576)
at com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1315)
at com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:853)
at com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:796)
at com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:565)
at com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1299)
at com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:662)
at com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:482)
at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:350)
at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:306)
at com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
Caused by: com.ibm.jscript.InterpretException: Script interpreter error, line=15, col=51: Error calling method 'getHeader()' on java class 'com.ibm.xsp.component.xp.XspSection'
at com.ibm.jscript.types.JavaAccessObject.call(JavaAccessObject.java:334)
at com.ibm.jscript.types.FBSObject.call(FBSObject.java:161)
at com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:197)
at com.ibm.jscript.ASTTree.ASTArgumentList.interpretArguments(ASTArgumentList.java:65)
at com.ibm.jscript.types.FBSObject.call(FBSObject.java:153)
at com.ibm.jscript.types.FBSGlobalObject$GlobalMethod.call(FBSGlobalObject.java:219)
at com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:197)
at com.ibm.jscript.ASTTree.ASTBlock.interpret(ASTBlock.java:100)
at com.ibm.jscript.ASTTree.ASTIf.interpret(ASTIf.java:85)
at com.ibm.jscript.ASTTree.ASTForIn.interpret(ASTForIn.java:103)
at com.ibm.jscript.ASTTree.ASTBlock.interpret(ASTBlock.java:100)
at com.ibm.jscript.ASTTree.ASTIf.interpret(ASTIf.java:85)
at com.ibm.jscript.ASTTree.ASTForIn.interpret(ASTForIn.java:103)
at com.ibm.jscript.ASTTree.ASTBlock.interpret(ASTBlock.java:100)
at com.ibm.jscript.ASTTree.ASTForIn.interpret(ASTForIn.java:103)
at com.ibm.jscript.std.FunctionObject._executeFunction(FunctionObject.java:261)
at com.ibm.jscript.std.FunctionObject.executeFunction(FunctionObject.java:185)
at com.ibm.jscript.std.FunctionObject.call(FunctionObject.java:171)
at com.ibm.jscript.types.FBSObject.call(FBSObject.java:161)
at com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:197)
at com.ibm.jscript.ASTTree.ASTProgram.interpret(ASTProgram.java:119)
at com.ibm.jscript.ASTTree.ASTProgram.interpretEx(ASTProgram.java:139)
at com.ibm.jscript.JSExpression._interpretExpression(JSExpression.java:435)
at com.ibm.jscript.JSExpression.access$1(JSExpression.java:424)
at com.ibm.jscript.JSExpression$2.run(JSExpression.java:414)
at java.security.AccessController.doPrivileged(AccessController.java:310)
at com.ibm.jscript.JSExpression.interpretExpression(JSExpression.java:410)
at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:251)
at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:234)
at com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:222)
at com.ibm.xsp.binding.javascript.JavaScriptMethodBinding.invoke(JavaScriptMethodBinding.java:111)
... 28 more
Caused by: com.ibm.xsp.exception.EvaluationExceptionEx: Error while executing JavaScript computed expression
at com.ibm.xsp.binding.javascript.JavaScriptValueBinding.getValue(JavaScriptValueBinding.java:132)
at com.ibm.xsp.component.xp.XspSection.getHeader(XspSection.java:156)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at com.ibm.jscript.types.JavaAccessObject.call(JavaAccessObject.java:321)
... 58 more
Caused by: com.ibm.jscript.InterpretException: 'item' not found
at com.ibm.jscript.types.FBSReferenceByName$JavaPackageVariable.getValue(FBSReferenceByName.java:74)
at com.ibm.jscript.ASTTree.InterpretResult.getFBSValue(InterpretResult.java:70)
at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:252)
at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:234)
at com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:222)
at com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:194)
at com.ibm.xsp.binding.javascript.JavaScriptValueBinding.getValue(JavaScriptValueBinding.java:78)
Gehe überhaupt den richtige Weg? Wie komme ich an das UI Objekt des Section rann?
Oder gibts für mein Problem ne ganz andere Lösung?
Danke schon mal & Gruß
Marcus