XPages EL: adding a condition to select field name - xpages

I am using a sample database from the book "Mastering XPages - Second Editon" (chap11e2b.nsf), where they created an extended rich text editor. There is a managed bean that is used to get/set the field value. In the sample, the custom control is using this as
<mxpd2:inputRichText id="inputRichTextExtended"
style="width:100%" htmlFilter="identity"
htmlFilterIn="identity" disableModifiedFlag="false"
htmlConversionWarning="noWarning">
<mxpd2:this.value><![CDATA[#{rteBean['pageDocument.Body']}]]></mxpd2:this.value>
...
I need to check a field so I know which field to use in the control, the standard "Body" field or the "BodyHTMLMime" in case the document has a flag (field called "converted") set to "1".
How can that be done in EL language, or how can I use the rteBean.['pageDocument.Body'] in SSJS?
Worst case I create two controls and hid eacocrding to the flag, but I'm sure that is not necessary a sit can be done at the data property level.
Thanks :)
EDIT:
My code is now this:
<xp:text escape="true" id="BodyFieldName">
<xp:this.value><![CDATA[#{javascript://sessionScope.BodyFieldName = 'pageDocument.Body';
viewScope.BodyFieldName = pageDocument.getItemValueString("v2_convertedtomime") == "1" ? "pageDocument.BodyHTMLMime" : "pageDocument.Body";
viewScope.BodyFieldName; }]]>
</xp:this.value>
</xp:text>
<mxpd2:inputRichText id="inputRichTextExtended"
style="width:100%" htmlFilter="identity" htmlFilterIn="identity"
disableModifiedFlag="false" htmlConversionWarning="noWarning"
value="#{rteBean[viewScope.BodyFieldName]}">
<xp:this.converter>
<xp:converter
converterId="InputRichTextConverter">
</xp:converter>
</xp:this.converter>
...
Here is the error I get with this code:
1/28/16 1:45 PM: Exception Thrown
Context Path: /dev/x_docCLQC.nsf
Page Name: /page.xsp
javax.faces.FacesException: java.lang.StringIndexOutOfBoundsException
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:865)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:878)
at com.ibm.xsp.component.UIDataPanelBase.invokeOnComponent(UIDataPanelBase.java:416)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:878)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:878)
at com.ibm.xsp.component.UIDataPanelBase.invokeOnComponent(UIDataPanelBase.java:416)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:878)
at com.ibm.xsp.component.UIDataPanelBase.invokeOnComponent(UIDataPanelBase.java:416)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:878)
at com.ibm.xsp.component.UIDataPanelBase.invokeOnComponent(UIDataPanelBase.java:416)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:878)
at com.ibm.xsp.extlib.component.layout.UIVarPublisherBase.invokeOnComponent(UIVarPublisherBase.java:155)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:878)
at com.ibm.xsp.component.UIDataPanelBase.invokeOnComponent(UIDataPanelBase.java:416)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:878)
at com.ibm.xsp.component.UIDataPanelBase.invokeOnComponent(UIDataPanelBase.java:416)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:878)
at com.ibm.xsp.component.UIDataPanelBase.invokeOnComponent(UIDataPanelBase.java:416)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:878)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:878)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:878)
at com.ibm.xsp.component.UIViewRootEx.invokeOnComponent(UIViewRootEx.java:1552)
at com.ibm.xsp.util.AjaxUtilEx.renderAjaxPartialLifecycle(AjaxUtilEx.java:188)
at com.ibm.xsp.webapp.FacesServletEx.renderAjaxPartial(FacesServletEx.java:249)
at com.ibm.xsp.webapp.FacesServletEx.serviceAjaxPartialView(FacesServletEx.java:200)
at com.ibm.xsp.webapp.FacesServletEx.serviceAjaxPartialViewSync(FacesServletEx.java:176)
at com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:155)
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:1335)
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:1319)
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:357)
at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:313)
at com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
Caused by: java.lang.StringIndexOutOfBoundsException
at java.lang.String.substring(String.java:1111)
at mxpd2.component.InputRichText.getObjectBinding(InputRichText.java:53)
at mxpd2.component.InputRichText.processAjaxRequest(InputRichText.java:99)
at com.ibm.xsp.util.AjaxUtilEx$1.invokeContextCallback(AjaxUtilEx.java:194)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:862)

inputRichText's value has to be EL because it uses the getter and setter of rteBean.
Calculate field name and put it into a viewScope variable.
Use the viewScope variable for field name in EL:
<xp:text
escape="true"
id="computedField1">
<xp:this.value><![CDATA[#{javascript:
viewScope.fieldName = document1.getItemValueString("converted") == "1" ? "document1.BodyHTMLMime" : "document1.Body1";
""}]]></xp:this.value>
</xp:text>
<xp:div themeId="container" style="width:800px">
<mxpd2:inputRichText id="inputRichText1"
value="#{rteBean[viewScope.fieldName]}">

Related

Add client behavior dynamically with var components

I'm trying to listen event from components contained in DynaForm of primefaces-extensions, so developer can do dynamically do some custom stuff. At the end I would like to be able to do this:
<pe:dynaForm id="dynaForm" value="#{dynaFormController.model}" var="data" controlKey="#{data.name}">
<pe:dynaFormControl type="input" for="txt">
<p:inputText id="txt" value="#{data.value}" required="#{data.required}" />
</pe:dynaFormControl>
<my:ajax event="keyup" listener="#{controller.authorSelected}" key="author"/>
</pe:dynaForm>
What I want to do:
Whenever the key defined in my:ajax match the controlKey of a pe:dynaFormControl, I want to attach the my:ajax client behavior to the p:inputText.
Problems encountered:
At first, I did all of this in DynaFormRenderer#encodeBody, quite convenient since var is put in the EL context. But I ended up having this exception (similar to this https://github.com/javaserverfaces/mojarra/issues/4365):
java.lang.NullPointerException
at javax.faces.component.UIComponentBase.restoreBehaviors(UIComponentBase.java:2228)
at javax.faces.component.UIComponentBase.restoreBehaviorsState(UIComponentBase.java:2203)
at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1623)
at javax.faces.component.UIOutput.restoreState(UIOutput.java:286)
at javax.faces.component.UIInput.restoreState(UIInput.java:1422)
at com.sun.faces.application.view.FaceletPartialStateManagementStrategy$2.visit(FaceletPartialStateManagementStrategy.java:379)
at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:151)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1689)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at javax.faces.component.UIForm.visitTree(UIForm.java:371)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
at com.sun.faces.application.view.FaceletPartialStateManagementStrategy.restoreView(FaceletPartialStateManagementStrategy.java:366)
at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:138)
at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:591)
at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:151)
at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:353)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:199)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:123)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
Then I tried to do just like o:moveComponent from Omnifaces using PreRenderViewEvent, but var is not available at this moment, in fact, calling DynaForm#getValue() always return null.
Do you have any suggestions how properly attach client behavior dynamically when var comes in the picture?
More infos: Mojarra 2.2.15 & Tomcat 8

XPAges: "java.io.NotSerializableException: lotus.domino.local.Document"

I have an XPage which holds one Notes document. The intention of this page is just to show some relevant fields of the document.
Accessing the page first time is ok. And also when showing later again without changing the underlaying document is ok.
But when I navigate from this to another XPage, and change the document there (yes, I have another page dedicated to edit the document), and then come back to the "show" page, I get the java.io.NotSerializableException in the render Response Phase.
Strange: it is for a lotus.domino.local.Document ... I never want to save/serialize a document ... :-o
What I've done to find the bug in my code:
I logged the viewScope content in beforeRenderResponse Event of the page, but there are only simple objects (strings and booleans).
I set the viewState of the page to "nostate".
I set the readonly attribute of the page to "true".
I removed every "on page loading" data-bindings (switched '${...}' to '#{...}')
So what else can I do to find the point of code, where some kind of document want to be saved?
What are typical error causes in this case?
Thanks for any help to help myself! :-)
My Stacktrace:
23.11.16 10:30: Exception Thrown
Context Path: /.../.../myApp.nsf
Page Name: /page_ShowData.xsp
com.ibm.xsp.FacesExceptionEx: java.io.NotSerializableException: lotus.domino.local.Document
at com.ibm.xsp.application.AbstractStateManager.saveSerializedView(AbstractStateManager.java:121)
at com.ibm.xsp.application.StateManagerImpl.saveSerializedView(StateManagerImpl.java:152)
at com.ibm.xsp.application.ViewHandlerExImpl._saveViewState(ViewHandlerExImpl.java:455)
at com.ibm.xsp.application.ViewHandlerExImpl.saveViewState(ViewHandlerExImpl.java:449)
at com.ibm.xsp.application.ViewHandlerExImpl._renderView(ViewHandlerExImpl.java:324)
at com.ibm.xsp.application.ViewHandlerExImpl.renderView(ViewHandlerExImpl.java:336)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:103)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:210)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:120)
at com.ibm.xsp.controller.FacesControllerImpl.render(FacesControllerImpl.java:270)
at com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:261)
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:588)
at com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1335)
at com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:865)
at com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:808)
at com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:577)
at com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1319)
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:357)
at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:313)
at com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
Caused by: java.io.NotSerializableException: lotus.domino.local.Document
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1185)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
at java.util.ArrayList.writeObject(ArrayList.java:728)
at sun.reflect.GeneratedMethodAccessor652.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1059)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1502)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1433)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1179)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
at java.util.HashMap.writeObject(HashMap.java:942)
at sun.reflect.GeneratedMethodAccessor637.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1059)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1502)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1433)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1179)
at java.io.ObjectOutputStream.writeUnshared(ObjectOutputStream.java:413)
at com.ibm.xsp.application.AbstractSerializingStateManager$FastObjectOutputStream.writeObjectEx(AbstractSerializingStateManager.java:438)
at com.ibm.xsp.application.AbstractSerializingStateManager$FastObjectOutputStream.writeObjectEx(AbstractSerializingStateManager.java:417)
at com.ibm.xsp.application.AbstractSerializingStateManager$FastObjectOutputStream.writeObjectEx(AbstractSerializingStateManager.java:417)
at com.ibm.xsp.application.AbstractSerializingStateManager$FastObjectOutputStream.writeObjectEx(AbstractSerializingStateManager.java:417)
at com.ibm.xsp.application.AbstractSerializingStateManager$FastObjectOutputStream.writeObjectEx(AbstractSerializingStateManager.java:417)
at com.ibm.xsp.application.AbstractSerializingStateManager.saveSerializedView(AbstractSerializingStateManager.java:294)
at com.ibm.xsp.application.AbstractSerializingStateManager.doSaveSerializedView(AbstractSerializingStateManager.java:269)
at com.ibm.xsp.application.FileStateManager.doSaveSerializedView(FileStateManager.java:290)
at com.ibm.xsp.application.FileStateManager.doSaveSerializedView(FileStateManager.java:270)
at com.ibm.xsp.application.AbstractStateManager.saveSerializedView(AbstractStateManager.java:114)
... 25 more
My page_ShowData.xsp:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" pageTitle="Show Data"
xmlns:xc="http://www.ibm.com/xsp/custom"
xmlns:xe="http://www.ibm.com/xsp/coreex" readonly="true"
viewState="nostate"
afterPageLoad="#{javascript:print('page_ShowData.afterPageLoad()');}">
<!-- ... -->
<xp:this.data>
<xp:dominoDocument var="stamm" formName="Masterdata" ignoreRequestParams="false">
<xp:this.action>
<![CDATA[#{javascript:
// ensure to set the unid if known
if (viewScope.stammid == null){
viewScope.stammid = param.get('documentId');
}
if(typeof viewScope.stammid == "undefined" || viewScope.stammid == null || viewScope.stammid == ""){
return; // empty means 'create'
} else {
return 'openDocument';
}
}]]>
</xp:this.action>
<xp:this.documentId>
<![CDATA[#{javascript:return viewScope.stammid;}]]>
</xp:this.documentId>
<xp:this.postOpenDocument>
<![CDATA[#{javascript:
<!-- set some viewScope vars -->
}]]>
</xp:this.postOpenDocument>
<xp:this.postNewDocument>
<![CDATA[#{javascript:
<!-- set some viewScope vars -->
}]]>
</xp:this.postNewDocument>
</xp:dominoDocument>
</xp:this.data>
<!-- ... -->
<xp:this.beforeRenderResponse>
<![CDATA[#{javascript:
try{
// print all viewScope vars
var vsKeys:java.util.Set = viewScope.keySet();
for (var k in vsKeys){
var v = viewScope.get(k);
print('viewScope - ['+k.toString()+'] (serializable='+(k instanceof java.io.Serializable)+') = ['+v+'] (instance='+(typeof v)+', serializable='+(v instanceof java.io.Serializable)+')');
}
}]]>
</xp:this.beforeRenderResponse>
<!-- some UI content -->
</xp:view>
On one of those two XPages you're storing a NotesDocument (not DominoDocument datasource, but a NotesDocument object) in a scoped variable. Domino objects aren't serializable, which is what's throwing the error. The most likely place is the page you're moving from.
If you need access to a specific document, store the UNID of the document in the scoped variable and use database.getDocumentByUNID() to retrieve it. That's almost certainly what the DominoDocument datasource does.

jsf render allways an xhtml page

Hi im testing my new app, and i have a problem when i click a button on my form, it has a table on it and im always check for a values, if it true it render if not it doesnt, and a button for register data . The problem is that im deleting some data of the table by a script and it give me a null pointer exception when i click the button. In the logs files it says it render the page again and then goes to the specific function of the button, and since i have already delete the data when it tried to render the page again give me a error 500.
here is me table :
<h:panelGroup id="tab1" rendered="#{DataControl.tabIndex == 1}">
<h:dataTable>
<h:column>
<h:commandButton disabled="#{DataControl.CheckDelete(item.intIdAddress)}" />
</h:column>
</h:dataTable>
<h:commandButton action="#{DataControl.AddAddress}" />
</h:panelGroup>
<h:panelGroup id="tab2" rendered="#{DataControl.tabIndex == 2}">
< Refister Form >
</h:panelGroup>
here is my checkDelete function :
public boolean CheckDelete() {
Util.getLog().info("CheckDelete for id : "+ id);
if (id.render)
return true;
else
return false;
}
here is my AddAddress function :
public String AddAddress(){
Util.getLog().info("Go to Register Div");
tabIndex = 2;
}
And the Logs File when im in the form and click the button :
Enter to filter : Has Session
CheckDelete for id : 1
CheckDelete for id : 2
CheckDelete for id : 3
CheckDelete for id : 4
Go to Register Div
And when i delete the data N° 2 the Logs file is (im in the form, delete the data and then i click the button):
Enter to filter : Has Session
CheckDelete for id : 1
javax.el.ELException: /pages/session/account_settings.xhtml #101,253 disabled="#{GeneralDataControl.VerificaEliminacion(item.intIdAddress)}": java.lang.NullPointerException
javax.faces.FacesException: javax.el.ELException: /pages/session/account_settings.xhtml #101,253 disabled="#{GeneralDataControl.VerificaEliminacion(item.intIdAddress)}": java.lang.NullPointerException
at javax.faces.component.UIComponentBase$AttributesMap.get(UIComponentBase.java:2214)
at com.sun.faces.util.Util.componentIsDisabledOrReadonly(Util.java:418)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.shouldDecode(HtmlBasicRenderer.java:739)
at com.sun.faces.renderkit.html_basic.ButtonRenderer.decode(ButtonRenderer.java:77)
at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:791)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1048)
at javax.faces.component.UIData.iterate(UIData.java:1477)
at javax.faces.component.UIData.processDecodes(UIData.java:980)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1043)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1043)
at javax.faces.component.UIForm.processDecodes(UIForm.java:212)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1043)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1043)
at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:920)
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:74)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1213)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1154)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:145)
at com.alignet.wallet.cliente.filter.FiltroHibernate.doFilter(FiltroHibernate.java:90)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:848)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:691)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:654)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:526)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:90)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:764)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1478)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:133)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:457)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:515)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:300)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:196)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:751)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:881)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1593)
Caused by: javax.el.ELException: /pages/session/account_settings.xhtml #101,253 disabled="#{GeneralDataControl.VerificaEliminacion(item.intIdAddress)}": java.lang.NullPointerException
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190)
at javax.faces.component.html.HtmlCommandButton.isDisabled(HtmlCommandButton.java:183)
at sun.reflect.GeneratedMethodAccessor489.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:619)
at javax.faces.component.UIComponentBase$AttributesMap.get(UIComponentBase.java:2206)
... 44 more
Caused by: java.lang.NullPointerException
at com.alignet.wallet.cliente.web.GeneralDataJSFAction.VerificaEliminacion(GeneralDataJSFAction.java:388)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:619)
at javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:737)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:467)
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:246)
at com.sun.el.parser.AstValue.getValue(AstValue.java:111)
at com.sun.el.parser.AstValue.getValue(AstValue.java:163)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:106)
... 50 more
its seems that jsf always render the page before to do the submit, i dont know how to solve this. I think is a configuration thing.
Im using a filter (the only filter ) to check for the session of the user and then a "doFilter" to let the response continue.
Thanks 4 ur time.

NotesXSPDocument - Inserting a boolean breaks getDocument

I have an XPage which has just broken due to (what should have been) a small change.
If I run (where document1 is NotesXSPDocument datasource) :
document1.replaceItem("ItemName", false); //or true, or any variable/formula that results in a boolean
followed by:
document1.getDocument(true);
I end up with an error
[TypeError] Exception occurred calling method NotesXspDocument.getDocument(boolean) null
This is on a new document (so not saved yet, which I've not tested, but might make a difference), hence I can't just set the field on the underlying doc.
It doesn't seem to be an artifact of anything else in the page, as a basic test page confirms it. It doesn't happen with anything (I've found) other than a boolean.
Any advice, other than just change the data type? I guess that's what I'll end up doing (along with a bug report) but I'd like to know I'm not missing something first.
Thanks
------------Test XSP code------------
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"><xp:this.data>
<xp:dominoDocument var="document1" formName="Test" />
</xp:this.data><xp:span style="font-weight:bold">
Button 1 code:</xp:span><xp:br></xp:br>document1.replaceItemValue("Test",false);
<xp:br></xp:br>var doc:NotesDocument = document1.getDocument(true);
<xp:br></xp:br>print(doc.toString());<xp:br></xp:br>
<xp:button value="Test 1" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:document1.replaceItemValue("Test",false);
var doc:NotesDocument = document1.getDocument(true);
print(doc.toString());}]]></xp:this.action>
</xp:eventHandler></xp:button>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:br></xp:br><xp:span style="font-weight:bold">
Button</xp:span><xp:span style="font-weight:bold"> 2</xp:span><xp:span style="font-weight:bold"> Code:</xp:span><xp:span style="font-weight:bold"></xp:span> <xp:br></xp:br>document1.replaceItemValue("Test","Test);<xp:br></xp:br>var doc:NotesDocument = document1.getDocument(true);
<xp:br></xp:br>print(doc.toString());<xp:br></xp:br><xp:button value="Test 2" id="button2">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:document1.replaceItemValue("Test","Test");
var doc:NotesDocument = document1.getDocument(true);
print(doc.toString());}]]></xp:this.action>
</xp:eventHandler></xp:button></xp:view>
If you have a look in the stack trace you will see the following:
....
NotesException: Unknown or unsupported object type in Vector
lotus.domino.local.Document.NreplaceItemValue(Native Method)
lotus.domino.local.Document.replaceItemValue(Unknown Source)
com.ibm.xsp.model.domino.wrapped.DominoDocument.applyChangesToDoc(DominoDocument.java:1698)
com.ibm.xsp.model.domino.wrapped.DominoDocument.applyChanges(DominoDocument.java:1649)
com.ibm.xsp.model.domino.wrapped.DominoDocument.getDocument(DominoDocument.java:544)
com.ibm.xsp.script.WrapperDominoEx$fct_DominoDocument.call(WrapperDominoEx.java:254)
....
The problem is that you use the replaceItemValue method with an unsupported data type.
Here is a list of all allowed data types:
String Text
Integer Number
Double Number
DateTime Date-time item
java.util.Vector with String, Integer, Double, or DateTime elements Multi-value text, number, or date-time item
Item Same data type as the Item
The error is raised in the moment the backend document is synchronized with the datasource document. That's why it fails while calling document1.getDocument(true).
Hope this helps
Sven
EDIT:
Why are you setting the value to false?

After confirmation, navigate to first tab of wizard

Pretty much, everything is said in title of topic.What I need to achieve is that when I am in last (confirm) tab of wizard and click on my button, after everything is done, I want to back to first tab of wizard. Of course, everything in wizard should be reset after that.
Well, it isn't help. Currently I am totally confused. On click of button I get this exception, but not in server log, only in browser I get:
An Error Occurred:
java.lang.NullPointerException
java.lang.NullPointerException
at org.primefaces.component.datatable.DataHelper.decodeFilters(DataHelper.java:167)
at org.primefaces.component.datatable.DataTableRenderer.decode(DataTableRenderer.java:51)
at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:790)
at javax.faces.component.UIData.processDecodes(UIData.java:980)
at org.primefaces.component.datatable.DataTable.processDecodes(DataTable.java:542)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1042)
at org.primefaces.component.panel.Panel.processDecodes(Panel.java:282)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1042)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1042)
at org.primefaces.component.wizard.Wizard.processDecodes(Wizard.java:210)
at javax.faces.component.UIForm.processDecodes(UIForm.java:216)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1042)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1042)
at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:941)
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:619)
Button looks like this:
<p:commandButton ajax="false" value="Save service" action="#{kuBean.saveService}"
update="growl"/>
Interesting...
Assuming that your bean is #ViewScoped then a simple page redirect to the url of your wizard page should reinstantiate your wizards managed bean. If that doesn't work you can append the GET property [url]?faces-redirect=true to the URL.
This won't work if your managed bean is #SessionScoped however as the data and state information from the previous wizard confirmation will likely still be there. The best solution would be to switch to ViewScoped and if that is not possible then write a reset method of the managed bean that can clear the state and data of the managed bean.
try using the flowListener of the p:wizard
<p:wizard flowListener="#{userWizard.handleFlow}">
...
</p:wizard>
in your bean:
public String handleFlow(FlowEvent event) {
String currentStepId = event.getCurrentStep();
String stepToGo = event.getNextStep();
//if(skip)
//return "confirm";
//else
//return event.getNextStep();
... portion where you are to return to the first tab
return "id_value_of_first_tab";
}

Resources