Author: fdesbois Date: 2010-05-14 17:12:25 +0200 (Fri, 14 May 2010) New Revision: 2999 Url: http://chorem.org/repositories/revision/pollen/2999 Log: Create component subForm to refresh zone inside a form. Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.java trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/SubForm.tml Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java trunk/pollen-ui/src/main/webapp/poll/PollForm.tml Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.java (rev 0) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.java 2010-05-14 15:12:25 UTC (rev 2999) @@ -0,0 +1,30 @@ +package org.chorem.pollen.ui.components; + +import org.apache.tapestry5.Block; +import org.apache.tapestry5.annotations.Parameter; +import org.apache.tapestry5.ioc.annotations.Inject; + +/** + * Created: 14 mai 2010 + * + * @author fdesbois <fdesbois@codelutin.com> + * @version $Id$ + */ +public class SubForm { + + @Parameter + private boolean visible; + + @Inject + private Block formBlock; + + @Inject + private Block noFormBlock; + + public Block getActiveBlock() { + if (visible) { + return noFormBlock; + } + return formBlock; + } +} Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/components/SubForm.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-14 14:23:00 UTC (rev 2998) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/ui/pages/poll/PollForm.java 2010-05-14 15:12:25 UTC (rev 2999) @@ -411,15 +411,16 @@ @Inject private ComponentResources resources; + @Property private boolean flag; - @Inject - private Block listsForm; +// @Inject +// private Block listsForm; +// +// @Inject +// @Property +// private Block listsFields; - @Inject - @Property - private Block listsFields; - public Map<String, ParticipantList> getLists() { if (lists == null) { lists = new HashMap<String, ParticipantList>(); @@ -446,16 +447,16 @@ return listsZone.getBody(); } - @Log - public Block getListsBlock() throws PollenBusinessException { - if (canDisplayLists()) { - if (flag) { - return listsFields; - } - return listsForm; - } - return null; - } +// @Log +// public Block getListsBlock() throws PollenBusinessException { +// if (canDisplayLists()) { +// if (flag) { +// return listsFields; +// } +// return listsForm; +// } +// return null; +// } @Log void onSelectedFromAddList() { Added: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/SubForm.tml =================================================================== --- trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/SubForm.tml (rev 0) +++ trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/SubForm.tml 2010-05-14 15:12:25 UTC (rev 2999) @@ -0,0 +1,14 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter"> + + <t:delegate t:to="activeBlock" /> + <t:block t:id="formBlock"> + <form t:type="form" action="tapestry"> + <t:body /> + </form> + </t:block> + <t:block t:id="noFormBlock"> + <t:body /> + </t:block> + +</html> \ No newline at end of file Property changes on: trunk/pollen-ui/src/main/resources/org/chorem/pollen/ui/components/SubForm.tml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/pollen-ui/src/main/webapp/poll/PollForm.tml =================================================================== --- trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-05-14 14:23:00 UTC (rev 2998) +++ trunk/pollen-ui/src/main/webapp/poll/PollForm.tml 2010-05-14 15:12:25 UTC (rev 2999) @@ -213,29 +213,48 @@ </span> </legend> <div t:type="zone" id="p-pollForm-lists-zone" t:id="listsZone" class="form-block"> - <t:delegate t:to="listsBlock" /> - <t:block t:id="listsForm"> - <form t:type="form" action="tapestry"> - <t:delegate t:to="listsFields" /> - </form> - </t:block> - <t:block t:id="listsFields"> - <t:if t:test="poll.pollType.group"> - <p> - <label t:type="label" t:for="listName" />: - <input t:type="textfield" t:id="listName" value="listName"/> - <input t:type="submit" t:id="addList" value="ADD"/> - </p> - <p> - <t:loop t:source="lists.values()" t:value="list" t:volatile="true"> - ${list.name} - </t:loop> - </p> - <p:else> - COOL - </p:else> - </t:if> - </t:block> + <t:if t:test="canDisplayLists()"> + <t:subForm t:visible="flag"> + <t:if t:test="poll.pollType.group"> + <p> + <label t:type="label" t:for="listName" />: + <input t:type="textfield" t:id="listName" value="listName"/> + <input t:type="submit" t:id="addList" value="ADD"/> + </p> + <p> + <t:loop t:source="lists.values()" t:value="list" t:volatile="true"> + ${list.name} + </t:loop> + </p> + <p:else> + COOL + </p:else> + </t:if> + </t:subForm> + </t:if> + <!--<t:delegate t:to="listsBlock" />--> + <!--<t:block t:id="listsForm">--> + <!--<form t:type="form" action="tapestry">--> + <!--<t:delegate t:to="listsFields" />--> + <!--</form>--> + <!--</t:block>--> + <!--<t:block t:id="listsFields">--> + <!--<t:if t:test="poll.pollType.group">--> + <!--<p>--> + <!--<label t:type="label" t:for="listName" />: --> + <!--<input t:type="textfield" t:id="listName" value="listName"/> --> + <!--<input t:type="submit" t:id="addList" value="ADD"/>--> + <!--</p>--> + <!--<p>--> + <!--<t:loop t:source="lists.values()" t:value="list" t:volatile="true">--> + <!--${list.name} --> + <!--</t:loop>--> + <!--</p>--> + <!--<p:else>--> + <!--COOL--> + <!--</p:else>--> + <!--</t:if>--> + <!--</t:block> --> </div> </fieldset> </div>