我一直试图用panelGroup创建一个弹出窗口,我成功地创建了一个,但每次我单击命令按钮(假设是渲染panelGroup)时,它都会重新加载整个页面,所以我决定使用ajax。我希望每次单击命令按钮时都能呈现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: </td><td><h:outputText value="Galaxy Tab"/></td>
</tr>
<tr>
<td>Available. Quantity: <td><td><h:outputText value="300" /></td>
</tr>
<tr>
<td>Price: </td><td><h:outputText value="64,000" /></td>
</tr>
<tr>
<td>Discount: </td><td><h:outputText value="10,000" /></td>
</tr>
<tr>
<td>Amount: </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);
}
}
求你了,我真的需要帮助。
万岁!!感谢上帝,我找到了答案,我所要做的就是使用ajax来呈现表单,而不是panelGroup。
E.g
<h:form id="formval1">
<h:commandButton value="submit" action="#{managedBean}">
<f:ajax event="action" render="formval1"/>
</h:commandButton>
……所有其他东西。。。。。
感谢大家的帮助和关心,我很感激。