h: данные inputText кэшируются
Нажмите "LINK1" -> модальное всплывающее окно -> введите значение в текстовом поле -> нажмите "Отправить / обработать"
Нажмите другую ссылку "обновить / отменить" -> то же самое модальное всплывающее окно -> я вижу значение в текстовом поле (Это нормально, и если я перезагрузлю страницу и снова нажму на ссылку, модальное окно появится с неизмененными значениями)
Нажмите "LINK1" -> то же самое модальное всплывающее окно -> я вижу значение в текстовом поле в кеше (на этот раз я хочу, чтобы значения не кэшировались в текстовом поле) -> Если я перезагружаю страницу, значения идут прочь хотя.
Я пытался очистить бэк-бин при щелчке по ссылкам, но все равно отображаются значения. Пожалуйста, порекомендуйте.
Обновите здесь код:
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"
,
2 ответа
Вот что я попробовал, чтобы получилось.
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;
}
}
Я думаю, что вы должны добавить в reRender вашего a4j:commandLink идентификатор текстового поля, которое вы хотите обновить, то есть "reimbursementAmount":
<a4j:commandLink
action="#reimbursementAction.initNewReimbursement(payment)}"
reRender="reimbursePaymentPanel,reimbursePaymentDiv,**reimbursementAmount**"
limitToList="true">
<span>Reimburse</span>
</a4j:commandLink>
Если это не сработало, попробуйте включить modalPanel на той же странице, что и "PaymentList.xhtml".
НТН.