Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Apache OfBiz Cookbook
Apache OfBiz Cookbook
Apache OfBiz Cookbook
Ebook790 pages18 hours

Apache OfBiz Cookbook

Rating: 0 out of 5 stars

()

Read preview

About this ebook

The best way to experience OFBiz is to dive right in and start "kicking the tires". No matter if you are an end user exploring the out-of-the-box e-commerce web store or a software developer getting ready to build a new application, you will find, eventually, that you perform the same tasks over and over again. This book is designed as a reference to guide you though those oft-encountered OFBiz tasks. It is a collection of recipes, not necessarily in any particular order of importance, that address and give answers to many of the real-world questions asked about how to do things with OFBiz. If you are an OFBiz user who has some familiarity with enterprise software systems, and perhaps more importantly, Internet and Web exposure, you will be able to glean useful information from this book. You will need only basic knowledge of modern browser behavior (for example: how to click a mouse button) to follow some recipes, while others assume a passing familiarity with a text-editor and XML documents. If you are a software developer looking for Java and/or Groovy examples, this book also includes a chapter on Java software development.
LanguageEnglish
Release dateSep 7, 2010
ISBN9781847199195
Apache OfBiz Cookbook

Related to Apache OfBiz Cookbook

Related ebooks

Information Technology For You

View More

Related articles

Reviews for Apache OfBiz Cookbook

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Apache OfBiz Cookbook - Ruth Hoffman

    Table of Contents

    Apache OFBiz Cookbook

    Credits

    About the Author

    About the Reviewers

    Preface

    What this book covers

    What you need for this book

    Who this book is for

    Conventions

    Reader feedback

    Customer support

    Errata

    Piracy

    Questions

    1. Getting Started

    Introduction

    Getting the project code

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Getting code from the Subversion repository

    Getting ready

    How to do it...

    How it works...

    See also

    Fixing IP port collision errors

    Getting ready

    How to do it...

    How it works...

    There's more...

    The JAVA_HOME setting

    Getting ready

    How to do it...

    How it works...

    There's more...

    Class Not Found errors

    Getting ready

    How to do it...

    How it works...

    There's more...

    Installation verification

    Getting ready

    How to do it...

    How it works...

    There's more...

    SSL verification

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Running JUnit tests

    Getting ready

    How to do it...

    How it works...

    There's more...

    Locating an OFBiz Component

    Getting ready

    How to do it...

    How it works...

    There's more...

    Locating an OFBiz Application

    Getting ready

    How to do it...

    How it works...

    There's more...

    2. Java Development

    Introduction

    Java runtime CLASSPATH

    How to do it...

    How it works...

    Java compile time CLASSPATH

    Getting ready

    How to do it...

    How it works...

    Naming conventions

    How to do it...

    Writing OFBiz Java Events

    Getting ready

    How to do it...

    How it works...

    There's more...

    Writing OFBiz Java Services

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Debugging using the logfile

    Getting ready

    How to do it...

    How it works...

    Calling OFBiz Services from a Java program

    Getting ready

    How to do it...

    How it works...

    There's more...

    Getting and validating request parameters (Events)

    How to do it...

    How it works...

    There's more...

    Getting and validating request parameters (Services)

    How to do it...

    How it works...

    Managing error messages

    How to do it...

    There's more...

    Using Java properties files

    How to do it...

    How it works...

    See also

    Sending e-mail from an OFBiz Event or Service

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Handling XML files

    Getting ready

    How to do it...

    How it works...

    3. The User Interface

    Introduction

    Creating HTML web pages

    Getting ready

    How to do it...

    How it works...

    There's more...

    Adding actions to Screen widgets

    Getting ready

    How to do it...

    How it works...

    There's more...

    HTML markup in Screen widgets

    How to do it...

    How it works..

    There's more...

    CSS styling in Screen widgets

    How to do it...

    How it works...

    There's more...

    Platform-specific widgets

    How to do it...

    How it works...

    There's more...

    OFBiz Tree widgets

    How to do it...

    How it works...

    There's more...

    OFBiz Menu widgets

    How to do it...

    How it works...

    OFBiz Form widgets

    How to do it...

    How it works...

    There's more..

    Creating web pages using FreeMarker

    Getting ready

    How to do it...

    How it works...

    There's more

    See also

    Passing Screen widget parameters to FreeMarker

    How to do it...

    How it works

    There's more

    Calling Java methods from FreeMarker

    How to do it...

    How it works...

    There's more...

    Forcing FreeMarker to render HTML markup

    How to do it...

    How it works

    Uploading files in FreeMarker forms

    Getting ready

    How to do it...

    How it works...

    There 's more...

    4. OFBiz Services

    Introduction

    Managing existing OFBiz Services

    How to do it...

    How it works...

    There's more...

    Calling a Service from an HTML form

    Getting ready

    How to do it...

    How it works...

    Calling asynchronous Services from HTML forms

    Getting ready

    How to do it...

    How it works...

    There's more...

    Calling a Service many times from an HTML form

    How to do it...

    How it works...

    Creating a new Service definition file

    How to do it...

    How it works...

    Creating a new Service definition

    How to do it...

    How it works...

    See also

    Implementing Services

    Getting ready

    How to do it...

    How it works...

    There's more...

    Defining Service attributes (INPUT/OUTPUT)

    How to do it...

    How it works...

    Service Event Condition Actions

    Getting ready

    How to do it...

    How it works...

    There's more...

    Service groups

    Getting ready

    How to do it...

    How it works...

    See also

    Handling Service errors

    Getting ready

    How to do it...

    How it works...

    See also

    Writing Groovy Services

    Getting ready

    How to do it...

    How it works...

    Mail Event Condition Actions

    Getting ready

    How to do it...

    How it works...

    See also

    Entity Event Condition Actions

    How to do it...

    How it works...

    There's more...

    See also

    5. The OFBiz Entity Engine

    Introduction

    Changing the default database

    Getting ready

    How to do it...

    How it works...

    See also

    Connecting to a remote database

    Getting ready

    How to do it...

    How it works...

    Connecting to multiple databases

    Getting ready

    How to do it...

    How it works...

    Creating entity groups

    Getting ready

    How to do it...

    How it works...

    Disabling automatic database checks

    Getting ready

    How to do it...

    How it works...

    Mapping database data types

    Getting ready

    How to do it...

    How it works...

    Creating a new entity definition file

    How to do it...

    How it works...

    Creating a new entity model

    Getting ready

    How to do it...

    How it works...

    There's more...

    Modifying an existing entity model

    Getting ready

    How to do it...

    How it works...

    Building a view-entity

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    6. OFBiz Security

    Introduction

    Securing communications ports

    How to do it...

    How it works...

    There's more...

    See also

    Disabling demonstration user accounts

    How to do it...

    How it works...

    Protecting OFBiz web pages

    Getting ready

    How to do it...

    How it works...

    There's more...

    Creating user accounts

    How to do it...

    How it works...

    There's more...

    Protecting applications using security groups

    How to do it...

    How it works...

    There's more...

    Protecting views (Tarpitting)

    Getting ready

    How to do it...

    How it works...

    There's more...

    Retrieving forgotten passwords

    Getting ready

    How to do it...

    How it works...

    Changing your password

    How to do it...

    How it works...

    Adding or changing SSL certificates

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    OFBiz single sign-on and the external login key

    Getting ready

    How to do it...

    How it works...

    There's more...

    7. WebTools

    Introduction

    Cache maintenance

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Changing debug settings

    Getting ready

    How to do it...

    How it works...

    There's more...

    Exporting database data to XML documents

    Getting ready

    How to do it...

    How it works...

    Loading database(s) from XML documents

    Getting ready

    How to do it...

    How it works...

    There's more...

    Managing internationalization labels

    Getting ready

    How to do it...

    How it works

    There's more...

    Using the SQL processor

    Getting ready

    How to do it...

    How it works...

    Exploring the entity reference tool

    Getting ready

    How to do it...

    How it works...

    Viewing OFBiz usage statistics

    Getting ready

    How to do it...

    How it works...

    Uncovering artifact information

    Getting ready

    How to do it...

    How it works...

    Working with temporal expressions

    Getting ready

    How to do it...

    How it works...

    There's more...

    8. Web Services

    Introduction

    Requesting web services using URL parameters

    Getting ready

    How to do it...

    How it works...

    There's more...

    Requesting web services using an HttpClient

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Creating HttpClients and passing XML documents

    Getting ready

    How to do it...

    How it works...

    Creating XML-RPC web service clients

    Getting ready

    How to do it...

    How it works...

    See also

    Becoming an XML-RPC web service provider

    Getting ready

    How to do it...

    How it works...

    See also

    OFBiz SOAP messaging clients

    Getting ready

    How to do it...

    How it works...

    There's more...

    Generating a WSDL document

    Getting ready

    How to do it...

    How it works...

    Creating SOAP-compliant web services

    Getting ready

    How to do it...

    How it works...

    9. OFBiz Tips and Tricks

    Introduction

    Fixing Java memory allocation errors

    Getting ready

    How to do it...

    How it works...

    There's more...

    Reloading OFBiz seed and demo data

    Getting ready

    How to do it...

    How it works...

    There's more...

    Creating new seed data files

    Getting ready

    How to do it...

    How it works...

    There's more…

    Changing the administrative user's password

    Getting ready

    How to do it...

    How it works...

    There's more…

    Creating a new administrative user

    Getting ready

    How to do it...

    How it works...

    There's more...

    Getting the OFBiz version number

    Getting ready

    How to do it...

    How it works...

    There's more...

    Building an OFBiz instance

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Building a single OFBiz Component

    Getting ready

    How to do it...

    How it works...

    Creating a new OFBiz Component or Application

    Getting ready

    How to do it...

    How it works...

    There's more...

    Creating a FreeMarker transform

    How to do it...

    How it works...

    There's more...

    Preparing data using Groovy

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Pop-up new browser windows

    How to do it...

    How it works...

    There's more...

    Installing an OFBiz Visual Theme

    Getting ready

    How to do it...

    How it works...

    There's more...

    Creating an OFBiz Visual Theme

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    A. Entity Engine by Example

    Introduction

    Putting it all together with a data model example

    Sample use case

    Entity diagram

    New entity definitions

    2-way SQL join view-entity

    3-way SQL join view-entity

    View-entity reports

    Next steps

    Reading data from an OFBiz data source

    Working with large result sets (EntityListIterator)

    Removing data from the database (Java)

    Writing data to the database (Java)

    Using the automatic sequence generator

    EntityUtil

    EntityUtil.getFirst()

    EntityUtil.filterByDate()

    EntityUtil.orderBy()

    EntityUtil.getFieldListFromEntityList()

    EntityUtil.getRelated()

    EntityUtil.filterByCondition()

    EntityOperator reference

    Index

    Apache OFBiz Cookbook


    Apache OFBiz Cookbook

    Copyright © 2010 Packt Publishing

    All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

    Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

    Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

    First published: September 2010

    Production Reference: 1020910

    Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK.

    ISBN 978-1-847199-18-8

    www.packtpub.com

    Cover Image by Harmeet Singh ( <singharmeet@yahoo.com> )

    Credits

    Author

    Ruth Hoffman

    Reviewers

    Adrian Crum

    Shi Jinghai

    Acquisition Editor

    Chaitanya Apte

    Development Editor

    Rakesh Shejwal

    Technical Editor

    Vanjeet D'souza

    Indexer

    Hemangini Bari

    Editorial Team Leader

    Mithun Sehgal

    Project Team Leader

    Ashwin Shetty

    Project Coordinator

    Joel Goveya

    Proofreader

    Jonathan Todd

    Graphics

    Geetanjali Sawant

    Production Coordinator

    Arvindkumar Gupta

    Cover Work

    Arvindkumar Gupta

    About the Author

    Ruth Hoffman is an OFBiz evangelist with over 25 years of information technology experience, including stints in software design and development, training, project management, product marketing, and software sales, She has dedicated the last few years of her eventful career to furthering the OFBiz vision. Whether it be writing about OFBiz, providing implementation and OFBiz consulting services, or just kicking the OFBiz tires for each new release, she enjoys working with and telling the world about all that this amazing ERP software suite has to offer.

    Ruth's current passion is her quest to provide high quality, cost effective OFBiz training and documentation. She has pursued this quest through multiple channels, including the OFBiz website. She invites everyone to stop by, take a gander, and give some feedback at http://www.myofbiz.com

    As a long-standing supporter of OFBiz, she has authored several other OFBiz titles, including OFBiz E-Commerce Out-Of-The-Box and The OFBiz Catalog Manager. For more information, please see: http://www.myofbiz.com.

    I would like to thank my partner, JC, for being so patient and understanding, my daughter for not getting too upset when I cancelled our planned Lilac Festival adventure, and my dog Sadie for sitting by me all those long hours when no one else would.

    Also, my sincerest thanks go to Adrian Crum and Shi Jinghai for their dedicated efforts in providing technical reviews of this book. Thanks for keeping me honest and setting me straight on a number of occasions. Your contributions are greatly appreciated!

    About the Reviewers

    Adrian Crum is an IT Manager/Computer programmer for a company that builds homes. Prior to that, he owned and operated a computer retail/service/consulting business. He was Technical Editor of Coast Compute Magazine, and a contributing writer for Programmer's Journal. Adrian has been involved with the Apache OFBiz project as a contributing programmer since 2004, and he is a member of the Project Management Committee. His extensive experience in many programming languages and cross-platform development has been a key part of his contributions to the Apache OFBiz project.

    Shi Jinghai graduated from Tsinghua University in 1991. In 2001, he took part in the China 2G Citizen Card Project and became an important system designer of the National Citizen Identity Information System of China. In 2004, he started his own company (Beijing Langhua Ltd.) focusing on IT services based on some excellent open source projects such as OFBiz, OpenCms, JBoss Portal, and Jasig CAS among others.

    Preface

    This book is designed to be read in any order, and is a collection of recipes found, by experience, to be most useful for developers working with the OFBiz project. Let it be your guide to enhancing your OFBiz productivity by saving you valuable time. Written specifically to give clear and straightforward answers to the most commonly asked OFBiz questions, this compendium of OFBiz recipes will show you everything you need to know to get things done in OFBiz.

    Whether you are new to OFBiz or an old pro, you are sure to find many useful hints and handy tips here. Topics range from getting started, to configuration and system setup, security and database management, through the final stages of developing and testing new OFBiz applications. We are now Open For Business.

    What this book covers

    Chapter 1, Getting Started: If you already know how to get started with OFBiz then you can confidently skip this chapter. If, however, you are new to OFBiz, then you may find helpful hints in here to get you started, including getting a copy of the code from the download page or from the Subversion source code repository; fixing installation-related IP port collision errors; setting JAVA_HOME; fixing Java Class Not Found errors; installation verification; running JUnit tests; and some basic project artifact navigation hints, including where certain special directories (folders for Windows users) and files may be found.

    Chapter 2, Java Development: OFBiz Java development starts with a clear understanding of the role of the Java CLASSPATH. In this chapter, learn how the CLASSPATH enables compilation and runtime loading of OFBiz artifacts. In addition, this chapter reveals how the OFBiz Java file-naming convention is helpful in organizing and finding Java source code. Also learn how to create OFBiz Events and Services, effectively use the provided Java debugging methods, call another OFBiz Service from within a Java program, access HTTP/HTTPS request parameters, use existing tools to handle error messages, use Java properties files, send e-mail using existing OFBiz Service(s), and manipulate XML documents using provided tools.

    Chapter 3, The User Interface: Users interact with OFBiz—that is, the User Interface—through web pages often referred to within the project as screens or screen views. In this chapter, see how web pages are built from the OFBiz Screen widget, including how to add actions, HTML markup, CSS, and other widgets (Tree, Menu, and Form widgets) to a single screen view widget definition. If your tastes run more towards creating your own screen views, see how to use FreeMarker templates inside Screen widget definitions to build (HTML) web pages. Also discussed in this chapter: passing parameters from the Screen widget's runtime context to the FreeMarker rendering engine, writing JavaScript and including it in a FreeMarker template, calling OFBiz Java methods directly from the FreeMarker context, forcing FreeMarker to render content with HTML markup at runtime, and how to upload a file—that is, support multipart HTML forms—in FreeMarker.

    Chapter 4, OFBiz Services: OFBiz Services are reusable snippets of code that represent business processing or other logic. You write an OFBiz Service one time and invoke it anytime, anywhere and as often as needed. In this chapter, discover how to manage existing Services, invoke Services from an HTML form, and implement your own Service. Learn how Services communicate and interact during runtime operations using input and output attributes and triggers called Service Event Condition Actions, or SECAs. See best practices for handling errors within a Service and/or SECA. Also discussed are tips on implementing Services in languages other than Java, and a quick introduction to special SECA for incoming e-mail and operations on specific entities.

    Chapter 5, The OFBiz Entity Engine: The OFBiz Entity Engine is the magic behind the database agnostic, data-driven tour-de-force that is OFBiz. In this chapter, see how to configure and use the Entity Engine to your advantage. Specifically, see how to change from the default Derby database to another database (note: throughout the OFBiz documentation, the term data source is used interchangeably with database); how to connect to remote and multiple databases; how entity groups work to help OFBiz organize access to multiple databases; and disable some system database startup checks, map new database field types, create your own entity definition file and entity definition, modify an existing entity definition—often referred to as the entity's model—and build view-entities that represent SQL join statements.

    Chapter 6, OFBiz Security: What book about enterprise software would be complete without a word concerning security? In this chapter, get a quick introduction to securing your OFBiz instance, including recipes to lock down communication ports, disable demonstration accounts, protect web pages and web applications using OFBiz Security Groups, enable support for tarpitting, retrieve forgotten passwords, change existing passwords, handle SSL certificates, and use OFBiz single sign-on support by way of the external login key feature.

    Chapter 7, WebTools: Often lost in the OFBiz shuffle is a discussion covering basic usage of the many and varied tools that come with the project to manage your OFBiz instance. Collectively called WebTools, this chapter looks at several important tasks easily accomplished using WebTools, including managing the cache, configuring system and application log tool settings for debug and troubleshooting support; exporting and importing database data; managing localization labels, and accessing databases using the SQL processor tool. Also discussed are introductions to the immensely useful Entity Reference Tool, finding and viewing OFBiz usage statistics, tracing OFBiz artifact dependencies, and working with temporal expressions.

    Chapter 8, Web Services: With service orientation at the core of the OFBiz architecture, OFBiz is uniquely qualified to act as both a web services client and service provider for any number of web service interactions. In this chapter, learn how to act as a web services client and request service using URL parameter passing, HttpClient and XML document exchanges, and XML-RPC service requests. If you wish to provide web services, see how to set up OFBiz to serve XML-RPC services, generate and serve WSDL documents, and build both SOAP-based clients and services.

    Chapter 9, OFBiz Tips and Tricks: This chapter is a collection of recipes

    Enjoying the preview?
    Page 1 of 1