Package org.apache.click.examples.domain

Examples of org.apache.click.examples.domain.Customer


        return true;
    }

    public boolean onAddClick() {
        if (customerForm.isValid()) {
            Customer customer = new Customer();
            customerForm.copyTo(customer);
            customerService.saveCustomer(customer);

            // The FormTable customer was set in the onInit phase. Since we just
            // added a new customer we refresh the FormTable row list
View Full Code Here


        int rowIndex = 4;

        List<Customer> customers = customerService.getCustomers();
        for (int i = 0; i < customers.size(); i++) {
            Customer customer = (Customer) customers.get(i);

            row = worksheet.createRow((short) rowIndex++);

            row.createCell((short) 0).setCellValue(new HSSFRichTextString(customer.getName()));
            row.createCell((short) 1).setCellValue(new HSSFRichTextString(customer.getEmail()));

            if (customer.getAge() != null) {
                row.createCell((short) 2).setCellValue(customer.getAge().intValue());
            }

            if (customer.getHoldings() != null) {
                row.createCell((short) 3).setCellValue(customer.getHoldings().doubleValue());
            }

            row.createCell((short) 4).setCellValue(new HSSFRichTextString(customer.getInvestments()));
        }

        return wb;
    }
View Full Code Here

        Column column = new Column("name");
        column.setSortable(false);
        column.setDecorator(new Decorator() {
            public String render(Object row, Context context) {
                Customer customer = (Customer) row;
                String email = customer.getEmail();
                String name = customer.getName();
                return "<a href='mailto:" + email + "'>" + name + "</a>";
            }
        });
        table.addColumn(column);

        column = new Column("investments");
        column.setAutolink(true);
        table.addColumn(column);

        column = new Column("holdings");
        column.setFormat("${0,number,#,##0.00}");
        column.setTextAlign("right");
        table.addColumn(column);

        viewLink.setTitle("View customer details");

        editLink.setListener(this, "onEditClick");
        editLink.setTitle("Edit customer details");
        editLink.setParameter("referrer", "/table/table-decorator.htm");

        deleteLink.setTitle("Delete customer record");
        deleteLink.setAttribute("onclick", "return window.confirm('Are you sure you want to delete this record?');");

        column = new Column("Action");
        column.setDecorator(new Decorator() {
            public String render(Object row, Context context) {
                Customer customer = (Customer) row;
                String id = String.valueOf(customer.getId());

                viewLink.setValue(id);
                editLink.setParameter("id", id);
                deleteLink.setValue(id);
View Full Code Here

        // Load customers data file
        loadFile("customers.txt", dataContext, new LineProcessor() {
            public void processLine(String line, DataContext context) {
                StringTokenizer tokenizer = new StringTokenizer(line, ",");

                Customer customer = new Customer();
                customer.setName(next(tokenizer));
                if (tokenizer.hasMoreTokens()) {
                    customer.setEmail(next(tokenizer));
                }
                if (tokenizer.hasMoreTokens()) {
                    customer.setAge(Integer.valueOf(next(tokenizer)));
                }
                if (tokenizer.hasMoreTokens()) {
                    customer.setInvestments(next(tokenizer));
                }
                if (tokenizer.hasMoreTokens()) {
                    customer.setHoldings(Double.valueOf(next(tokenizer)));
                }
                if (tokenizer.hasMoreTokens()) {
                    customer.setDateJoined(createDate(next(tokenizer)));
                }
                if (tokenizer.hasMoreTokens()) {
                    customer.setActive(Boolean.valueOf(next(tokenizer)));
                }

                dataContext.registerNewObject(customer);
            }
        });
View Full Code Here

     *
     * @return true
     */
    public boolean onOkClicked() {
        if (form.isValid()) {
            Customer customer = new Customer();
            form.copyTo(customer);

            customerService.saveCustomer(customer);

            form.clearValues();
View Full Code Here

    // Event Handlers ---------------------------------------------------------

    public boolean onEditClick() {
        Integer id = editLink.getValueInteger();
        Customer customer = customerService.getCustomerForID(id);
        if (customer != null) {
            form.setDataObject(customer);
        }
        return true;
    }
View Full Code Here

    public ActionResult onChangeCustomer() {
        ActionResult actionResult = new ActionResult();

        // Lookup customer based on request parameter 'customerId'
        String customerId = getContext().getRequest().getParameter("customerId");
        Customer customer = customerService.findCustomerByID(customerId);

        // CustomerPanel will render the customer as an HTML snippet
        CustomerPanel customerPanel = new CustomerPanel(this, customer);
        actionResult.setContent(customerPanel.toString());
View Full Code Here

    public ActionResult onChangeCustomer() {
        ActionResult actionResult = new ActionResult();

        // Lookup customer based on request parameter 'customerId'
        String customerId = getContext().getRequest().getParameter("customerId");
        Customer customer = customerService.findCustomerByID(customerId);

        // CustomerPanel will render the customer as an HTML snippet
        CustomerPanel customerPanel = new CustomerPanel(this, customer);
        actionResult.setContent(customerPanel.toString());
View Full Code Here

    /**
     * @see org.apache.click.Page#onPost()
     */
    @Override
    public void onPost() {
        Customer customer = null;
        String value = textField.getValue().trim();
        String type = typeSelect.getValue().toLowerCase();

        if (type.equals("id")) {
            if (NumberUtils.isDigits(value)) {
View Full Code Here

     * @param buffer the buffer to render the totals footer to
     */
    private void renderTotalHoldingsFooter(HtmlStringBuffer buffer) {
        double total = 0;
        for (int i = 0; i < table.getRowList().size(); i++) {
            Customer customer = (Customer) table.getRowList().get(i);
            if (customer.getHoldings() != null) {
                total += customer.getHoldings().doubleValue();
            }
        }

        String format = "<b>Total Holdings</b>: &nbsp; ${0,number,#,##0.00}";
        String totalDisplay = MessageFormat.format(format, new Double(total));
View Full Code Here

TOP

Related Classes of org.apache.click.examples.domain.Customer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.