follow all "significant" code...






--> Here goes the HTML:



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">



<html>

<head>REMOVED </head>



<body>

            <div id="globalContainer" class="globalBodyContainer">

            <input id="previousTRId" type="hidden" value=""/>

            <input id="previousDataId" type="hidden" value=""/>



            <!--Hidden filds for translate Menus from PopUp Boxes, get values 
from wicket properties files.-->



            <!-- Copy Box -->

            <input id="copyHeader" type="hidden" 
wicket:message="value:copyFieldHeader"/>

            <input id="copyBody" type="hidden" 
wicket:message="value:copyFieldBody"/>



            <!-- Header for all Alert Box -->

            <input id="labelHeader" type="hidden" 
wicket:message="value:labelFieldHeader"/>



            <!-- Delete Box -->

            <input id="deleteBody" type="hidden" 
wicket:message="value:deleteFieldBody"/>



            <!-- Active Box -->

            <input id="activeBody" type="hidden" 
wicket:message="value:activeFieldBody"/>



            <!-- DeActive Box -->

            <input id="deactiveBody" type="hidden" 
wicket:message="value:deactiveFieldBody"/>



            <form wicket:id="hiddenFieldsForm" id="hiddenFieldsForm">

                  <input wicket:id="hiddenFieldsForm.copyName" type="hidden"/> 
<!--Copy Name-->

                  <input wicket:id="hiddenFieldsForm.operationName" 
type="hidden"/> <!--Operation -->

                  <input wicket:id="hiddenFieldsForm.dataBaseID" 
type="hidden"/> <!--Get data base ID for active, deactive, delete and copy -->

                  </form>



                  <!-- Title -->

                  <div id="pageTitle" class="pageTitle"><wicket:message 
key="tittle">Trade Coverage Plan - Initial Screen</wicket:message></div>



                  <div class="separator"></div>



                  <!-- Upper button panel -->

               <form wicket:id="tcp.menuForm">

                        <fieldset id="Fieldset2" class="searchFilterPanel">

                            <legend><wicket:message 
key="fieldCommands">Commands</wicket:message></legend>

                            <div id="buttonPanel">

                           <div class="buttonPanelElement">

                               <button wicket:id="tcp.menuForm.newButton" 
type="button" class="short">

                                    <wicket:message 
key="buttonNew">New</wicket:message>

                               </button>

                           </div>

                           <div class="buttonPanelElement">

                           <button wicket:id="tcp.menuForm.openButton" 
id="openButton" type="button" class="short"  
onclick="callConfirmBox('labelHeader','deleteBody','open');" disabled>

                                 <wicket:message 
key="buttonOpen">Open</wicket:message>

                           </button>

                           </div>

                           <div class="buttonPanelElement">

                              <button id="deleteButton" 
wicket:id="tcp.menuForm.deleteButton" type="button" class="short"  
onclick="callConfirmBox('labelHeader','deleteBody','delete');" disabled>

                                    <wicket:message 
key="buttonDelete">Delete</wicket:message>

                              </button>

                           </div>



                           <div class="buttonPanelElement">

                                 <div wicket:id="modal1"></div>

                                 <a wicket:id="showModal1">

                               <!--<button id="activateButton" 
wicket:id="tcp.menuForm.activeButton" type="button" class="short"  
onclick="callConfirmBox('labelHeader','activeBody','active');" disabled>-->

                               <button id="activateButton" 
wicket:id="tcp.menuForm.activeButton" type="button" class="short" disabled>

                                    <wicket:message 
key="buttonActivate">Activate</wicket:message>

                               </button>

                                     </a>

                           </div>

                            <div class="buttonPanelElement">

                                <button id="deactivateButton" 
wicket:id="tcp.menuForm.deActiveButton" type="button" class="short"  
onclick="callConfirmBox('labelHeader','deactiveBody','deactive');" disabled>

                                    <wicket:message 
key="buttonDeactivate">Deactivate</wicket:message>

                                </button>

                            </div>



                           <div class="rightButtonPanelElement" 
id="copyToField" style="width: 251px">

                               <!--<wicket:message key="labelCopyTo">Copy 
to</wicket:message>&nbsp;-->

                              <!--<input type="text" id="tcp_copyto" value="" 
style="width: 100px" onclick="this.value='';"/>&nbsp-->

                              <button type="button" class="short" 
id="executeButton" onclick="callCopyBox('copyHeader','copyBody','copy');" 
disabled>

                                    <wicket:message 
key="buttonCopy">Copy</wicket:message>

                              </button>

                           </div>

                            </div>

                        </fieldset>

                  </form>

                  <!--  <div class="separator"></div>-->



                  <!--  Form wicket tcp.searchForm -->

                  <form wicket:id="tcp.searchForm">

                        <!-- "Search TCPs" panel -->

                        <fieldset id="searchFilterPanel" 
class="searchFilterPanel" style="height: 100%">

                            <legend><wicket:message key="fieldSearch">Search 
TCPs</wicket:message></legend>



                       <div style="float:left; width: 100%; height: 51px;">

                           <div class="searchFilterPanelElement" style="width: 
120px">

                              <wicket:message 
key="labelYear">Year</wicket:message>&nbsp;

                              <select wicket:id="tcp.searchForm.yearSelect" 
name="year" style="width: 80px">

                                   <option selected="selected" 
value="0"></option>

                                   <option value="1">2008</option>

                                   <option value="2">2007</option>

                                   <option value="3">2006</option>

                                   <option value="4">2005</option>

                                   <option value="5">2004</option>

                                   <option value="6">2003</option>

                               </select>

                           </div>



                           <div class="searchFilterPanelElement" style="width: 
196px; ">

                              <wicket:message 
key="labelName">Name</wicket:message>&nbsp;

                              <input wicket:id="tcp.searchForm.nameText" 
type="text" name="name" value="Enter Text" style="width: 140px" 
onclick="this.value='';"/>

                           </div>



                           <div class="searchFilterPanelElement" style="width: 
200px">

                              <wicket:message 
key="labelDivision">Division</wicket:message>&nbsp;

                              <select wicket:id="tcp.searchForm.divisionSelect" 
name="division" style="width: 130px">

                                              <option value="0"></option>

                                              <option value="1">São 
Paulo</option>

                                              <option value="2">Rio de 
Janeiro</option>

                                              <option value="3">Santos</option>

                              </select>

                           </div>



                           <div style="float:right; width: 240px; height: 
51px;" class="rightSearchFilterPanelElement">

                              <wicket:message 
key="labelStatus">Status</wicket:message>&nbsp;

                              <select wicket:id="tcp.searchForm.statusSelect" 
name="status" style="width: 100px">

                                              <option value="0"></option>

                                              <option value="1">Active</option>

                                              <option 
value="2">Inactive</option>

                              </select>&nbsp;



                           </div>

                       </div>



                       <div style="float:left; width: 100%; height: 51px;">

                           <div style="float:left; width: 506px; height: 51px;" 
class="buttonPanelElementLarge">

                              <wicket:message key="labelTradeApproach">Trade 
Approach</wicket:message>&nbsp

                              <select wicket:id="tcp.searchForm.tradeApproach" 
name="tradeApproach" style="width: 170px">

                                              <option value="0"></option>

                                              <option 
value="1">Pre-Sales</option>

                                              <option 
value="2">Prompt-Sales</option>

                                              <option 
value="2">Tele-Sales</option>

                              </select>&nbsp;



                              <button wicket:id="tcp.searchForm.find" 
id="findButton" class="short" type="button">

                                  <wicket:message 
key="buttonFind">Find</wicket:message>

                              </button>



                           </div>

                       </div>

                        </fieldset>

                  </form>



                  <!--  <div class="separator"></div>-->



                  <!-- Result grid -->

                  <div>

                  <fieldset id="Fieldset1" class="searchFilterPanel">

                      <legend><wicket:message key="fieldList">List 
TCPs</wicket:message></legend>

                         <div class="resultGrid">

                               <table id="tcpTable" class="resultGridTable" >

                                          <!-- Result grid header -->

                                          <tr class="resultGridHeader">

                                                      <td 
class="resultGridHeader" style="height: 18px; width: 107px;"><wicket:message 
key="gridYear">Year</wicket:message></td>

                                                      <td 
class="resultGridHeader" style="height: 18px; width: 331px;"><wicket:message 
key="gridName">Name</wicket:message></td>

                                                      <td 
class="resultGridHeader" style="height: 18px; width: 270px;"><wicket:message 
key="gridDivision">Division</wicket:message></td>

                                                      <td 
class="resultGridHeader" style="height: 18px; width: 101px;"><wicket:message 
key="gridStatus">Status</wicket:message></td>

                                                      <td 
class="resultGridHeader" style="height: 18px; width: 270px;"><wicket:message 
key="gridTradeApproach">Trade Approach</wicket:message></td>

                                          </tr>

                                          <tr wicket:id="tcp.ResultGrid" 
class="resultGridData" onmouseover="setStyle(this, 'highlight');" 
onmouseout="setStyle(this, 'resultGridData');">

                                                      <td 
class="resultGridData" style="width: 107px"><span 
wicket:id="tcp.ResultGrid.Year">2008</span></td>

                                                      <td 
class="resultGridData" style="width: 331px"><span 
wicket:id="tcp.ResultGrid.Name" >Plan Classe B</span></td>

                                                      <td 
class="resultGridData" style="width: 270px"><span 
wicket:id="tcp.ResultGrid.Division">São Paulo</span></td>

                                                      <td 
class="resultGridData" style="width: 101px"><span 
wicket:id="tcp.ResultGrid.Status">Active</span></td>

                                                      <td 
class="resultGridData" style="width: 270px"><span 
wicket:id="tcp.ResultGrid.TradeAprroach">Pre-Sales</span></td>

                                          </tr>

                               </table>

                         </div>

            </fieldset>

                  </div>

            </div>

<script type="text/javascript">

    document.getElementById("newButton").focus();

</script>

</body>

</html>







--> Here goes the JAVA CODE:



import java.util.ArrayList;

import java.util.Date;

import java.util.HashMap;

import java.util.List;

import java.util.Map;



import org.apache.wicket.AttributeModifier;

import org.apache.wicket.Page;

import org.apache.wicket.ajax.AjaxRequestTarget;

import org.apache.wicket.ajax.markup.html.AjaxLink;

import org.apache.wicket.behavior.AttributeAppender;

import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;

import org.apache.wicket.markup.html.basic.Label;

import org.apache.wicket.markup.html.form.Button;

import org.apache.wicket.markup.html.form.DropDownChoice;

import org.apache.wicket.markup.html.form.Form;

import org.apache.wicket.markup.html.form.HiddenField;

import org.apache.wicket.markup.html.form.IChoiceRenderer;

import org.apache.wicket.markup.html.form.TextField;

import org.apache.wicket.markup.html.list.ListItem;

import org.apache.wicket.markup.html.list.ListView;

import org.apache.wicket.model.Model;

import org.apache.wicket.model.PropertyModel;

import org.apache.wicket.spring.injection.annot.SpringBean;





public class TCPInitialScreen extends BaseWebPage{



      //Service

      @SpringBean(name="StatusBean")

      private IStatusBusinessService searchStatusBusinessService;



      @SpringBean(name="DivisionBean")

      private IDivisionBusinessService searchDivisionBusinessService;



      @SpringBean(name="TCPBean")

      private ITCPBusinessService tcpBusinessService;



      @SpringBean(name="TradeApproachBean")

      private ITradeApproachBusinessService tradeApproachBusinessService; 
//Todos os trade approachs



      //Objects TO



      private TCPBasicDataTO tcpSearch = new TCPBasicDataTO();



      //Wicket



      Model<StatusTO> statusModel = new Model<StatusTO>();

      Model<DivisionTO> divisionModel = new Model<DivisionTO>();

      Model<TradeApproachTO> tradeAppModel = new Model<TradeApproachTO>();



      //Atributes



      int lineIndexDataGrid =0;

      private Map<Integer, StatusTO> statusDescriptionMap = new 
HashMap<Integer, StatusTO>();



      public TCPInitialScreen(){



            createMenuForm();

            createSearchForm();

            createHiddenForm();



            // Searches all TCP's and displays them in the initial screen

            TCPSearchCriteriaTO searchCriteria = new TCPSearchCriteriaTO();

            List<TCPBasicDataTO> allTCPList = 
tcpBusinessService.searchTCPByCriteria(searchCriteria);

            createDataGrid(allTCPList);

      }



      @SuppressWarnings({ "unchecked", "serial" })

      protected void createMenuForm(){

            /*

             * Menu Form

             */

            Form menuForm = new Form("tcp.menuForm");

            add(menuForm);



            Button newButton = 
TCPComponentFactory.createButton(TCPComponentFactory.NEW_BUTTON, 
"tcp.menuForm.newButton", "newButton");



            newButton.add(new AttributeAppender("onclick", new 
Model("loadBodyFromLeftMenu('iframeBody', 
'?wicket:bookmarkablePage=:com.bat.planning.presentation.tcp.web.TCPBasicDataScreen');"),
 ";"));

            menuForm.add(newButton);



            //Open

            Button openButton = new Button("tcp.menuForm.openButton"){

                  public void onSubmit() {

                        //TODO : Check how to get the selected product and open 
into BCPBasicDataPage

                  }

            };

            openButton.add(new AttributeModifier("id", new 
Model("openButton")));

            menuForm.add(openButton);



            //Delete

            Button deleteButton = new Button("tcp.menuForm.deleteButton"){

                  public void onSubmit() {

                        //TODO : Check how to get the selected product and open 
into BCPBasicDataPage

                  }

            };

            deleteButton.add(new AttributeModifier("id", new 
Model("deleteButton")));

            menuForm.add(deleteButton);



            /*

             *

             */



            //Modal Active



            final ModalWindow modal1 = new ModalWindow("modal1");



            /*

             * Gera Modal window

             */

        modal1.setPageCreator(new ModalWindow.PageCreator()

        {

            public Page createPage()

            {

                return new TCPActiveScreen(TCPInitialScreen.this, modal1);

            }

        });

        menuForm.add(modal1);



            AjaxLink activeLink = (new AjaxLink("showModal1"){



                  @Override

                  public void onClick(AjaxRequestTarget target) {

                        modal1.setInitialHeight(280);

                        modal1.setInitialWidth(330);

                        //modal1.set

                        modal1.show(target);

                  }



            });

            menuForm.add(activeLink);



            /*

             *

             */



            //Active

            Button activeButton = new Button("tcp.menuForm.activeButton"){

                  public void onSubmit() {

                        //TODO : Check how to get the selected product and open 
into BCPBasicDataPage

                  }

            };

            activeButton.add(new AttributeModifier("id", new 
Model("activateButton")));

            //menuForm.add(activeButton);

            activeLink.add(activeButton);



            //Deactive

            Button deActiveButton = new Button("tcp.menuForm.deActiveButton"){

                  public void onSubmit() {

                        //TODO : Check how to get the selected product and open 
into BCPBasicDataPage

                  }

            };

            deActiveButton.add(new AttributeModifier("id", new 
Model("deactivateButton")));

            menuForm.add(deActiveButton);



      }



      @SuppressWarnings({ "serial", "unchecked" })

      private void createSearchForm() {

            /*

             *  Search Form

             */

            Form searchForm = new Form("tcp.searchForm"){

                  protected void onSubmit(){





                        //Search Service call



                        //Clear all values of comboBox, get default choice again

                        divisionModel = new Model<DivisionTO>();

                        statusModel = new Model<StatusTO>();

                        tradeAppModel = new Model<TradeApproachTO>();

                        createSearchForm();

                  }

            };

            searchForm.add(new AttributeModifier("id", new 
Model("tcp.searchForm")));



            List<String> yearsFake = new ArrayList<String>();

            yearsFake.add("1");



            List<Integer> tcpYearCombo = 
tcpBusinessService.searchTCPYears(yearsFake);



            //Year

            DropDownChoice<Integer> yearDropDown = new 
DropDownChoice<Integer>("tcp.searchForm.yearSelect", new 
PropertyModel<Integer>(tcpSearch, "tcpYear"),tcpYearCombo);



            //Name

            TextField nameField = new TextField("tcp.searchForm.nameText", new 
PropertyModel(tcpSearch, "tcpName"));



            //Division

            IChoiceRenderer<DivisionTO> choiceRendererDivision = new 
IChoiceRenderer<DivisionTO>() {

                  public String getIdValue(DivisionTO division, int index) {

                        return division.getDivisionId().toString();

                  }



                  public Object getDisplayValue(DivisionTO division) {

                        return division.getDivisionName();

                  }

            };



            DropDownChoice divisionDropDown = new DropDownChoice 
("tcp.searchForm.divisionSelect", divisionModel, 
searchDivisionBusinessService.searchDivisions(), choiceRendererDivision);



            //Status

            String languageId = getLocalizer().getString("languageId", this);



            if (languageId == null){

                  languageId = "1";

            }



            List<StatusTO> statusList = 
searchStatusBusinessService.searchStatus(Integer.parseInt(languageId));

            for(StatusTO status: statusList)

            {

                  statusDescriptionMap.put(status.getStatusId(), status);

            }



            IChoiceRenderer<StatusTO> choiceRendererStatus = new 
IChoiceRenderer<StatusTO>(){

                  public String getIdValue(StatusTO status, int index) {

                        return Integer.toString(status.getStatusId());

                  }



                  public Object getDisplayValue(StatusTO status) {

                        return status.getStatusDescription();

                  }

            };



            DropDownChoice<StatusTO> statusDropDown = new 
DropDownChoice<StatusTO>("tcp.searchForm.statusSelect", statusModel, 
statusList, choiceRendererStatus);



            //Trade Approach

            List<TradeApproachTO> tcpTradeApproachesList = 
tradeApproachBusinessService.searchAllAvailableTradeApproach();



            IChoiceRenderer<TradeApproachTO> choiceRenderTradeApp = new 
IChoiceRenderer<TradeApproachTO>(){

                  public String getIdValue(TradeApproachTO tradeApproach, int 
index){

                        return 
Integer.toString(tradeApproach.getTradeApproachId());

                  }



                  public Object getDisplayValue(TradeApproachTO tradeApproach){

                        return tradeApproach.getTradeApproachName();

                  }

            };



            DropDownChoice<TradeApproachTO> tradeApproachDropDown = new 
DropDownChoice<TradeApproachTO>("tcp.searchForm.tradeApproach", tradeAppModel, 
tcpTradeApproachesList, choiceRenderTradeApp);



            tcpSearch.setTcpYear(null);

            tcpSearch.setDivisionName(null);

            tcpSearch.setDivisionId(null);

            tcpSearch.setStatus(null);



            searchForm.add(yearDropDown);

            searchForm.add(nameField);

            searchForm.add(divisionDropDown);

            searchForm.add(statusDropDown);

            searchForm.add(tradeApproachDropDown);



            Button findButton = new Button("tcp.searchForm.find") {

                  public void onSubmit() {



                  }

            };

            findButton.add(new AttributeAppender("onclick", new 
Model("submitForms('tcp.searchForm');"), ";"));

            searchForm.add(findButton);



            remove(searchForm);

            add(searchForm);

      }



}






Reply via email to