如何使用Trinidad和facelets创建模式对话框(How to create a modal dialog with Trinidad and facelets)

编程入门 行业动态 更新时间:2024-10-20 17:22:40
如何使用Trinidad和facelets创建模式对话框(How to create a modal dialog with Trinidad and facelets)

我正在尝试创建一个模式对话框,当按下tr:commandNavigationItem时弹出该模式对话框。 我可以弹出一个弹出窗口,当我单击我创建的“取消”按钮时,它将调用returnListener,但弹出窗口本身不会消失。 调用“提交”按钮会导致异常。

该网站正在使用facelets,因此调用页面具有它使用的模板。

我在日志中收到以下警告:

W org.apache.myfaces.trinidad.component.UIXComponentBase getClientId getClientId should not be called while the view is being constructed. Component ID: holdOrder_hold

W com.ibm.ws.webcontainer.srt.SRTServletResponse setIntHeader SRVE8094W: WARNING: Cannot set header. Response already committed.

这是调用页面(.xhtml):

<tr:navigationPane hint="bar" inlineStyle="width:100%;" id="completeNavBar"> ... <tr:commandNavigationItem id="holdButton" text="#{odMessages['BUTTON_HOLD_ORDER']}" partialSubmit="true" useWindow="true" rendered="#{taskHandler.holdAndReleaseEnabled}" action="dialog:holdOrder" immidiate="true" returnListener="#{taskHandler.handleReturnHoldDialog}" windowHeight="350" windowWidth="800"/> ... </tr:navigationPane>

这是完整的对话框页面(.xhtml):

<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:tr="http://myfaces.apache.org/trinidad" xmlns:trd="http://myfaces.apache.org/trinidad/demo" xmlns:trh="http://myfaces.apache.org/trinidad/html"> <jsp:directive.page contentType="text/html;charset=utf-8"/> <f:view> <tr:document title="Put Order On Hold"> <tr:form> <tr:messages globalOnly="true"/> <tr:panelFormLayout> <tr:inputText id="holdOrder_comment" rows="5" label="Comment:" value="#{taskHandler.task.holdObj.holdComment}" /> <f:facet name="footer"> <tr:commandButton id="holdOrder_hold" actionListener="#{taskHandler.holdToDo}" text="Submit" partialSubmit="true"/> <tr:commandButton id="holdOrder_cancel" actionListener="#{taskHandler.cancelDialog}" text="cancel" partialSubmit="true"/> </f:facet> </tr:panelFormLayout> </tr:form> </tr:document> </f:view> </ui:composition>

这是使用的单个支持bean:

@ManagedBean @ViewScoped public class TaskHandler implements Serializable { ... public void holdToDo(ActionEvent event) { System.out.println("putting on hold"); HashMap<Object, Object> returnMap = new HashMap<Object, Object>(); try { boolean response = ToDoHold.execute(task); if(!response) { returnMap.put("returnValue", "no validation errors"); } } catch (Exception e) { System.out.println("exception in holdToDo"); e.printStackTrace(); } RequestContext.getCurrentInstance().returnFromDialog(Boolean.TRUE, returnMap); } public void handleReturnHoldDialog(ReturnEvent event) { System.out.println("returning hold Dialog"); } public void cancelDialog(ActionEvent event) { System.out.println("cancelling dialog"); try { HashMap<Object, Object> returnMap = new HashMap<Object, Object>(); returnMap.put("returnValue", "cancel"); RequestContext.getCurrentInstance().returnFromDialog(Boolean.FALSE, returnMap); } catch(Exception e) { System.out.println("cancelling dialog: exception"); e.printStackTrace(); } } ... }

使用的版本:Trinidad 2.0.1 JSF 2.0 Servlet 3

I am trying to create a modal dialog that pops up when a tr:commandNavigationItem is pressed. I can get a pop up to appear, and when I click the "cancel" button I created, it will call the returnListener, but the pop up itself won't disappear. Calling the "submit" button causes an exception.

The website is using facelets so the calling page has a template it uses.

I get the following warnings in the log:

W org.apache.myfaces.trinidad.component.UIXComponentBase getClientId getClientId should not be called while the view is being constructed. Component ID: holdOrder_hold

and

W com.ibm.ws.webcontainer.srt.SRTServletResponse setIntHeader SRVE8094W: WARNING: Cannot set header. Response already committed.

Here is the calling page (.xhtml):

<tr:navigationPane hint="bar" inlineStyle="width:100%;" id="completeNavBar"> ... <tr:commandNavigationItem id="holdButton" text="#{odMessages['BUTTON_HOLD_ORDER']}" partialSubmit="true" useWindow="true" rendered="#{taskHandler.holdAndReleaseEnabled}" action="dialog:holdOrder" immidiate="true" returnListener="#{taskHandler.handleReturnHoldDialog}" windowHeight="350" windowWidth="800"/> ... </tr:navigationPane>

Here is the complete dialog page (.xhtml):

<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:tr="http://myfaces.apache.org/trinidad" xmlns:trd="http://myfaces.apache.org/trinidad/demo" xmlns:trh="http://myfaces.apache.org/trinidad/html"> <jsp:directive.page contentType="text/html;charset=utf-8"/> <f:view> <tr:document title="Put Order On Hold"> <tr:form> <tr:messages globalOnly="true"/> <tr:panelFormLayout> <tr:inputText id="holdOrder_comment" rows="5" label="Comment:" value="#{taskHandler.task.holdObj.holdComment}" /> <f:facet name="footer"> <tr:commandButton id="holdOrder_hold" actionListener="#{taskHandler.holdToDo}" text="Submit" partialSubmit="true"/> <tr:commandButton id="holdOrder_cancel" actionListener="#{taskHandler.cancelDialog}" text="cancel" partialSubmit="true"/> </f:facet> </tr:panelFormLayout> </tr:form> </tr:document> </f:view> </ui:composition>

Here is the single backing bean used:

@ManagedBean @ViewScoped public class TaskHandler implements Serializable { ... public void holdToDo(ActionEvent event) { System.out.println("putting on hold"); HashMap<Object, Object> returnMap = new HashMap<Object, Object>(); try { boolean response = ToDoHold.execute(task); if(!response) { returnMap.put("returnValue", "no validation errors"); } } catch (Exception e) { System.out.println("exception in holdToDo"); e.printStackTrace(); } RequestContext.getCurrentInstance().returnFromDialog(Boolean.TRUE, returnMap); } public void handleReturnHoldDialog(ReturnEvent event) { System.out.println("returning hold Dialog"); } public void cancelDialog(ActionEvent event) { System.out.println("cancelling dialog"); try { HashMap<Object, Object> returnMap = new HashMap<Object, Object>(); returnMap.put("returnValue", "cancel"); RequestContext.getCurrentInstance().returnFromDialog(Boolean.FALSE, returnMap); } catch(Exception e) { System.out.println("cancelling dialog: exception"); e.printStackTrace(); } } ... }

Versions used: Trinidad 2.0.1 JSF 2.0 Servlet 3

最满意答案

所以我从来没有完全解决过这个问题,但事实证明问题是在对话框中使用<f:facet name="footer"> (上面提供的XHTML)是造成问题的原因,并且删除了facet导致了两个按钮开始正常工作。 这可能是一个错误,但由于公司指导原则,我使用的是非最新版本的trinidad(1.26)。

So I never solved this completely, but it turned out that the problem was using <f:facet name="footer"> in the dialog (the XHTML is available above) was what was causing the problem, and removing the facet caused both buttons to start working correctly. This may be a bug but I'm using a non-up-to-date version of trinidad (1.26) due to corporate guidelines.

更多推荐

本文发布于:2023-08-01 13:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1359184.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   对话框   模式   Trinidad   dialog

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!