How to wrap ivy composite component by a outputPanel dynamically
Hi ivy team,
I need to wrap ivy composite component by a outputPanel. So in the event [postAddToView][1], i do some thing following:
1. Scan UI: to get the list of components
2. Update UI: i loop on that list. Then i get the parent of ivy component, replace ivy component by the new outputLabel and assign ivy component to outLabel's children.
It works for other component like InputText, Label... But goes wrong when i get **PermissionException** with Ivy component.
add event postAddToView to Address component
Address xhtml
< cc:interface componentType="IvyComponent">
< /cc:interface>
< cc:implementation>
< h:panelGroup layout="block" styleClass="component-wrapper" id="AddressPanel" >
< f:event listener="#{logic.processView}" type="preValidate" ></f:event>
< f:event listener="#{logic.postValidate}" type="postValidate" ></f:event>
< f:event listener="#{logic.initializeView}" type="postAddToView"></f:event>
< /h:panelGroup>
< /cc:implementation>
Demo xhtml
< h:form id="form">
< f:event listener="#{logic.preValidate}" type="preValidate" ></f:event>
< f:event listener="#{logic.postValidate}" type="postValidate" ></f:event>
< f:event listener="#{logic.postAddToView}" type="postAddToView"></f:event>
< p:outputLabel for="firstNameDemo" value="First name" title="Fist tooltip"/>
< p:inputText id="firstNameDemo" value="#{data.firstNameDemo}"/>
< ic:.DemoComponent data="#{data.person}" ></ic:DemoComponent>
< ic:ch.axonivy.fintech.basic.component.AddressComponent
startMethod="start" id="abc" value="#{data.address}" ></ic:.AddressComponent>
< /h:form>
wrap
OutputPanel outputPanel = UIComponentUtil.createOutputPanel(param.getFacesContext());
outputPanel.setId(ivyComponent.getId() + UIComponentUtil.PARENT_SUFFIX);
ivyComponent.getParent().getParent().getChildren().set(ivyComponent.getParent().getParent().getChildren().indexOf(ivyComponent.getParent()), outputPanel);
outputPanel.getChildren().add(ivyComponent.getParent());
Error
PermissionDeniedException: Session 1 (Developer) is not allowed to call method public ch.ivyteam.ivy.cm.IContentManagementSystem ch.ivyteam.ivy.cm.internal.ContentManagement.findCms(ch.ivyteam.ivy.application.IProcessModelVersion).
The session does not fulfill the permission rule SESSION IS SYSTEM
ProvisionException: Unable to provision, see the following errors:
Stack trace
org.apache.myfaces.view.facelets.el.ContextAwareELException: javax.el.ELException: ch.ivyteam.ivy.bpm.engine.restricted.error.BpmErrorHandler$UnhandledException: BpmError ivy:error:system
Unique ID: 1528153199ECF258
Process Element: postAddToView(PostAddToViewEvent) <1524368C6B07FA9C-f8>
at org.apache.myfaces.view.facelets.el.ContextAwareTagMethodExpression.invoke(ContextAwareTagMethodExpression.java:108)
at org.apache.myfaces.view.facelets.tag.jsf.core.EventHandler$Listener.processEvent(EventHandler.java:273)
at javax.faces.component.UIComponent$EventListenerWrapper.processEvent(UIComponent.java:1624)
at javax.faces.event.SystemEvent.processListener(SystemEvent.java:40)
at javax.faces.event.ComponentSystemEvent.processListener(ComponentSystemEvent.java:51)
at org.apache.myfaces.application.ApplicationImpl._traverseListenerList(ApplicationImpl.java:2595)
at org.apache.myfaces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:595)
at javax.faces.application.ApplicationWrapper.publishEvent(ApplicationWrapper.java:328)
at javax.faces.application.ApplicationWrapper.publishEvent(ApplicationWrapper.java:328)
at javax.faces.component.UIComponentBase._publishPostAddToViewEvent(UIComponentBase.java:243)
at javax.faces.component.UIComponentBase._publishPostAddToViewEvent(UIComponentBase.java:262)
Please give me your feedback.
Thanks for your support!
[1]: http://docs.oracle.com/javaee/6/api/javax/faces/event/PostAddToViewEvent.html