Hi,
I'm trying to use AjaxFormLoop inspired from
* http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/formloop1
*
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/AjaxFormLoop.html
but I have a big problem. My new pojos are not populated with their values.
Did I miss something ?
Can somebody help me ??
Thanks
Here's the java code :
public class MatchDetail extends BasePageEquipe {
@Property
private Match _match;
@Property
private Buteur _buteur;
@Property(read=false)
private List<Buteur> _listButeur;
public List<Buteur> getListButeur() {
if (_listButeur == null) {
_listButeur = _match.getListButeur();
}
return _listButeur;
}
@Inject
private ServiceDAO _dao;
@Property
private boolean _update = false;
public void onActivate(final Long idMatch) {
_match = _dao.getMatchDAO().get1N(idMatch);
if (_match == null) {
_match = new Match();
_match.setIdMatch(idMatch);
_match.setIdConvocation(idMatch);
}
}
public Long onPassivate() {
if (_match == null || _match.getIdMatch() == null) {
return 0L;
} else {
return _match.getIdMatch();
}
}
public void onSuccess() {
getWebUtilisateur();
try {
_dao.getMatchDAO().save(_match, _listButeur);
setOkMsg("Mise à jour OK");
} catch (Exception e) {
setErrorMsg(e.getMessage());
}
}
@Property
private SelectLicencieIdModel _licencieModel = new
SelectLicencieIdModel();
@Property
private MyButeurValueEncoder _buteurEncoder = new
MyButeurValueEncoder();
Object onAddRowFromButeurs() {
getWebUtilisateur();
Buteur buteur = new Buteur();
try {
Licencie licencie = _dao.getLicencieDAO().getFirstLicencie();
buteur.setIdMatch(_match.getIdMatch());
buteur.setIdLicencie(licencie.getIdLicencie());
_dao.getButeurDAO().save(buteur);
_listButeur.add(buteur);
} catch (Exception e) {
setErrorMsg(e.getMessage());
}
return buteur;
}
void onRemoveRowFromButeurs(Buteur buteur) {
getWebUtilisateur();
try {
_dao.getButeurDAO().delete(buteur.getIdButeur());
_listButeur.remove(buteur);
} catch (Exception e) {
setErrorMsg(e.getMessage());
}
}
private class MyButeurValueEncoder extends BaseValueEncoder<Buteur> {
public String toClient(Buteur buteur) {
Long id = buteur.getIdButeur();
return id == null ? null : id.toString();
}
public Buteur toValue(String value) {
Buteur buteur = null;
Long idButeur = LongUtil.toLong(value);
if (idButeur == null) {
buteur = new Buteur();
} else {
buteur = getButeurDAO().get(idButeur);
}
if (buteur == null) {
_logger.error(String.format("Probléme Buteur
introuvable id: [%s]", idButeur));
buteur = new Buteur();
}
return buteur;
}
private ButeurDAO getButeurDAO() {
return getDAO().getButeurDAO();
}
}
}
Here's the tml code :
<html t:type="equipelayout" title="literal:Détail Match"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
xmlns:p="tapestry:parameter">
<div class="pure-g-r">
<div class="pure-u-1">
<div class="content">
<t:if test="MsgNotEmpty">
<t:atlog.msg.DisplayInfo type="${MsgType}"
content="${msg}" duration="${duration}" />
</t:if>
<h1>Détail Match</h1>
<div class="pure-menu pure-menu-open pure-menu-horizontal">
<ul>
<li><t:pageLink page="convocation/message"
context="match.idConvocation" class="pure-button pure-button-active">
<t:atlog.img.Tango size="M"
src="actions/edit-find-replace.png" title="Edition" alt="Edition"
border="0" />
Retour à la convocation
</t:pageLink></li>
</ul>
</div>
<br />
<div class="t-beaneditor">
<t:form t:id="myMatch">
<t:beaneditor object="match" submitlabel="Mise à
jour" include="idMatch, equipeA, equipeB, resultat, note, titre,
compteRendu">
<p:idMatch>
<label>Id</label>
<t:if test="update">
<t:hidden value="match.idMatch" />
</t:if>
[${match.idMatch}]
</p:idMatch>
<p:compteRendu>
<t:textarea t:id="compteRendu"
t:mixins="tynamo/ckeditor" value="match.compteRendu" width="70%" />
</p:compteRendu>
</t:beaneditor>
<div t:type="ajaxformloop" t:id="buteurs"
source="listButeur" value="buteur" t:encoder="buteurEncoder" t:show="show">
${buteur.idButeur}
<t:submitnotifier>
<t:select value="buteur.idLicencie"
model="licencieModel" />
<t:textfield value="buteur.description" />
</t:submitnotifier>
|
<t:removerowlink>Suppression</t:removerowlink>
<p:addRow>
<t:addrowlink>Ajouter un buteur</t:addrowlink>
</p:addRow>
</div>
<input type="submit" value="Mise à jour" />
</t:form>
</div>
</div>
</div>
</div>
</html>
thanks, Thomas