Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added syntax highlighter for code block.

...

1.) Add two Freemarker files at location $ OFBIZ_HOME/plugins/ofbizDemo/webapp/ofbizDemo/crud/AddOfbizDemo.ftl and ListOfbizDemo.ftl, as shown below:


...

Code Block
languagexml
titleAddOfbizDemo.ftl

 

<div class="screenlet-body">

...


  <form id="createOfbizDemoEvent" method="post" action="<@ofbizUrl>createOfbizDemoEvent</@ofbizUrl>">

...


    <input type="hidden" name="addOfbizDemoFromFtl" value="Y"/>

...

    <fieldset>
      <div>

...


    <fieldset>
      <div>
        <span class="label">${uiLabelMap.OfbizDemoType}</

...

span>
        <select name="ofbizDemoTypeId" class='required'>

...

          <#list ofbizDemoTypes as demoType>

...


          <#list ofbizDemoTypes as demoType>
            <option value='${demoType.ofbizDemoTypeId}'>${demoType.description}</

...

          </#list>
        </select>*
      </div>
      <div>

...

option>
          </#list>
        </select>*
      </div>
      <div>
        <span class="label">${uiLabelMap.OfbizDemoFirstName}</

...

span>
        <input type="text" name="firstName" id="firstName" class='required' maxlength="20" />*

...

      </div>
      <div>

...


      </div>
      <div>
        <span class="label">${uiLabelMap.OfbizDemoLastName}</

...

span>
        <input type="text" name="lastName" id="lastName" class='required' maxlength="20" />*

...

      </div>
      <div>

...


      </div>
      <div>
        <span class="label">${uiLabelMap.OfbizDemoComment}</

...

span>
        <input type="text" name="comments" id="comments" class='inputBox' size="60" maxlength="255" />

...

      </div>
    </fieldset>

...


      </div>
    </fieldset>
    <input type="submit" value="${uiLabelMap.CommonAdd}" />

...


  </

...

form>
</div>

 

div>

 

Code Block
languagexml
titleListOfbizDemo.ftl

 

 <div
<div class="screenlet-body">
  <#if

  <#if ofbizDemoList?has_content>
    <table

    <table cellspacing=0 cellpadding=2 border=0 class="basic-table
">
      <thead><tr>
        
">
      <thead><tr>
        <th>${uiLabelMap.OfbizDemoId}</th>
        

        <th>${uiLabelMap.OfbizDemoType}</th>
        

        <th>${uiLabelMap.OfbizDemoFirstName}</th>
        

        <th>${uiLabelMap.OfbizDemoLastName}</th>
        

        <th>${uiLabelMap.OfbizDemoComment}</th>
      

      </tr></thead>
      <tbody>
        <#list ofbizDemoList as ofbizDemo>
          <tr>
            

      <tbody>
        <#list ofbizDemoList as ofbizDemo>
          <tr>
            <td>${ofbizDemo.ofbizDemoId}</
td>            
td>
            <td>${ofbizDemo.getRelatedOne("OfbizDemoType").get("description", locale)}</td>
            

            <td>${ofbizDemo.firstName?default("NA")}</td>
            

            <td>${ofbizDemo.lastName?default("NA")}</td>
            

            <td>${ofbizDemo.comments!}</td>
          

          </tr>
        

        </#list>
       

       </tbody>
    

    </table>
  

  </
#if>
#if>
</div>

 

2.) Add new Groovy file for data fetching logic at location $ OFBIZ_HOME/plugins/ofbizDemo/webapp/ofbizDemo/WEB-INF/actions/crud/ListOfbizDemo.groovy and add code as shown to list out OfbizDemo records:

 

Code Block
languagegroovy
ofbizDemoTypes = delegator.findList("OfbizDemoType", null, null, null, null, false);

context.ofbizDemoTypes = ofbizDemoTypes;

ofbizDemoList = delegator.findList("OfbizDemo", null, null, null, null, false);

context.ofbizDemoList = ofbizDemoList;

 

3.) Add new screen file with Ofbiz default decorator to OfbizDemoScreens.xml with newly added freemarker and groovy files as:

...