thanks very much for your help Sven

Bruno Moura


2013/5/5 Sven Meier <[email protected]>

> I'm not fluent in Scala but it seems you're adding additional components
> without reason:
>
>
>  private class TextDesc(id: String, workSheet: WorkSheet)
>>  extends TextField[String](id) {
>>    add(new TextField("textField", new Model[String]() {
>>
>
> TextDesc *is* a textfield, why are you adding another textfield to it?
>
>  private class DropDownChoiceCustomer(id: String, listCustomer:
>> List[Customer], workSheet: WorkSheet)
>>
>>  extends DropDownChoice[String](id) {
>>    add(new DropDownChoice("**customerSelection", listCustomer,
>>      new ChoiceRenderer[Customer]("**name")) {
>>
>
> DropDownChoiceCustomer *is* a dropdownchoice already, why are you adding
> another one to it?
>
> Regards
> Sven
>
>
>
> On 05/05/2013 02:26 AM, Bruno Moura wrote:
>
>> I need to add components in a listView and associate all of them with a
>> model,for allow keep the state of each object saved in this listView. I'm
>> using wicket 1.4 with scala.
>> The code is showed bellow, isn't a short piece of code but I tried to keep
>> it simple as possible
>>
>>
>> add(new ListView[WorkSheet]("**listWorkSheet", listData) {
>>
>>      override protected def onBeforeRender() {
>>        super.onBeforeRender()
>>      }
>>
>>      def populateItem(item: ListItem[WorkSheet]) = {
>>        var workSheet = item.getModelObject()
>>
>>        // Render normally
>>        item.add(new LinkDate("initDate", workSheet, 1))
>>
>>        // render normally
>>        item.add(new TextField("description"))
>>        // error on Render Page
>>        item.add(new TextDesc("description", workSheet))
>>
>>        val listCustomer: java.util.List[Customer] =
>> customerDAO.listCustomers
>>
>>        // render normally
>>        item.add(new DropDownChoice("**customerSelection", listCustomer,
>> new
>> ChoiceRenderer[Customer]("**name")))
>>        // error on Render Page
>>        item.add(new DropDownChoiceCustomer("**customerSelection",
>> listCustomer, workSheet))
>>
>> }
>>
>> // Render normally, works
>> private class LinkDate(id: String, workSheet: WorkSheet, type: Int)
>> extends
>> Link[String](id) {
>>
>>    setEnabled(false)
>>    add(new Label("label", new Model[String]() {
>>      override def getObject(): String = {
>>        var result = ""
>>        if (type == 1) {
>>            result = workSheet.initDate.toString("**dd/MM/YYYY HH:mm:ss")
>>        }
>>        return result
>>      }
>>    }))
>>
>>    def onClick() {}
>> }
>>
>> // doesn't work
>> private class TextDesc(id: String, workSheet: WorkSheet) extends
>> TextField[String](id) {
>>
>>    add(new TextField("textField", new Model[String]() {
>>      override def getObject(): String = {
>>        var result = ""
>>        if (result.length != 0) {
>>            result = workSheet.description
>>        }
>>        return result
>>      }
>>    }))
>> }
>>
>> // doesn't work
>> private class DropDownChoiceCustomer(id: String, listCustomer:
>> java.util.List[Customer], workSheet: WorkSheet) extends
>> DropDownChoice[String](id) {
>>
>>      add(new DropDownChoice("**customerSelection", listCustomer, new
>> ChoiceRenderer[Customer]("**name")) {
>>        protected override def wantOnSelectionChangedNotifica**tions:
>> Boolean =
>> {
>>          true
>>        }
>>        protected override def onSelectionChanged(**customerSelection:
>> Customer) {
>>          System.out.println("selected: " + customerSelection.id)
>>        }
>>      })
>> }
>>
>> // I got the error messages bellow
>>
>> WicketMessage: The component(s) below failed to render. A common problem
>> is
>> that you have added a component in code but forgot to reference it in the
>> markup (thus the component will never be rendered).
>>
>> 1. [MarkupContainer [Component id = textField]]
>> 2. [MarkupContainer [Component id = textField]]
>>
>> Root cause:
>>
>> org.apache.wicket.**WicketRuntimeException: The component(s) below
>> failed to
>> render. A common problem is that you have added a component in code but
>> forgot to reference it in the markup (thus the component will never be
>> rendered).
>>
>> 1. [MarkupContainer [Component id = textField]]
>> 2. [MarkupContainer [Component id = textField]]
>>
>> at org.apache.wicket.Page.**checkRendering(Page.java:1201)
>> at org.apache.wicket.Page.**renderPage(Page.java:941)
>> at
>> org.apache.wicket.protocol.**http.WebRequestCycle.**
>> redirectTo(WebRequestCycle.**java:201)
>>
>>
>> WicketMessage: The component(s) below failed to render. A common problem
>> is
>> that you have added a component in code but forgot to reference it in the
>> markup (thus the component will never be rendered).
>>
>> 1. [MarkupContainer [Component id = customerSelection]]
>> 2. [MarkupContainer [Component id = customerSelection]]
>>
>> Root cause:
>>
>> org.apache.wicket.**WicketRuntimeException: The component(s) below
>> failed to
>> render. A common problem is that you have added a component in code but
>> forgot to reference it in the markup (thus the component will never be
>> rendered).
>>
>> 1. [MarkupContainer [Component id = customerSelection]]
>> 2. [MarkupContainer [Component id = customerSelection]]
>>
>>
>> // the markup
>>
>> <TD>
>>     <SELECT wicket:id="customerSelection" name="id"></SELECT>
>> </TD>
>> <TD><INPUT wicket:id="description" type="text" name="obs" value="_"/></TD>
>>
>> If someone could help me I'll appreciate, thanks.
>>
>> Bera
>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: 
> users-unsubscribe@wicket.**apache.org<[email protected]>
> For additional commands, e-mail: [email protected]
>
>

Reply via email to