Nested Lists#

Makumba allows for several <mak:list> and <mak:object> tags to be nested inside each other. This allows you to display objects from a certain type, and then for each object to list all related objects. As an example, we might want to list all companies, and then for each company all the employees working at that specific company.
    <mak:list from="company.Company c" orderBy="name">
            <mak:value expr="">, employees:
                <mak:list from="company.Employee e" where="" orderBy=",, e.surname">
                    <li> <mak:value expr=""> <mak:value expr="e.surname"> (<mak:value expr="") </li>>

The strength in nested <mak:lists> is that Makumba will take care of optimising the SQL statements needed for fetching the data. In an optimal case, for each root/top level <mak:list>, only 1 SQL statement is needed, fetching and grouping all the data needed for the nested lists.

More statements are required if some of the pointers used in the statements can be null. More details can be found in the <mak:list> implementation documentation.

Multiple Forms#

Makumba allows creating or editing of several different types and objects at the same time, within a single form. This is called "multiple forms" or "nested forms". For example, we can edit all the addresses of a person at the same time, or we can create five new companies within a single form. This allows the user to accomplish several actions with only one form submission.

Some properties of multiple forms are:

  • Any number of levels of form inclusion is possible but only the outermost form can have an action, onSubmit, and method and other attributes specific to HTML forms.
  • All form actions take place in a single database transaction, which is rolled back by Makumba if there is an error in any of the single forms.
  • addForms can add to the subsets of object produced by the enclosing newForm.
  • After_ methods are not executed in correct order (bug 689)
<mak:form action="blabla">
    <%-- the topmost form, will result in a HTML form --!>

    <mak:input name="first" /> <%-- the topmost form can have fields of its own --%>

    <mak:addForm object="bla" field="bla" >
        <%-- we have a nested forms here --%>
        <mak:input name="second" />

    <mak:list from="blo.bla bla"> 
        <%-- We can add forms repeatedly in loops / mak:list --%>
        <mak:addForm object="bla" field="bli" >
            <%-- note that we can't define an action here, it's the action of the topmost form --%>
            <%-- a normal on_add BL method will be called --%>
            <mak:input name="second" />

    <mak:list .... > 
        <%-- there can be more than one loop in a root form -- %>
    <input type="submit"> <%-- it's easy to add a submit button anywhere --%>

Having an <mak:addForm> inside a <mak:newForm>#

To insert to a set of an object being created, use code similar to the following

<mak:newForm type="bla.Bla" name="b" method="post" action="page.jsp">

    <%-- a regular textfield inside bla.Bla --%>
    <mak:input name="textField" /><br/>
    <%-- object="b" refers to the name given to the newForm --%>
    <mak:addForm object="b" field="setOfThings" />
        <%-- these are all fields of the set entry which will be created on submit --%>
        <mak:input name="fieldInsideTheSet" /><br/> 
        <mak:input name="anotherFieldInsideTheSet" /><br/>
    <input type="submit" value="submit" /> <%-- a regular submit button --%>


Having an <mak:newForm> inside a <mak:newForm>#

To insert two objects at the same time, where one refers to the other, use code similar to the following

<mak:newForm type="company.Company" name="company" action="companyList.jsp" method="post">
    <%-- a regular text field inside company.Company --%>
    Name: <mak:input name="name"/><br/>
    <mak:newForm type="Department">
        <%-- a regular text field inside company.Department --%>
        Department name: <mak:input name="name"/><br/>
        <%-- setting the reference to the newly created company --%>
        <%-- the attribute values of value=".." and name=".." of the outer newForm must be the same--%>
        <mak:input name="company" value="company" type="hidden"/>
    <input type="submit" value="submit" /> <%-- a regular submit button --%>


Category Usage

Add Comment
« This page was last updated on March 10 2011