Moqui Learning Day4

Source: Internet
Author: User

Add a new form

Add a button to pop up the new form and create a transform to handle the input data operation. Add a transform to the Findtutorial.xml file.
<!--new List-    <transition>        <service-call name= "create#tutorial"/>        < Default-response url= "." />    </transition>

  

the conversion simply invokes the Lecreate#tutorial service and then jumps back to the current page. The service façade of the Moqui Framework supports a custom entity that does not need to define the implementation of entities or additions to the service, the name of the service consists of two parts: a verb and a noun, in the middle with a # separated by a verb called create update store Delete , and the noun is a valid entity name, the service façade you will assume that the service is an implicit automatic entity service and will perform the expected operation. This service invocation is based entirely on the entity definition and passed parameters. For example, if you use the CREATE verb and pass a primary key field for the entity, the service will use the primary key field, or the service will automatically generate the primary key sequence number using the entity name as the sequence key. add a new form that shows a hidden container interface when the button is clicked, adds a container to the form-list element within the widget element in the previously created Findtutoria interface, and displays the container on the list form:
<container-dialog id= "Createtutorialdialog" button-text= "Create Tutorial" >            <form-single name= " Createtutorial "transition=" createtutorial ">                <auto-fields-entity entity-name=" Tutorial "field-type=" Edit "/>                <field name=" Submitbutton ">                  <default-field title=" Create ">                      <submit/>                  </default-field>                </field>            </form-single>        </container-dialog>

  

This interface definition is referenced by the transition just added, and the edit field is automatically generated using the Field-type element definition of the auto-fields-entity element with the value edit, and finally a button is declared to submit the form so that it can be run. Customizing new services:The createtutorial conversion above uses an implicit automatic entity service create#tutorial.The following implements the manual creation of new servicesfirst define a service using the default automatic entity additions and deletions to implement,Runtime/component/tutorial/service/tutorial/tutorialservices.xml
<container-dialog id= "Createtutorialdialog" button-text= "Create Tutorial" >            <form-single name= " Createtutorial "transition=" createtutorial ">                <auto-fields-entity entity-name=" Tutorial "field-type=" Edit "/>                <field name=" Submitbutton ">                  <default-field title=" Create ">                      <submit/>                  </default-field>                </field>            </form-single>        </container-dialog>

  

Findtutorial.xml<!--custom new -  
  <transition name= "createtutorial" >        <service-call name= "tutorial. Tutorialservices.create#tutorial "/>        <default-response url=". />    </transition>

  

  Groovy Services:What if you want to use groovy (or other languages supported by the framework) instead of inline XML actions to implement the service?  
<service verb= "Create" noun= "Tutorial" type= "script" location= "component://tutorial/script/ Createtutorial.grovvy ">        <in-parameters>            <auto-parameters include=" All "/>        </ in-parameters>        <out-parameters>            <out-parameters>                <auto-parameters include= "PK" Required= "true"/>            </out-parameters>        </out-parameters>    </service>

  

 the type attribute of the Zhe forest has become a market ripe, and now has a location property to specify the position of the script Grovvy The contents of the script: 
Entityvalue tutorial=ec.entity.makevalue ("tutorial") tutorial.setall (context) if (!tutorial.tutorialid) Tutorial.setsequencedidprimary () tutorial.create ()

  

Moqui Learning Day4

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.