点击“LINK1” - > modal popsup - >在文本框中输入值 - >单击“提交/处理”
点击另一个链接“更新/取消” - >相同的模态弹出 - >我在文本框中看到了这个值(这很好,如果我重新加载页面并再次点击链接,则模态显示的值保持不变)
点击“LINK1” - >相同的模态弹出 - >我看到文本框中的值被缓存(这次我希望值不在文本框中缓存) - >如果我重新加载页面,值会消失。
我已经尝试在单击链接时清除backing-bean,但仍会显示值。请指教。
更新这里是代码:
ReimbursementActionBean.java
@Name("reimbursementAction")
@Scope(ScopeType.CONVERSATION)
public class ReimbursementActionBean implements Serializable {
public void initReimbursement(PaymentInfo payment) {
// do something
}
public void initNewReimbursement(PaymentInfo payment) {
initReimbursement(payment);
// --> log.info("CLEARING INPUT ELEMENT CACHE");
// -->this.getReimbursement().setAmount(null);
hideModal = false;
}
public void initUpdateReimbursement(PaymentInfo payment) {
initReimbursement(payment);
hideModal = false;
}
public void initCancelReimbursement(PaymentInfo payment) {
initReimbursement(payment);
hideModal = true;
}
public void reimbursePayment() {
// do something
}
public void updateReimbursment() {
// do something
}
public void cancelReimbursment() {
// do something
}
public void cancelupdateReimbursment() {
hideModal = true;
}
public Reimbursement getReimbursement() {
return reimbursement;
}
public void setReimbursement(Reimbursement reimbursement) {
this.reimbursement = reimbursement;
}
}
reimbursePaymentModal.xhtml
< rich:modalPanel id="reimbursePaymentPanel"
width="430"
autosized="true"
showWhenRendered="#{!hideModal}">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="Reimburse Payment"/>
</h:panelGroup>
</f:facet>
<h:form>
<a4j:outputPanel id="reimbursePaymentDiv">
<s:div styleClass="section" style="padding:5px;padding-left:0px;">
<s:decorate template="/layout/edit.xhtml">
<ui:define name="label">Reimbursement Amount(*)</ui:define>
<h:inputText id="reimbursementAmount"
value="#{reimbursementAction.reimbursement.amount}">
<a4j:support event="onblur" rerender="reimbursementAmount" action="#{reimbursementAction.validateAmount}" limitToList="true" />
</h:inputText>
</s:decorate>
<div style="clear:both"></div>
</s:div>
<div class="button-holder" style="padding-top:10px">
<div style="float:right">
<a4j:commandLink oncomplete="Richfaces.hideModalPanel('reimbursePaymentPanel');"
immediate="true"
action="#{reimbursementAction.cancelupdateReimbursment()}"
styleClass="button"
reRender="reimbursePaymentPanel">
<!--todo add cancel command to reimbursementAction-->
<span class="inner-button">Cancel</span>
</a4j:commandLink>
</div>
<div style="float:right">
<a4j:commandLink id="reimbursePaymentId" styleClass="button"
oncomplete="this.disabled=false;"
action="#{reimbursementAction.reimbursePayment}"
rendered="#{reimbursementAction.reimbursementConstraints.allowableReimbursementAction eq 'SUBMIT_NEW'}"
reRender="paymentSearchResults,reimbursePaymentDiv,reimbursePaymentPanel,pnlInfoView" limitToList="true"
bypassUpdates="true" onclick="this.disabled=true;">
<span class="inner-button">Process</span>
</a4j:commandLink>
</div>
</div>
</a4j:outputPanel>
</h:form>
</rich:modalPanel>
PaymentList.xhtml
< a4j:outputPanel id="paymentSearchResults" ajaxRendered="true">
<s:div styleClass="section" style="overflow-y:scroll; overflow-x:hidden;max-height:420px;margin:10px "
rendered="#{not empty paymentList}">
<rich:dataTable id="paymentListId"
var="payment"
value="#{paymentList}"
styleClass="data-table"
rowClasses="odd,even"
width="100%">
<!-- Reimburse -->
<s:div rendered="#{payment.reimbursementSummary.allowableReimbursementActionType eq 'SUBMIT_NEW'}">
<a4j:commandLink action="#{reimbursementAction.initNewReimbursement(payment)}"
reRender="reimbursePaymentPanel,reimbursePaymentDiv"
limitToList="true">
<span> Reimburse</span>
</a4j:commandLink>
</s:div>
<!-- Update Reimburse and Cancel Reimbursement-->
<s:div rendered="#{payment.reimbursementSummary.allowableReimbursementActionType eq 'MODIFY_EXISTING'}">
<a4j:commandLink action="#{reimbursementAction.initUpdateReimbursement(payment)}"
reRender="reimbursePaymentPanel,reimbursePaymentDiv"
limitToList="true"
bypassUpdates="true">
<span>Update Reimbursement</span>
</a4j:commandLink>
<h:outputText value=" | "/>
<a4j:commandLink oncomplete="Richfaces.showModalPanel('cancelReimbursementPanel');"
action="#{reimbursementAction.initCancelReimbursement(payment)}"
reRender="cancelReimbursementDiv"
limitToList="true">
<span>Cancel Reimbursement</span>
</a4j:commandLink>
</s:div>
</div>
</rich:column>
</rich:dataTable>
</s:div>
</a4j:outputPanel>
我所说的链接是:Reimburse
和Update Reimbursement
。点击链接重新呈现reimbursePaymentPanel
,使用id=reimbursePaymentPanel
文本框id="reimbursementAmount"
打开模式。
答案 0 :(得分:0)
我认为你应该在你的a4j:commandLink的reRender中添加你要更新的文本框的id,即“reimbursementAmount”:
<a4j:commandLink
action="#reimbursementAction.initNewReimbursement(payment)}"
reRender="reimbursePaymentPanel,reimbursePaymentDiv,**reimbursementAmount**"
limitToList="true">
<span>Reimburse</span>
</a4j:commandLink>
如果这不起作用,请尝试将modalPanel包含在同一页面上,即“PaymentList.xhtml”。
HTH。
答案 1 :(得分:0)
这是我尝试过的。
<s:decorate template="/layout/edit.xhtml">
<ui:define name="label">Reimbursement Amount(*)</ui:define>
<h:inputText id="reimbursementAmount"
binding="#{reimburseEvent.amountText}"
value="#{reimbursementAction.reimbursement.amount}">
<a4j:support event="onblur" action="#{reimbursementAction.validateAmount}"
limitToList="true"/>
</h:inputText>
</s:decorate>
<s:div rendered="#{payment.reimbursementSummary.allowableReimbursementActionType eq 'SUBMIT_NEW'}">
<a4j:commandLink action="#{reimbursementAction.initNewReimbursement(payment)}"
reRender="reimbursePaymentPanel,reimbursePaymentDiv, reimbursementAmount"
actionListener="#{reimbursementAction.clearForm}" immediate="true" limitToList="true"
>
<span> Reimburse</span>
</a4j:commandLink>
</s:div>
@In(required=false)
private ReimburseEvent reimburseEvent;
//Added
public void clearForm(ActionEvent event){
if(reimbursement!=null){
reimbursement.setAmount(null);
getReimbursement().setAmount(null);
}
reimburseEvent.getAmountText().setSubmittedValue("");
}
@Name("reimburseEvent")
@Scope(ScopeType.EVENT)
@AutoCreate
public class ReimburseEvent {
// amountText is binding attribute in the reimbursementPaymentModal. Binding attributes cannot be used in ReimbursementActionBean (Since it is Conversation Scope).
// So creating ReimburseEvent (Event scope) to support the binding attribute and injecting it to ReimbursementActionBean.
private UIInput amountText;
public void setAmountText(UIInput amountText) {
this.amountText = amountText;
}
public UIInput getAmountText() {
return amountText;
}
}