I have created a listView with method populateList, that fills a list
of customers meetings with the respective manager responsible for each
line according the figure bellow:

Begin                   End                  Manager  Detail  Total
       Actions
21/04/2013 09:52:41     21/04/2013 10:05:21  ------V  ______  00:12:40
       Edit
21/04/2013 10:05:38     21/04/2013 10:05:41  ------V  ______  00:00:03
       Edit
21/04/2013 10:36:06     21/04/2013 10:36:09  ------V  ______  00:00:03
       Edit
                                              TOTAL   -----   00:12:46

Obs: I'm using scala :-D


Two problems here:

 1. When a new new item is created, only the fields (labels) dateBegin and
    dateEnd are preserved with previous assigned values, I lost the
    values of **Manager** *DropDownChoice* and the **Detail**
    *TextField* in last line of the ListItem.
 2. **After change** the *DropDownChoice* of after exit from the
*Detail TextField* is needed *update the model* with the respective
value have chosen from each filed.

So the values are kept only for labels, in truth links. Let me show the code:


    add(new ListView[Meetings]("listMeetings", listData) {
      override protected def onBeforeRender() {
      periodTotal = new Period()
      super.onBeforeRender()
    }

    // for populating the listView
    def populateItem(item: ListItem[customer]) = {
        var customer = item.getModelObject()

        item.add(new LinkDate("beginDate", customer))
        item.add(new LinkDate("endDate", customer))

        val listManagers: java.util.List[Manager] = managerDAO.listManagers
        item.add(new DropDownChoice("managerSelection",
listManagers,new ChoiceRenderer[Manager]("name")))

        item.add(new TextField("detail"))

        /*
         * I tried to use the code bellow but it's cause a markups errors too.
         * Only the code above display the components without errors.
         */
        //val managerSelection = new LinkManager("managerSelection",customer)
        //item.add(managerSelection)
        //item.add(new LinkDetail("detail",  customer))

        var period = new Period(customer.beginDate, customer.endDate.get)
        item.add(new Label("total", period.toString(getFormatter())))

        item.add(new LinkEdit("edit", customer))
    }})

The functions bellow work fine for date value and for edit a
respective fields of the line:

    private class LinkDate(id: String, customer: Customer) extends
Link[String](id) {

        setEnabled(false)
        add(new Label("label", new Model[String]() {
          override def getObject(): String = {
            var result = ""
            if (id == "beginDate") {
              result = customer.beginDate.toString("dd/MM/YYYY HH:mm:ss")
            }
            if (id == "endDate") {
              result = customer.endDate.get.toString("dd/MM/YYYY HH:mm:ss")
            }
            return result
          }
        }))
         // ... doing other stuff
      }

      private class LinkEdit(id: String, customer: Customer) extends
Link[String](id) {

        add(new Label("label", new Model[String]() {
          override def getObject: String = "edit"
        }));
        // ... doing other stuff
      }

 But for DropDown and TextField I tried to do the same and I failed strongly:

      // Doesn't work
      private class LinkManager(id: String, customer: Customer)
extends Link[String](id) {

        val listManagers: java.util.List[Manager] = managerDAO.listManagers
        add(new DropDownChoice("managerSelection", listManagers,new
ChoiceRenderer[Manager]("name") {

          def wantOnSelectionChangedNotifications() = {
            true;
          }
          def onSelectionChanged(managerSelection: Manager): String = {
            // saving model
            })
          }
        }))

        // ... doing other stuff
      }

      // Doesn't work
      // Also here I tried to change textFiled for a inline-ajax Editable label
      // And I need the behaviour to change model imadiately after change value
      private class LinkDetail(id: String, customer: Customer) extends
Link[String](id) {

        add(new AjaxEditableLabel("detail", new Model[String]() {
          override def getObject(): String = {
            // ... doing other stuff
          }
        }))
      }

The piece of corresponding markup is shoewd bellow:

    <TR wicket:id="listCustomersMettings">
      <TD><a wicket:id="beginDate"><span wicket:id="label"></span></a></TD>
      <TD><a wicket:id="endDate"><span wicket:id="label"></span></a></TD>
      <TD>
          <SELECT wicket:id="managerSelection" name="id"></SELECT>
          <BR>
      </TD>

      <TD><INPUT wicket:id="detail" type="text" name="obs" value="_"/></TD>

      <TD wicket:id="total"></TD>

      <TD><a wicket:id="edit"><span wicket:id="label"
style="text-align: center"></span></a></TD>

    </TR>


I think that is needed a Object, similar to LinkDate, to deal and
store the values for Manager DropDownChoice and for the textField or
AjaxEditableLabel Detail, but I got in trouble to implement them.

Thanks for someone that could help me or give me information about.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to