h:inputText data cached
Click "LINK1" --> modal popsup --> enter value in text-box --> click Submit/Process
Click another link "update/cancel" --> same modal popsup --> I see the value in the text box (This is fine and if I reload the page and click the link again, the modal appears with values intact)
Click "LINK1" --> same modal popsup --> I see the value in the text box cached(this time I want the values not to be cached in the text box) --> If I reload the page, the values go away though.
I have tried clearing the backing-bean when the links are clicked, but still the values appear. Please advise.
Update here is the code:
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>
The links I am talking about are: Reimburse
and Update Reimbursement
. Clicking on the links rerender reimbursePaymentPanel
which open up the modal with id=reimbursePaymentPanel
having textbox with id="reimbursementAmount"
.
I think you should add in the reRender of your a4j:commandLink the id of the text box that you wanna update, which is "reimbursementAmount":
<a4j:commandLink
action="#reimbursementAction.initNewReimbursement(payment)}"
reRender="reimbursePaymentPanel,reimbursePaymentDiv,**reimbursementAmount**"
limitToList="true">
<span>Reimburse</span>
</a4j:commandLink>
If this didn't work, try to include the modalPanel on the same page, which is "PaymentList.xhtml".
HTH.
Here is what I tried that worked.
reimbursePaymentModal.xhtml
<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>
PaymentList.xhtml
<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>
ReimbursementActionBean.java
@In(required=false)
private ReimburseEvent reimburseEvent;
//Added
public void clearForm(ActionEvent event){
if(reimbursement!=null){
reimbursement.setAmount(null);
getReimbursement().setAmount(null);
}
reimburseEvent.getAmountText().setSubmittedValue("");
}
ReimburseEvent.java
@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;
}
}
精彩评论