2010-11-08 127 views
2

关闭我面临着同样的问题,因为这里所描述Rich modalpanel closes automatically丰富modalpanel自动

我使用RichFaces的3.3.0(包含在缝2.12)。我试图隔离这个问题,Firebug显示在modalpanel出现后,会生成对服务器的请求。数小时后面板关闭。我为rich_modalPanel标签(在表单外部)处理了几个位置。

任何想法?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:rich="http://richfaces.org/rich" 
    xmlns:a="http://richfaces.org/a4j" 
    xmlns:s="http://jboss.com/products/seam/taglib"> 
<head /> 
<body id="pgHome"> 
<f:view> 
    <div id="document"> 
     <h:form id="login"> 
     <fieldset> 
      <h:outputLabel id="UsernameLabel" for="username">Login Name</h:outputLabel> 
      <h:inputText id="username" value="#{identity.username}" style="width: 175px;" /> 
     </fieldset> 
     <h:commandButton id="search2" value="modal" 
      onclick="#{rich:component('mp')}.show()" /> 

     </h:form> 
     <rich:modalPanel id="mp" height="200" width="500"> 
      <f:facet name="header"> 
       <h:outputText value="Modal Panel Title" /> 
      </f:facet> 
     </rich:modalPanel> 
    </div> 
</f:view> 
</body> 
</html> 

编辑:

我终于用这个例子:

<rich:modalPanel id="modalPanelID"> 
    <f:facet name="header"> 
     <h:outputText value="header" /> 
    </f:facet> 
    <a onclick="Richfaces.hideModalPanel('modalPanelID');" href="#">Hide</a> 
</rich:modalPanel> 
<a onclick="Richfaces.showModalPanel('modalPanelID');" href="#">Show</a> 
+0

应该当你按下按钮打开,如'的onclick =“#declaed面板。{丰富:成分( 'MP')}秀( )“' – 2010-11-08 18:12:48

回答

8

这种现象是正常的,因为你使用命令按钮用下面的代码显示您ModalPanel

<h:commandButton id="search2" value="modal" onclick="#{rich:component('mp')}.show()" /> 

commandButton将显示ModalPanel,并然后将提交表单。这将强制页面完全重新显示,这就是为什么你会得到这种行为。

解决你的问题,你必须return false;onclick事件,这可以转化为显示模式面板,然后停止任何处理的末端,即不提交表单。使用代码如下:

<h:commandButton id="search2" value="modal" onclick="#{rich:component('mp')}.show(); return false;" /> 
1

我的猜测是,由于使用的是h:commandButton您发布的形式,除非这是你想要做什么,那就是问题所在。

至少使按钮返回false,所以它不发布,或使用正常的HTML按钮。

+0

+1谢谢,对不起,我不明白你的意思是'返回false',因为romaintaz的答案工作,这是正确的。 – stacker 2010-11-09 10:15:27

+0

是的,下次我可以告诉你代码示例 – 2010-11-09 12:23:09

2

尝试使用的<a4j:commandButton>代替<h:commandButton>

但因为你只是有onclick,你不需要commandButton在所有 - 使用<input type="button" onclick=".." />

+0

这仍然会发布表单和结果相同的行为 – 2010-11-09 09:42:02

+0

@Shervin没有它不会。 ' Bozho 2010-11-09 09:47:23

0

我有一个smiliar问题。我使用commandButton来上传文件。使用onClick事件触发事件而不点击加载页面。如果我使用我的模态面板自动隐藏的动作。点击commandButton后,模态面板应该保持打开状态。我需要提交表单来处理bean中上传的数据。

这里是我的代码...

<h:commandButton id="Button" 
    process="@this,attachmentPanel" 
    binding="#{actionButton}" 
    value="#{messages['view.attachment.add']}" 
    action="#{myHandler.addAttachment()}" 
    reRender="attachmentFramePanel"> 
</h:commandButton>