Greetings,

  Until 08/30/2005, you can buy one license of Dreamsource and get another one 
free from http://www.leeonsoft.com. I just join this mailing list to announce 
this offer. I think it is good for us. Please don't reply this message. 

Dreamsource is a user-friendly Java source code generator for Java and J2EE 
developers. Dreamsource can cut down application development time by 50% to 
70%. You can download it from http://www.leeonsoft.com/download.htm.

Dreamsource generates data access codes based on Data Access Object (DAO) 
design pattern and web source codes based on Struts web framework (1.2). It can 
generate all the necessary source codes and deployment descriptors for J2EE 
applications, and package them into deployable enterprise archive (.ear) files 
for major application servers.

The generated source codes can be customized. Dreamsource provides a simple 
persistence framework, and allows users to build complex SQL query easily. 
Dreamsource framework source code are available for official users upon 
request. Dreamsource users have all source codes. Dreamsource just generates 
source codes to cut down application development time. 

Based on our experience with Dreamsource, the generated Struts source codes can 
be used as your starting point. A lot of time is spent in customizing the 
generated Struts source codes. If you think you can customize the following 
Struts codes, you should consider evaluating Dreamsource to see if it can save 
your development time.

public class CustomersAction extends MappingDispatchAction {
    private static Log log = LogFactory.getLog(CustomersAction.class);
    private static Fields _fields = null;

    static {
        _fields = new Fields();

        _fields.addField(CustomersTable.getCustomerIdField());
  ...

    }

    //for query database records.
    public ActionForward doQuery(ActionMapping mapping, ActionForm form, 
HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        CustomersQueryForm _customersQueryForm = (CustomersQueryForm)form;
        String methodName = _customersQueryForm.getMethodName();
        try {
            CustomersDAO _customersDAO = DelegateFactory.getCustomersDAO();
            Collection _customerss = null;

            if (methodName.equals("findByPrimaryKey")) {
                String customerId = _customersQueryForm.getCustomerId();

                CustomersPK _customersPK = new CustomersPK();
                _customersPK.setCustomerId(customerId);

                _customerss = new ArrayList();

                Customers _customers = _customersDAO.findByPrimaryKey(_fields, 
_customersPK);
                if (_customers == null) {
                    throw new Exception("No such entity found.");
                }
                else {
                    _customerss.add(_customers);
                }

                request.setAttribute("customers_data", transferToView(true, 
_customerss));
            }                    
            //query records based on the range of 'since' field (between since 
and since_1).
            else if (methodName.equals("findBySince")) {
                String since = _customersQueryForm.getSince();
                String since_1 = _customersQueryForm.getSince_1();

                Select select = new Select(_fields);

                Condition condition = new 
Condition(CustomersTable.getSinceField().betweenAnd(since, since_1));
                select.setCondition(condition);
                select.addOrderBy(CustomersTable.getLastNameField().asc());
                select.addOrderBy(CustomersTable.getFirstNameField().asc());

                _customerss = _customersDAO.findBySelect(select);

                request.setAttribute("customers_data", transferToView(true, 
_customerss));
            }
            //query records based on its related table 'Salesreps'
            else if (methodName.equals("findBySalesrepsHireDateRangeAndSales")) 
{
                String salesrepsHireDate = 
_customersQueryForm.getSalesrepsHireDate();
                String salesrepsHireDate_1 = 
_customersQueryForm.getSalesrepsHireDate_1();
                String salesrepsSales = _customersQueryForm.getSalesrepsSales();

                Select select = new Select(_fields);

                JoinCondition salesrepsCustomersJoinCondition = new 
JoinCondition();
                
salesrepsCustomersJoinCondition.add(SalesrepsTable.getEmplNumField(), 
CustomersTable.getCustRepField());

                SalesrepsTable salesrepsTable = new SalesrepsTable();
                CustomersTable customersTable = new CustomersTable();

                JoinTable joinTable0 = 
                    salesrepsTable.join(customersTable, JoinTable.INNER_JOIN, 
salesrepsCustomersJoinCondition);

                And and = new And();
                ConditionBetweenAndField conditionBetweenAndField = 
SalesrepsTable.getHireDateField().betweenAnd(salesrepsHireDate, 
salesrepsHireDate_1);
                and.add(conditionBetweenAndField);

                ConditionField conditionField = 
SalesrepsTable.getSalesField().greaterThan(salesrepsSales);
                and.add(conditionField);

                Condition condition = new Condition(and);
                select.setCondition(condition);
                select.addOrderBy(CustomersTable.getLastNameField().asc());
                select.addOrderBy(CustomersTable.getFirstNameField().asc());

                _customerss = _customersDAO.findBySelect(select, joinTable0);

                request.setAttribute("customers_data", transferToView(true, 
_customerss));
            }

            return mapping.findForward("success");
        }
        catch (Exception e) {
            ActionMessages actionMessages = new ActionMessages();
            actionMessages.add("Customers.query", new 
ActionMessage("errors.query", e.getClass().getName() + ": " + e.getMessage()));
            saveErrors(request, actionMessages);
            return mapping.findForward("failure");
        }
    }

    //update records.
    public ActionForward doUpdate(ActionMapping mapping, ActionForm form, 
HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        try {
            CustomerssUpdateForm _customerssUpdateForm = 
(CustomerssUpdateForm)form;
            int size = _customerssUpdateForm.getSize();
            Customers[] _customerss = new Customers[size];
            for (int i=0; i<_customerss.length; i++) {
                CustomersReqUpdateBean _customersReqUpdateBean = 
_customerssUpdateForm.getCustomersReqUpdateBean(i);
                _customerss[i] = 
transferToUpdatedCustomers(_customersReqUpdateBean);
            }
            CustomersDAO _customersDAO = DelegateFactory.getCustomersDAO();

            _customersDAO.update(_customerss);

            String message = size + " record(s) has/have been updated 
successfully.";
            request.setAttribute("successfullyDone", message);

            return mapping.findForward("success");
        }
        catch(Exception e) {
            ActionMessages actionMessages = new ActionMessages();
            actionMessages.add("Customers.update", new 
ActionMessage("errors.update", e.getClass().getName() + ": " + e.getMessage()));

            saveErrors(request, actionMessages);

            return mapping.findForward("failure");
        }
    }



Reply via email to