我試圖通過commandlink在ajax請求後顯示錶單中的字段。但是,當我單擊鏈接時,出現malformedXML錯誤。在XHTML文件看起來像:JSF 2.0,在命令鏈接上使用ajax時出現malformedXML
<h:form>
.
.
<tr>
<td>Product Image*:</td>
<td>
<h:graphicImage url="#{addItem.prodFileName}" width="100" height="100"/>
<br /><h:commandLink value="change image" >
<f:ajax event="click" render="uploadimage" execute="@this" listener="#{addItem.ChangeImage}"/>
</h:commandLink>
</td>
</tr>
<tr >
<td>
<t:inputFileUpload rendered ="#{addItem.editImgChange}" label="editImage" id="uploadimage" value="#{addItem.uploadedFile}" />
<h:messages for="prodimage"/>
</td>
</tr>
.
.
</h:form>
如addItem bean是RequestScoped,它具有的代碼以下行:用戶點擊後才inputFileUpload領域:
@ManagedBean
public class AddItem extends AbstractBean {
//..
boolean editImgChange=false;
//...
public void ChangeImage(){
this.editImgChange=true;
}
}
Inshort,我想顯示的T改變圖像鏈接。我在初始值爲false的AddItem bean中保留了一個標誌editImgChange,並且一旦用戶單擊更改圖像鏈接,該標誌將更改爲true。該程序進入ChangeImage()方法,但在那之後我得到的錯誤
「malformedXML:在更新:j_idt30:uploadimage找不到」
。
我會很高興與一個完全不同的解決方案,以達到相同的結果,因爲我的設計是不好的。