add(add.jsp.jet) - Generate the new page

Introduce

Generate the new page.

Related knowledge:

Task

Model

Tag


Task And Model

The model group of the current task is shop, 
which contain a Java entity model book, 
and the relation value of book is one;

More about the model structure of this demo, please click: Demo model structure 

There are 2 ways to select the model:

We have created the following properties for this model:
Class: A head uppercase property, 
       which can be used as the class name or a part that need head uppercase.
       It's value is "Book".
class: A lowercase property, 
       which can be used as a part that need lowercase.
       It's value is "book".
menu: The name of the menu bar, and it's value is "Book".

Initialization

Add field

logic:
--If the field is the query field, iterate over the field.
<table>
for field : object.fields object.isEdit
  <tr>
    --Output field name 
    <th>field.name</th>
    <td>
    --If the control is text                                   
    if field.controlType == text
    --Output input control
    <input ...>
    --If the control is select
    elseif field.controlType == select
    --Output select control
    <select ...>
      --The data of the field                  
      for data : field.datas
      --The value of the option is data.value, and the name of the option is data.name
      <option value="data.value"/>data.name</option>
    </select ...>
    --If the control is date
    elseif field.controlType == date
    --Output date control
    <input class="Wdate"...>
    </td>
  </tr>
</table>

field.property("isEdit") == true: whether the field is editable, editable fields need to set control.

Result

Submit, Clear and Back

Similarly, submit, clear and back javascript can be generated.

Result