RichFaces中的彈出式面板相當醜陋,但要誠實。有幾次調用一些涉及到的JavaScript,這使得不容易推導出一般可用的東西。反正,我嘗試以下:創建一個RichFaces彈出面板作爲Facelets子視圖/構圖不可隱藏
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<h:commandLink>
<h:graphicImage library="images/icons" name="#{buttonImageFileName}" />
<rich:tooltip value="#{buttonTooltipText}" direction="bottomRight" />
<rich:componentControl target="#{popupId}" operation="show" />
</h:commandLink>
<rich:popupPanel modal="true"
height="#{popupHeight}"
resizeable="#{popupResizable}"
onmaskclick="#{componentCallToId}.hide(); return false;"
id="#{popupId}">
<f:facet name="header">
<h:outputText value="#{popupHeaderText}" />
</f:facet>
<f:facet name="controls">
<h:outputLink value="#" onclick="#{componentCallToId}.hide(); return false;">
<h:outputText value="X" />
</h:outputLink>
</f:facet>
<p>#{popupSubject}</p>
<p>
<h:inputText value="#{inputTextBean[inputTextProperty]}" styleClass="full-width" id="#{inputTextId}" />
</p>
<h:panelGrid columns="2" style="margin: 0 auto;">
<h:commandButton value="OK"
action="#{acceptButtonBean[acceptButtonMethod](acceptButtonMethodArg)}"
onclick="#{componentCallToId}.hide(); return true;">
<a4j:ajax execute="@this #{inputTextId}" render="@form" />
</h:commandButton>
<h:commandButton value="Cancel" onclick="#{componentCallToId}.hide(); return false;" immediate="true" />
</h:panelGrid>
</rich:popupPanel>
</ui:composition>
這顯示圖像按鈕,會彈出一個簡單的輸入對話框,這是應該通過點擊彈出窗口外被隱藏(onmaskclick =「...」) ,通過點擊右上角的彈出框(<f:facet>
與onclick="..."
),或者按取消<h:commandButton onclick="...">
。在確定AJAX表格是假設被提交,彈出窗口也被隱藏。但沒有任何反應(無法關閉):
EL表達式#{componentCallToId}.hide(); return false;
是「問題兒童」在上面。它不是那樣工作的。
在其原來,這裏非Facelets的變種(http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=popup&sample=modalPopup&skin=classic)控制組件的調用是這樣的:
<h:commandButton value="Cancel" onclick="#{rich:component('add-root-chapter-popup')}.hide(); return false;" immediate="true" />
我通過以下參數<ui:include>
:
<ui:include src="/subviews/add-node-clink-input-popup.xhtml">
<ui:param name="buttonImageFileName" value="add.png" />
...
<ui:param name="popupId" value="add-root-chapter-popup" />
<ui:param name="componentControlCallToId" value="rich:component('add-root-chapter-popup')" />
...
</ui:include>
注意長條目(其餘的似乎在工作 - 即使是bean + method + arg的奇怪語法,但這不是這裏的焦點)。
問:
爲什麼不<ui:param name="componentControlCallToId" value="rich:component('add-root-chapter-popup')" />
工作?當在彈出窗口外點擊,X'ing或按OK或Cancel(彈出保留)時,目前沒有任何反應。
螢火蟲僅示出了:
syntax error
.hide(); return false;
貌似表達進行評估,以空/空字符串。
怎麼回事?它可以修復嗎?我的替代品是什麼?
PS:請注意,那我以前嘗試過使用 「popupId」 在Facelets的表達像
<h:commandButton value="Cancel" onclick="#{rich:component('popupId')}.hide(); return false;" immediate="true" />
但是這有相同的結果。