2012-10-10 32 views
0

正如标题所示,当我点击a4j:commandLink时,该方法执行完美并更新我需要的表。a4j:commandLink从xhtml擦除javascript

问题是,页面的js在a4j:commandLink发布到bean之后正在消失。

编辑:为了更清楚一点,当我的意思是js消失时,会发生什么情况是,当我在Mozilla Firebug中查找页面的JavaScript时,它不显示它。 这是正常的吗?我究竟做错了什么?任何最好的方法呢?

的代码是:

<h:panelGroup id="examplePanel" > 
<h:panelGroup rendered="#{not empty exampleBean.list}"> 
<table id="listDataTable" width="100%" cellspacing="0" 
    cellpadding="0" border="0" style="margin-left: 0pt; width: 716px;"> 
    <thead> 
     <tr> 
      <th>col1</th> 
      <th>col2</th> 
      <th>col3</th>        
      <th class="shortCol">col4</th> 
     </tr>  
    </thead> 
    <tbody> 
    <a4j:repeat value="#{exampleBean.list}" rowKeyVar="itStatus" var="item"> 
     <tr> 
      <td> 
       <h:outputText value="#{exampleBean.exampleShow(item)}" /> 
      </td> 
      <td> 
       <h:outputText value="#{exampleBean.exampleShow(item)}" /> 
      </td> 
      <td> 
       <h:outputText value="#{exampleBean.exampleShow(item)}" /> 
      </td>     
      <td> 
       <h:commandLink action="#{exampleShow(item)}" ></h:commandLink> 
      </td>        
     </tr>   
    </a4j:repeat> 
    </tbody> 
</table> 
</h:panelGroup> 
</h:panelGroup> 
<h:outputLabel value="* #{locale.name}:" /> 
<h:inputText value="#{exampleBean.exampleName}" 
disabled="#{not exampleBean.edit}" id="exampleName" /> 

<div class="button search"> 
**<a4j:commandLink action="#{exampleBean.objetToTable}" value="#{locale.create}" render="exampleTurnPanel" ></a4j:commandLink>** 
</div> 

在此之前,我使用的是H:commandLink用F:AJAX内部。但是有了这个,这个bean没有这个值,因为POST永远都不会完成。正确?

<h:commandLink action="#{exampleBean.objetToTable}"      value="#{locale.create}"> 
<f:ajax execute="examplePanel" render="examplePanel" onevent="setExampleTableCss"/>        </h:commandLink> 

REGARDS。

+0

如果将JavaScript代码移到“exampleTurnPanel”组件外部,会更好。如果这不起作用,请隔离问题并确保它是错误(或不是)。 –

回答

0

我不确定您的意思是消失JavaScript,但请注意,您的<a4j:commandLink>更新exampleTurnPanel而不刷新整个页面。这意味着exampleTurnPanel的新内容不受您在加载页面时执行的任何JavaScript的影响。

如果你有一些JavaScript代码会影响exampleTurnPanel的内容,那么你应该把它放在exampleTurnPanel之内,以使它在面板的每次更新时都能运行。或者,您可以在更新后使用的oncomplete属性明确地调用它。

<h:commandLink>情况下,你需要<f:ajax event = "action" ... />,但它不应该从<a4j:commandLink>是不同的(但请注意,在onevent="setExampleTableCss"<f:ajax> - 不,你需要它的<a4j:commandLink>oncomplete?)。

+0

我正在使用a4j:命令cuz我不​​想再加载整个页面,只是在它的表格。 我会尽量把js放在桌子里,看看会发生什么。 –

+0

没有工作这种方法(表中的JS) –