Thông tin tài liệu
www.it-ebooks.info
Apache OFBiz Cookbook
Over 60 simple but incredibly effective recipes for taking
control of OFBiz
Ruth Hoffman
BIRMINGHAM - MUMBAI
www.it-ebooks.info
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)
www.it-ebooks.info
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
www.it-ebooks.info
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!
www.it-ebooks.info
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.
www.it-ebooks.info
www.it-ebooks.info
Table of Contents
Preface 1
Chapter 1: Getting Started 7
Introduction 7
Getting the project code 9
Getting code from the Subversion repository 12
Fixing IP port collision errors 14
The JAVA_HOME setting 17
"Class Not Found" errors 18
Installation verication 20
SSL verication 22
Running JUnit tests 25
Locating an OFBiz Component 26
Locating an OFBiz Application 28
Chapter 2: Java Development 31
Introduction 32
Java runtime CLASSPATH 32
Java compile time CLASSPATH 33
Naming conventions 34
Writing OFBiz Java Events 35
Writing OFBiz Java Services 39
Debugging using the logle 42
Calling OFBiz Services from a Java program 43
Getting and validating request parameters (Events) 45
Getting and validating request parameters (Services) 47
Managing error messages 48
Using Java properties les 50
Sending e-mail from an OFBiz Event or Service 51
Handling XML les 53
www.it-ebooks.info
ii
Table of Contents
Chapter 3: The User Interface 57
Introduction 57
Creating HTML web pages 58
Adding actions to Screen widgets 63
HTML markup in Screen widgets 65
CSS styling in Screen widgets 66
Platform-specic widgets 68
OFBiz Tree widgets 69
OFBiz Menu widgets 71
OFBiz Form widgets 72
Creating web pages using FreeMarker 74
Passing Screen widget parameters to FreeMarker 77
Calling Java methods from FreeMarker 78
Forcing FreeMarker to render HTML markup 79
Uploading les in FreeMarker forms 79
Chapter 4: OFBiz Services 83
Introduction 83
Managing existing OFBiz Services 85
Calling a Service from an HTML form 86
Calling asynchronous Services from HTML forms 89
Calling a Service many times from an HTML form 91
Creating a new Service denition le 92
Creating a new Service denition 93
Implementing Services 94
Dening Service attributes (INPUT/OUTPUT) 95
Service Event Condition Actions 96
Service groups 98
Handling Service errors 100
Writing Groovy Services 102
Mail Event Condition Actions 104
Entity Event Condition Actions 106
Chapter 5: The OFBiz Entity Engine 111
Introduction 111
Changing the default database 113
Connecting to a remote database 119
Connecting to multiple databases 120
Creating entity groups 121
Disabling automatic database checks 123
Mapping database data types 123
www.it-ebooks.info
iii
Table of Contents
Creating a new entity model 126
Modifying an existing entity model 130
Building a view-entity 132
Chapter 6: OFBiz Security 137
Introduction 137
Securing communications ports 138
Disabling demonstration user accounts 141
Protecting OFBiz web pages 142
Creating user accounts 144
Protecting applications using security groups 147
Protecting views ("Tarpitting") 152
Retrieving forgotten passwords 154
Changing your password 156
Adding or changing SSL certicates 157
OFBiz single sign-on and the external login key 160
Chapter 7: WebTools 163
Introduction 163
Cache maintenance 164
Changing debug settings 167
Exporting database data to XML documents 170
Loading database(s) from XML documents 172
Managing internationalization labels 174
Using the SQL processor 176
Exploring the entity reference tool 177
Viewing OFBiz usage statistics 181
Uncovering artifact information 183
Working with temporal expressions 186
Chapter 8: Web Services 189
Introduction 189
Requesting web services using URL parameters 190
Requesting web services using an HttpClient 193
Creating HttpClients and passing XML documents 196
Creating XML-RPC web service clients 199
Becoming an XML-RPC web service provider 202
OFBiz SOAP messaging clients 204
Generating a WSDL document 212
Creating SOAP-compliant web services 215
www.it-ebooks.info
[...]... connection with HTTP access to the OFBiz download website How to do it Apache OFBiz can be downloaded as shown in the following steps: 1 Using your browser, navigate to the Apache OFBiz download site (http:/ /ofbiz apache. org/download.html) to reveal the Download Apache OFBiz web page as shown: 10 www.it-ebooks.info Chapter 1 2 Use your browser to select the desired OFBiz release New users are urged... started 5 OFBiz is up and running! See also For more information on prerequisites, getting the OFBiz code, and downloading and starting OFBiz up, please visit the What Do I Get? section on the following OFBiz web page: http:// ci .apache. org/projects /ofbiz/ snapshots/ Note: Be careful not to use the DOWNLOAD OFBIZ button on the snapshots download web page Unless you want to download the latest OFBiz trunk... view the primary OFBiz log file located in ~/runtime/logs /ofbiz. log 14 www.it-ebooks.info Chapter 1 2 Locate the OFBiz configuration file where the port is set 3 Edit the OFBiz configuration by changing the port number to a non-conflicting value 4 Restart OFBiz How it works For example, to fix collisions on port 8080, the IP port that OFBiz listens on for HTTP requests, navigate to the ofbiz- containers.xml... ~framework/base/config/ofbizcontainers.xml ~framework/webapp/config/url properties ~framework/base/config/ofbizcontainers.xml ~framework/base/config/ofbizcontainers.xml ~framework/base/config/ofbizcontainers.xml ~framework/base/config/rmicontainers.xml ~startofbiz.sh ~startofbiz.bat ~startofbizNoLog.bat ~stopofbiz.sh ~framework/base/config/jndiLdap properties Port usage note Tomcat HTTP listener Internal HTTP... following table summarizes OFBiz Java dependencies: Release Java version OFBiz 9.04 1.5 OFBiz 4.0 1.5 OFBiz trunk 1.6 19 www.it-ebooks.info Getting Started There's more There is no recommended Java reference platform for OFBiz Known implementations of the Java SDK that have successfully built OFBiz include the Sun and Mac Java SDKs Installation verification To quickly ascertain if OFBiz has installed correctly... build, this button should not be confused with the DOWNLOAD OFBIZ button found on the official OFBiz loading web page: http:/ /ofbiz .apache. org Getting code from the Subversion repository If you are planning to contribute back to the project or are just curious about downloading from the OFBiz source code control system, you may download a complete OFBiz package from the Subversion source code repository... install OFBiz from within the IDE using IDE-specific commands It goes without saying: you must also have an Internet connection with access to the OFBiz Subversion repository How to do it OFBiz source code can be downloaded from the Subversion repository by the following steps: 1 From a command-line window, type the following Subversion command: svn co http://svn .apache. org/repos/asf /ofbiz/ trunk ofbiz. .. running the OFBiz startup scripts The build script rebuilds all included Java programs, rebuilds the runtime CLASSPATH, and checks and loads the database with seed and demonstration data See also For more information on using Eclipse with the OFBiz Subversion repository, please refer to the following OFBiz Wiki page: http://cwiki .apache. org/confluence/display /OFBIZ/ Running+and+Debuggin g +OFBiz+ in+Eclipse... 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... start up OFBiz Depending on your operating system environment and your proclivities towards working on the command line, you may: ff Use one of the provided start up scripts ff Invoke OFBiz from the command line directly or use the ANT build tool as shown here: Windows Unix Command line startofbiz.bat startofbiz.sh java -Xmx256M -jar ofbiz. jar ant run 11 www.it-ebooks.info Getting Started OFBiz runs .
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. version
OFBiz
version
apache- ofbiz- 09.04.zip
Recommended for new users
and those looking for the most
stable project package.
Java 1.5 *
apache- ofbiz- 4.0.zip
Legacy
Ngày đăng: 07/03/2014, 06:20
Xem thêm: Apache OFBiz Cookbook pdf, Apache OFBiz Cookbook pdf