OFBiz learning practices

Source: Internet
Author: User

Additional points:
1. Construct a dynamic query statement for OFBiz
(1) construct query Conditions
(2) Add a logical relationship between each condition and use maincond = new entityconditionlist (andexprs, entityoperator. And );
(3) set the list of fields to be displayed
(4) set the sorting Field List
(5) set the distinct list
Entityfindoptions findopts = new entityfindoptions (true, entityfindoptions. type_scroll_insensitive, entityfindoptions. concur_read_only, true );
(6) obtain the Object List
Entitylistiterator PLI = delegator. findlistiteratorbycondition (entityname, maincond, null, fieldstoselect, orderby, findopts );
(7) a specific instance of a dynamic query statement
<%
String entityname = "study ";
List andexprs = new arraylist ();
String number = "";
String name = "";
String sex = "";
String Tel = "";
// Genericdelegator delegator = genericdelegator. getgenericdelegator ("default ");
Entityconditionlist maincond = NULL;
If (request. getparameter ("Number ")! = NULL)
Number = request. getparameter ("Number"). tostring ();
If (request. getparameter ("name ")! = NULL)
Name = request. getparameter ("name"). tostring ();
If (request. getparameter ("sex ")! = NULL)
Sex = request. getparameter ("sex"). tostring ();
If (request. getparameter ("tel ")! = NULL)
Tel = request. getparameter ("tel"). tostring ();
// Construct query Conditions
If (number. compareto ("")! = 0)
Andexprs. Add (New entityexpr ("Number", entityoperator. Equals, number ));
If (name. compareto ("")! = 0)
Andexprs. Add (New entityexpr ("name1", true, entityoperator. Like, "%" + name + "%", true ));
If (sex. compareto ("")! = 0)
Andexprs. Add (New entityexpr ("sex1", true, entityoperator. Like, "%" + sex + "%", true ));
If (Tel. compareto ("")! = 0)
Andexprs. Add (New entityexpr ("tel", true, entityoperator. Like, "%" + Tel + "%", true ));
// Logical relationship between each condition
If (andexprs. Size ()> 0)
Maincond = new entityconditionlist (andexprs, entityoperator. And );
// List of fields to be displayed
List fieldstoselect = new arraylist ();
Fieldstoselect. Add ("Number ");
Fieldstoselect. Add ("name1 ");
Fieldstoselect. Add ("sex1 ");
Fieldstoselect. Add ("tel ");
// List of sorting Fields
List orderby = utilmisc. tolist ("Number", "name1 ");
// Distinct list
Entityfindoptions findopts = new entityfindoptions (true, entityfindoptions. type_scroll_insensitive, entityfindoptions. concur_read_only, true );
// Obtain the Object List
Entitylistiterator PLI = delegator. findlistiteratorbycondition (entityname, maincond, null, fieldstoselect, orderby, findopts );
While (PLI. hasnext ())
{
Genericvalue Cust = (genericvalue) PLI. Next (); %>
<Tr>
<TD> <% = Cust. getstring ("Number") %> </TD>
<TD> <% = Cust. getstring ("name1") %> </TD>
<TD> <% = Cust. getstring ("sex1") %> </TD>
<TD> <% = Cust. getstring ("tel") %> </TD>
</Tr>
<% }%>

</Table>

2. All image files are stored in the images directory.
3. Set the image tag <OFBiz: contenturl> image path </OFBiz: contenturl>
4. link tag <OFBiz: URL> request set in control. xml </OFBiz. url>
5. <region: render section = 'header'/> introduce the file defined by the header.
The header identifier is defined in regions. xml.
<Define id = 'main _ reg 'template ='/templates/main_template1.jsp '>
<Put section = 'title'> application page </put> <! -- This is a default and is meant to overridden -->
<Put section = 'header' content = '/shortdes/bottom. jsp'/>
<Put section = 'leftbar' content = '/shortdes/left. jsp'/>
<Put section = 'middle' content = '/Includes/middle. jsp'/>
<Put section = 'content' content = '/Includes/middle. jsp'/> <! -- This is a default and is meant to overridden -->
<Put section = 'top' content = '/shortdes/top. jsp'/>
<Put section = 'error' type = "jpublish" content = '/Includes/errormsg. FTL'/>
<! -- <Put section = 'footer 'type = "jpublish" content ='/Includes/footer. FTL '/> -->
</Define>
Then the following definitions can be used for other pages:
<Define id = 'basepubemp' region = 'main _ reg '>
<Put section = 'title'> View basepubemp </put>
<Put section = 'content' content = '/basepubemp. jsp'/>
</Define>
Note that the block specified by content here is the content defined above.
6. These labels are quite simple. There are examples in OFBiz. Just take a look.

The shark workflow in OFBiz will be described later.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.