我在這裏有很奇怪的情況,我不能設置字段,因爲輸入在客戶端,並且onSuccess
函數只有在我按下mixin中的確認後纔會調用。不能退縮,不能前進。掛毯確認對話
我按確認,我打開確認對話框。但是因爲這裏的值尚未設置(他們正在等待「確認」對話框中的提交),所以我將這些值設置爲空值和零值。你能否告訴我如何擺脫這種情況?此外,我還擔心的是,一旦我處於對話模式,我無法點擊確認按鈕,我不知道爲什麼。
感謝您的幫助。
<t:layout t:pageTitle='${message:AddTickets}' xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd">
<t:jquery.jgrowl />
<form t:type="form" t:id="dodajTiket">
<t:zone t:id="zonaDjelovanja" id="zonaDjelovanja">
<t:errors/>
<div class="palette palette-concrete" style="height:80%;">
<div class="col-xs-12" style="margin-left:17px;">
<h5>${message:selectTypeOfTicket}</h5>
<t:select t:id="drawTip" style="color:black;" validate="required" t:event="OsvjeziZonu" zone="zonaDjelovanja" />
</div>
<!-- fecha del sorteo -->
<div class="col-xs-12">
<div class="col-xs-3">
<t:label for="datum"><h6>${message:datum}</h6></t:label>
<t:datefield id="uzmiDatum" validate="required" class="form-control" t:id="datum"/>
</div>
<!-- no de fracciones -->
<div class="col-xs-3">
<div class="post-box"><label><h6>${message:numberOfTickets}</h6></label>
<input class="form-control" validate="required" t:type="TextField" t:id="brojTiketa" t:value="brojTiketa"/></div>
</div>
</div>
<div class="col-xs-12">
<div class="col-xs-3">
<div class="post-box"><label><h6>${message:number}</h6></label>
<input class="form-control" id="uzmiBroj" validate="required" t:type="TextField" t:id="broj"/></div>
</div>
<div class="col-xs-3">
<div class="post-box"><label><h6>${message:serial}</h6></label>
<input class="form-control" validate="required" t:type="TextField" t:id="series" t:value="series" /></div>
</div>
<div class="col-xs-3">
<div class="post-box"><label><h6>${message:price}</h6></label>
<input class="form-control" t:type="TextField" t:id="cijena" t:value="cijena"/></div>
</div>
</div>
<div class="col-xs-12">
<br></br>
<br></br>
<div class="col-xs-3">
<!--
<t:submit value="Confirmar" t:event="dodajTiket" class="form-control" t:height="300" t:message="¿Seguro que desea crear esta entrada? ${kopijaBroj}" t:mixins="confirm"/>
-->
<t:zone t:id="zonaUploadovanja" id="zonaDjelovanja">
<div t:type="jquery/dialog" t:zone="zonaDjelovanja" t:clientId="modal-example" class="k-modal" t:params="params">
<div class="content">
<p>¿Seguro que desea crear esta entrada?
</p>
${brojTiketa}
<!--
<script> document.getElementById('izmiBroj').value</script>-->
<p style="color:red; font-size: 25px;">6</p>
</div>
<t:submit t:event="OsvjeziZonu" value="Confirmar" class="form-control" />
</div>
</t:zone>
</div>
</div>
</div>
</t:zone>
</form>
<t:jquery.dialoglink t:dialog="modal-example" class="k-modal-trigger">Open</t:jquery.dialoglink>
</t:layout>
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package rs.domaci.pages;
import org.apache.commons.lang.StringUtils;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.EventConstants;
import org.apache.tapestry5.PersistenceConstants;
import org.apache.tapestry5.alerts.AlertManager;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.hibernate.annotations.CommitAfter;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.ComponentSource;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.ajax.AjaxResponseRenderer;
import org.hibernate.Session;
import rs.domaci.entities.Tiket;
import rs.domaci.entities.TiketStatus;
import rs.domaci.entities.TipDrawTiketa;
/**
* This page is for generating tickets!
*
* @author
*/
public class AddTickets {
@Property
private String drawNumberOfTicket;
@Inject
private Session hibernate;
@Property
private int series;
@Property
@Persist(PersistenceConstants.CLIENT)
private String datum;
@Inject
private ComponentSource componentSource;
@Property
// price
private int cijena;
@Property
@Persist
private String kopijaDatum;
@Property
@Persist
private int kopijaBroj;
/**
* @Property private
*/
@Property
@Persist(PersistenceConstants.CLIENT)
private int broj;
@Property
@Persist(PersistenceConstants.FLASH)
private int brojTiketa;
@Property
private TiketStatus status = TiketStatus.DISPONIBLE;
@InjectComponent
private Zone zonaDjelovanja;
@Inject
private Request request;
@Inject
private AjaxResponseRenderer ajaxResponseRenderer;
@Inject
private ComponentResources componentResources;
@Property
@Persist(PersistenceConstants.FLASH)
private TipDrawTiketa drawTip;
@Inject
private AlertManager manager;
@Component(id = "dodajTiket")
private Form form;
// Generally useful bits and pieces
void setupRender() {
datum = null;
updateDisplay(drawTip);
}
// public TipDrawTiketa getNAVIDENA() {
// brojTiketa = 20;
// return TipDrawTiketa.NAVIDENA;
// }
//
// public TipDrawTiketa getCHANCES() {
// brojTiketa = 10;
// return TipDrawTiketa.CHANCES;
// }
//
// public TipDrawTiketa getLOTERIANACIONAL() {
// brojTiketa = 20;
// return TipDrawTiketa.LOT_NAC;
// }
public String getFormatirajMe() {
String prviDio = String.format("%03d", series);
String drugiDio = String.format("%02d", broj);
return prviDio + drugiDio;
}
public Object getOsvjeziZonu() {
if (drawTip == drawTip.LOT_NAC) {
brojTiketa = 20;
return zonaDjelovanja.getBody();
} else if (drawTip == drawTip.CHANCES) {
brojTiketa = 10;
return zonaDjelovanja.getBody();
} else if (drawTip == drawTip.NAVIDENA) {
brojTiketa = 10;
return zonaDjelovanja.getBody();
} else {
brojTiketa = 10;
return zonaDjelovanja.getBody();
}
}
@OnEvent(value = EventConstants.VALUE_CHANGED, component = "drawTip")
public Object updateDisplay(TipDrawTiketa tipDrawTiketaa) {
drawTip = tipDrawTiketaa;
if (drawTip == TipDrawTiketa.LOT_NAC) {
brojTiketa = 20;
return zonaDjelovanja.getBody();
} else if (drawTip == TipDrawTiketa.CHANCES) {
brojTiketa = 10;
return zonaDjelovanja.getBody();
} else if (drawTip == TipDrawTiketa.NAVIDENA) {
brojTiketa = 20;
return zonaDjelovanja.getBody();
} else {
brojTiketa = 20;
return zonaDjelovanja.getBody();
}
}
/**
*
* @return
*/
@CommitAfter
@OnEvent(value = "submit", component = "dodajTiket")
void onDodajTiket() {
for (int i = 0; i < brojTiketa; i++) {
hibernate.save(new Tiket(StringUtils.leftPad(String.valueOf(series + "" + broj), 5, ""), datum, drawTip, String.format("%03d", series), String.format("%02d", broj), status, cijena));
}
String redom = "Created ticket sheet serial " + series + "\n" + " number " + broj;
//manager.alert(Duration.UNTIL_DISMISSED, Severity.INFO, redom);
componentResources.discardPersistentFieldChanges();
}
@Property
private JSONObject params;
@OnEvent(EventConstants.ACTIVATE)
public void onActivate() {
params = new JSONObject();
params.accumulate("modal", true);
}
}
在這個形象,我曾嘗試使用參數從現場Cantidad德Fracciones這是一個區域內,當頁面加載它只會工作,cantidad de fracciones的值也會在對話框中更改,但這不是因爲AJAX,我認爲它可以從頁面加載中獲取Cantidad de Fracciones的值,並且在該頁面停留期間無法更改,這不是什麼我想要。當我改變字段Cantidad de Fracciones內的輸入時,我希望更新對話框中Cantidad de Fracciones的值。
UPDATE:
因爲它是所有客戶端的東西,我選擇使用jQuery方法,因爲在蘭斯Java的回答表明,聽在某領域的文本改變。
<script>
$("input")
.keyup(function() {
var value = $(broj).val();
$("#provjeraBroj").text(value);
var value = $(datum).val();
$("#provjeraDatum").text(value);
//var value = $(drawTip).val();
$('#drawTip').change(function() {
var $selected = $(this).find('option:selected');
if ($selected.val() === 'LOT_NAC') {
$("#provjeraDrawTip").text("Loteri");
}
if ($selected.val() === 'CHANCES') {
$("#provjeraDrawTip").text("Chances");
}
else {
$("#provjeraDrawTip").text("Navideña");
}
}).change();
var value = $(series).val();
$("#provjeraSeries").text(value);
var value = $(brojTiketa).val();
$("#provjeraBrojTiketa").text(value);
})
.keyup();
</script>
你的「更新」確實應該是第二個答案。 – 2014-10-20 02:18:29