论坛首页 Java企业应用论坛

ofbiz minilang(hjd_668翻译)

浏览 2079 次
该帖已经被评为隐藏帖
作者 正文
   发表时间:2007-11-29  

 

   由于编辑器不好用,所以主要内容在附件中,是doc格式simple-map-processor simple-method XML files  

simple-map-processor的两个主要功能:校验,转换

 

Simple Map Processors Example

<!---->


 

 
 -
 -
 T
 :
 :
 
 

 
 
 
 

 
 
 
 
 

 
 
 
 
 

 
 
 

     

simple-method 是可以被Control Servlet a service 调用的Event的的简单实现

 
 

Sm 可以被作为static 方法调用(调用者可以是Control Servlet or a service),或者作为一个类调用(调用者可以是Control Servlet or a service),也可以通过一个Entity controller 配置文件:

 

或一个 service 通过一个entry 在一个 services.xml 文件,像下面:

 location="org/ofbiz/commonapp/party/party/PartyRoleServices.xml" invoke="createPartyRole" auth="true">
 Create a Party Role (add a Role to a Party)
 optional="true"/>
 
 

  

Mini-Language 可以调用 Simple Map Processors, Services and bsh scripts, 操作 entity 相关的操作, and 创建消息返回给调用者. Specific operations can be 附上 in if blocks to execute conditionally and values or fields can be copied around in the maps, lists and method environment.

 

有许多标签可以得到或者设置属性 /从一个 request 或者 session object 当被作为一个事件调用 或者设置属性作为返回结果当作为一个服务的时候。如果你包含一个env-to-request 操作,它将仅仅被作为一个enent的时候才会被调用 。一个a env-to-result 操作见仅仅被作为一个service时才可以调用。 Everything else is the same when called as an event or a service which makes it easy to write 灵活的逻辑that can be mounted/applied in various ways.

 下面是simple-method标签的完整的属性表:
Attribute NameReqd?Default ValueDescription
method-nameYN/AA name (preferably a legal Java identifier) for this method. This name must be unique for the XML file it is in as it will be used to reference this method externally.
short-descriptionYN/AA short description of the method for certain system error messages.
login-requiredN"true"Is a logged in user (UserLogin object, or login.username and login.password Strings) required to run this method? "true" or "false".
use-transactionN"true"Create a transaction if none exists for this thread? "true" or "false".
default-error-codeN"error"The default error return code.
default-success-codeN"success"The default success return code.
parameter-map-nameN"parameters"As event: copy of request parameters
As service: incoming context
event-request-object-nameN"request"(as event only)
event-response-code-nameN"_response_code_"(as event only)
event-error-message-nameN"_error_message_"(as event only)
event-event-message-nameN"_event_message_"(as event only)
service-response-message-nameN"responseMessage"(as service only)
service-error-message-nameN"errorMessage"(as service only)
service-error-message-list-nameN"errorMessageList"(as service only)
service-success-message-nameN"successMessage"(as service only)
service-success-message-list-nameN"successMessageList"(as service only)
delegator-nameN"delegator"A GenericDelegator object to use in the method
security-nameN"security"A Security object to use in the method
dispatcher-nameN"dispatcher"A LocalDispatcher object to use in the method

访问特殊 Contex的语法

访问Map成员,属性field-name="product.productName" 将引用product MapproductName成员,另一种写法是map-name="product" field-name="productName" ,下面的写法更加自由:name="products.widget.productName",这句将访问products Map类型)的widget成员(也是一个Map类型)productName成员

 

访问List 成员,例子:field-name="products[0].productName"将访问products(List类型)的第一个元素的productName属性。为了更有用,,你可以从环境中得到一个List的索引,如:field-name="products[${currentIndex}].productName",甚至一个Map的引用:field-name="products[${currentIndex}].${currentMember}"

  
Call Operations

call-map-processor

 

call-map-processor 标签调用一个简单的map processor 从一个存在的map 或创建一个新的map 或者添加到已经存在的map中去,如果这个名字的out-map 已经存在的话。 Resulting messages 被加入一个命名的 list, 如果这个名字的list不存在的话,一个新的List就会被创建. 记住,同一个context中所有的maplist必须有唯一的名字

  
Attribute NameRequired?Description
xml-resourceNThe full path and filename on the classpath of the XML file which contains an external map processor to execute. This is only required if an external map processor is desired.
processor-nameNThe name of the external map processor to execute in the specified xml-resource. This is only required if an external map processor is desired.
in-map-nameYThe name of a map in the method environment to use as the input map.
out-map-nameYThe name of a map in the method environment to use as the output map. Will be created if it does not exist already. If already exists will be added to in place.
error-list-nameNThe name of a list in the method environment that the error messages will be added to. Will be created if it does not exist. Defaults to "error_list".
 
Sub-Element NameHow Many<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-o
   发表时间:2007-11-29  
干啥呢啊?
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics