tml file
<html t:type="layout" title="${message:title}"
      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd";
      xmlns:p="tapestry:parameter">
    <!-- Most of the page content, including <head>, <body>, etc. tags,
comes from Layout.tml -->


    <!-- A Zone is a component that can be updated in place, triggered by
other components. -->
    <t:navbar/>
    <t:finances/>
    <t:if t:test="clientExists">
        <t:delegate to="block:addExpenseBlock"/>
        <t:delegate to="block:currencySelectBlock"/>
        <t:delegate to="block:myExpenseListBlock"/>
        <t:delegate to="block:trustedExpenseListBlock"/>
        <t:if t:test="admin">
            <t:delegate to="block:fullExpenseListBlock"/>
        </t:if>
    </t:if>
    <t:block id="addExpenseBlock">
        <t:zone t:id="addExpenseZone">
            <t:form t:id="addExpenseForm">
                <table  border="0">
                    <thead>
                        <tr>
                            <th colspan="2">
                                Add new expense form
                    <hr/>
                    </th>
                    </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>
                    <t:label for="recepient"/>(*):
                    </td>
                    <td>
                        <input t:type="TextField" t:id="recepient"
value="recepientValue"/>
                    </td>
                    </tr>
                    <tr>
                        <td>

                    <t:label for="purposeOfPayment"/>(*):
                    </td>
                    <td>
                        <input t:type="TextField" t:id="purposeOfPayment"
value="purposeOfPaymentValue"/>
                    </td>
                    </tr>
                    <tr>                    <td>
                    <t:label for="currency"/>(*):
                    </td>
                    <td>
                        <input t:type="TextField" t:id="currency"
value="currencyValue"/>
                    </td>
                    </tr>
                    <tr>
                        <td>
                    <t:label for="amount"/>(*):
                    </td>
                    <td>
                        <input  type="number" step="any"
 t:type="TextField" t:id="amount" value="amountValue"/>
                    </td>
                    </tr>
                    <tr>
                        <td>
                    <t:label for="renew"/>:
                    </td>
                    <td>
                    <t:checkbox t:id="renew"
                                t:mixins="triggerfragment" fragment="f1"/>
                    </td>
                    </tr>
                    <t:formfragment t:id="f1" visible="renew" hide="fade">
                        <tr>
                            <td colspan="2">
                                Calculate payment from
                            </td>
                        </tr>
                        <tr>
                            <td>
                        <t:label for="dateOfPayment"/>(*):
                        </td>
                        <td>
                            <input type="date"  t:type="TextField"
t:id="dateOfPayment" value="dateOfPaymentValue" />
                        </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                Repeat payment every
                            </td>
                        </tr>
                        <tr>
                            <td>
                        <t:label for="number"/>(*):
                        </td>
                        <td>
                            <input type="number" t:type="TextField"
t:id="number"  value="numberValue"/>
                        </td>
                        </tr>
                        <tr>
                            <td>
                        <t:label for="timeUnit"/>(*):
                        </td>
                        <td>
                            <select t:type="Select" t:id="timeUnit"
t:model="literal:day,week,month,year" t:value="timeUnitValue"/>
                        </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                Calculate payment until
                            </td>
                        </tr>
                        <tr>
                            <td>
                        <t:label for="endDate"/>(*):
                        </td>
                        <td>
                            <input type="date"  t:type="TextField"
t:id="endDate" value="endDateValue" />
                        </td>
                        </tr>
                    </t:formfragment>
                    <tr>
                        <td>
                            <input t:type="Submit" t:id="add" value="Add
expense"/>
                        </td>
                        <td>
                            <input type="reset" value="Reset" />
                        </td>
                    </tr>
                    </tbody>
                </table>
                <t:errors/>
            </t:form>
        </t:zone>
    </t:block>

    <t:block id="currencySelectBlock">
        <t:zone t:id="currencySelectZone">
            <t:form t:id="currencySelectForm">
                <table  border="0">
                    <thead>
                        <tr>
                            <th colspan="2">
                                Select currency form
                    <hr/>
                    </th>
                    </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>
                    <t:label for="tableCurrency"/>(*):
                    </td>
                    <td>
                        <input t:type="TextField" t:id="tableCurrency"
value="tableCurrencyValue"/>
                    </td>
                    </tr>
                    <tr>
                        <td>
                            <input t:type="Submit" t:id="selectCurrency"
value="Select Currency"/>
                        </td>
                        <td>
                            <input type="reset" value="Reset" />
                        </td>
                    </tr>
                    </tbody>
                </table>
                <t:errors/>
            </t:form>
        </t:zone>
    </t:block>
    <t:block id="myExpenseListBlock">
        <t:zone t:id="myExpenseListZone">
            <p>
                List of your expenses
            </p>
            <hr/>
            <table t:type="grid" t:source="myExpenseList"
                   t:row="gridLine"
                   t:rowsPerPage="10" t:pagerPosition="both"

 t:exclude="moneyId,moneyIO,moneyNextDate,moneyFinishDate,moneyTs,cliClientId"

 t:reorder="moneyName,moneyPurpose,moneyAmount,moneyCurrency,moneyDate"
add="removeExpense">
                [Grid here]
                <p:removeExpenseCell>
                    <t:actionlink t:id="myExpenseRemove"
t:context="gridLine?.moneyName" >remove payment</t:actionlink>
                </p:removeExpenseCell>
            </table>
        </t:zone>
    </t:block>
    <t:block id="trustedExpenseListBlock">
        <t:zone t:id="trustedExpenseListZone">
            <p>
                List of expenses from trusted
            </p>
            <hr/>
            <!--            <table t:type="grid"
t:source="trustedExpenseList"
                               t:row="gridLine"
                               t:rowsPerPage="10" t:pagerPosition="both"

 t:exclude="moneyId,moneyIO,moneyNextDate,moneyFinishDate"

 
t:reorder="moneyName,moneyPurpose,moneyAmount,moneyCurrency,moneyDateCalendar,moneyNumber,moneyRenewal,cliClientId?.clientUsername">
                            [Grid here]
                        </table>-->
        </t:zone>
    </t:block>

    <t:block id="fullExpenseListBlock">
        <t:zone t:id="fullExpenseListZone">
            <p>
                List of all clients in your home
            </p>
            <hr/>
            <!--            <table t:type="grid" t:source="fullExpenseList"
                               t:row="gridLine"
                               t:rowsPerPage="5" t:pagerPosition="both"

 t:exclude="mmoneyId,moneyIO,moneyNextDate,moneyFinishDate"

 
t:reorder="moneyName,moneyPurpose,moneyAmount,moneyCurrency,moneyDate,moneyNumber,moneyRenewal,cliClientId?.clientUsername">
                            [Grid here]
                        </table>-->
        </t:zone>
    </t:block>
</html>
Page class

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rs.edu.fit.cs230web.pages;

import java.util.List;
import logic.ws.Client;
import logic.ws.ClientType;
import logic.ws.ClientWebService;
import logic.ws.ExpenseWebService;
import logic.ws.Money;
import org.apache.tapestry5.PersistenceConstants;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.beaneditor.Validate;
import org.apache.tapestry5.ioc.annotations.Inject;

/**
 *
 * @author nikola
 */
public class Expenses {

    @SessionState
    @Property
    private Client client;
    @Property
    private boolean clientExists;
    @Persist(PersistenceConstants.FLASH)
    private Boolean admin;
    @Inject
    private ClientWebService clientWebService;
    @Inject
    private ExpenseWebService expenseWebService;
    @Property
    private Money gridLine;
    @Persist
    @Property
    private List<Money> myExpenseList;
    @Persist
    @Property
    private List<Money> trustedExpenseList;
    @Persist
    @Property
    private List<Money> fullExpenseList;
    @Property
    @Persist(PersistenceConstants.FLASH)
    @Validate("required")
    private String recepientValue;
    @Property
    @Persist(PersistenceConstants.FLASH)
    @Validate("required")
    private String purposeOfPaymentValue;
    @Property
    @Persist(PersistenceConstants.FLASH)
    @Validate("required")
    private String currencyValue;
    @Property
    @Persist(PersistenceConstants.FLASH)
    @Validate("required")
    private Double amountValue;
    @Property
    @Persist(PersistenceConstants.FLASH)
    private String dateOfPaymentValue;
    @Property
    @Persist(PersistenceConstants.FLASH)
    private Integer numberValue;
    @Property
    @Persist(PersistenceConstants.FLASH)
    private String timeUnitValue;
    @Property
    @Persist(PersistenceConstants.FLASH)
    private String endDateValue;
    @Persist
    @Property
    private boolean renew;
    @Property
    @Persist
    private String tableCurrencyValue;

    void onPrepareForRender() {
        myExpenseList =
expenseWebService.findMyExpenses(client.getClientUsername(),
tableCurrencyValue);
        trustedExpenseList =
expenseWebService.findFriendsExpenses(client.getClientUsername(),
tableCurrencyValue);
        fullExpenseList =
expenseWebService.findHomeExpenses(client.getClientUsername(),
tableCurrencyValue);

    }

    public Boolean getAdmin() {
        if (clientExists) {
            if (client.getClientType().equals(ClientType.ADMIN)) {
                return Boolean.TRUE;
            }
        }
        return Boolean.FALSE;
    }

    Object onActionFromMyExpenseRemove(String name) {
        expenseWebService.destroyExpense(name, tableCurrencyValue,
client.getClientUsername());
        return null;
    }

    void onValidateFromAddExpenseForm() {
    }

    Object onSuccessFromAddExpenseForm() {
        tableCurrencyValue = currencyValue;
        if (renew == Boolean.FALSE) {
            Money makeExpenseOnce =
expenseWebService.makeExpenseOnce(recepientValue, purposeOfPaymentValue,
client.getClientUsername(), amountValue, currencyValue);
        } else {
            if (timeUnitValue.equalsIgnoreCase("day")) {
                Money makeExpenseDay =
expenseWebService.makeExpenseDay(recepientValue, purposeOfPaymentValue,
client.getClientUsername(), amountValue, currencyValue, dateOfPaymentValue,
endDateValue, numberValue);
            } else if (timeUnitValue.equalsIgnoreCase("week")) {
                Money makeExpenseWeek =
expenseWebService.makeExpenseWeek(recepientValue, purposeOfPaymentValue,
client.getClientUsername(), amountValue, currencyValue, dateOfPaymentValue,
endDateValue, numberValue);
            } else if (timeUnitValue.equalsIgnoreCase("month")) {
                Money makeExpenseMonth =
expenseWebService.makeExpenseMonth(recepientValue, purposeOfPaymentValue,
client.getClientUsername(), amountValue, currencyValue, dateOfPaymentValue,
endDateValue, numberValue);
            } else if (timeUnitValue.equalsIgnoreCase("year")) {
                Money makeExpenseYear =
expenseWebService.makeExpenseYear(recepientValue, purposeOfPaymentValue,
client.getClientUsername(), amountValue, currencyValue, dateOfPaymentValue,
endDateValue, numberValue);
            }
        }
        return null;
    }
}


On Sun, May 19, 2013 at 4:17 PM, Nikola Vulovic <nivuk...@gmail.com> wrote:

> [image: Inline image 1]
> Code is provided attachments
> Some please tell me why is FormFragment displaying
>
> --
> nkv1
>



-- 
Pozdrav Nikola Vulovic

Reply via email to