单击commandButton时无法呈现panelGroup(JSF)

时间:2014-04-17 23:23:30

标签: ajax jsf

我一直在尝试创建一个带有panelGroup的弹出窗口,我成功地创建了一个,但每次单击commandButton时,假设要渲染panelGroup,它会重新加载整个页面,所以我决定使用ajax。我希望每次单击commandButton时都会呈现panelGroup,但它给出了一个错误:“malformedXml:在更新期间:j_idt8:找不到comp1”

这是我的代码:

<h:form>
<h:commandButton value="Show Popup" action="#{popupBean.open}">
<f:ajax event="action" render="comp1"/>
</h:commandButton>
<div style="position:absolute;top:200px;left:500px; background-color:palevioletred;height:50%; width:50%">
<h:panelGroup rendered="#{popupBean.popupStatus}" id="comp1">

<h:panelGroup>
<div align="center" class="popupBody"><font size="2" style="position:relative; top:5px">
 <table id="appDetails" width="270px">

 <tr>
                                                         <td width="165px">Appliance Name:&nbsp;</td><td><h:outputText value="Galaxy Tab"/></td>
                                                 </tr>
                                                     <tr>

 <td>Available.    Quantity:&nbsp;<td><td><h:outputText value="300" /></td>
                                                 </tr>
                                                 <tr>
                                                     <td>Price:&nbsp;</td><td><h:outputText value="64,000" /></td>
                                                 </tr>
                                                 <tr>
                                                     <td>Discount:&nbsp;</td><td><h:outputText value="10,000" /></td>
                                                 </tr>
                                                 <tr>
                                                     <td>Amount:&nbsp;</td><td><h:outputText value="54,000" /></td>
                                                 </tr>
                                             </table>

</font>
                <br/><br/>

   

<h:panelGroup>
<div class="popupheader" >
<div class="title"><h:outputText.    value="Details"/></div>
<div class="button"><h:commandButton styleClass="closeButton" actionListener="#{popupBean.close}" 
                                                               alt="close" style="border:1;"/></div>
</div>
</h:panelGroup>

</h:panelGroup>
</div>
</h:form>

这是我的托管bean:

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import java.io.Serializable;
import javax.faces.event.ActionEvent;
import javax.faces.event.AjaxBehaviorEvent;

/**
 *
 * @author DavidLaxi
 */
@ManagedBean
@SessionScoped

public class PopupBean implements Serializable{
 int track; 
 private static final long serialVersionUID = 1L;
boolean popupStatus = false;
public static int count = 0;

public PopupBean() {
 count  ;
 setTrack(count);
}
public void setTrack(int track){
this.track = track;
}
public int getTrack(){
return track;
}
public void setPopupStatus(boolean popupStatus){
this.popupStatus=popupStatus;
}
public boolean getPopupStatus(){
return popupStatus;
}
public void open(){

setPopupStatus(!popupStatus);
}
public void close(){
setPopupStatus(false);
}
}

我真的需要帮助。

1 个答案:

答案 0 :(得分:0)

乌拉!!感谢GOD我找到了答案,我想要做的就是使用ajax来渲染表单而不是panelGroup。

E.g

<h:form id="formval1">
  <h:commandButton value="submit" action="#{managedBean}">
<f:ajax event="action" render="formval1"/>
</h:commandButton>

    ......所有其他的东西......          

感谢大家的帮助和关心,我很感激。