Re: Wicket MarkupContainer error, the component failed to render

2013-05-05 Thread Sven Meier

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/ 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 wantOnSelectionChangedNotifications: 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
TDINPUT wicket:id=description type=text name=obs value=_//TD

If someone could help me I'll appreciate, thanks.

Bera




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

Change signature of AbstractTree or Model.ofSet

2013-05-05 Thread Илья Нарыжный
Hello,

I have following problem in wicket 6 with trees:
Constructor of
class org.apache.wicket.extensions.markup.html.repeater.tree.AbstractTree
have following signature:
protected AbstractTree(String id, ITreeProviderT provider, IModelSetT
state)
The problem is in IModelSetT state argument and fact that Model.ofSet
return IModelSet? extends C, so it's not possible directly pass
IModelSet? extends C to constructor. It seems that either Model.ofSet
should be changed or AbstractTree.

What do you think?

Regards,

Ilia


Popup window ( user notification window) after Form submission.

2013-05-05 Thread mayanksahai
Hi all ,i am new to wicket and taking panel based approach to build out
Pages. in my application there is main page that contains multiple panels.in
panel one i have a user registration form. once user submits this form i
want to launch a window/popup (confirming to user that he is registered
successfully or not) , once he closes down that window same panel gets
refreshed , all inputs are cleared.is there a better alternative to this ?.
i tried searching for solution over the web could not find it checked out
code for modalwindow also but all examples points its usage with ajax
only.right now i am refreshing the fullpage by setting setResponsePage() , i
dnt think its right approach.thanksmayank sahai



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Popup-window-user-notification-window-after-Form-submission-tp4658554.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Get the selected item in the DropDownChoice using Scala

2013-05-05 Thread Bruno Moura
How can I get the selected item form a DropDownChoice inside an ListView?

I implemented the chunky code bellow:

val listCustomer: java.util.List[Customer] = customerDAO.listCustomers

item.add(new DropDownChoice(customerSelection, listCustomer, new
ChoiceRenderer[Customer](name)))

In this case I want to get the name property displayed of the model
Customer.

Thanks



Bera


Wicket - get the value of a textbox using scala

2013-05-05 Thread Bruno Moura
I'm trying to retrieve a value of a TextField as is showed bellow:

item.add(new TextField(description, new Model[String]() {
override def getObject(): String = {
customer.description = ??? // I don't know how I can get the
value here
return ...
}
}))

I have this TextField inserted in a ListView and I need to use the
TextField value to set it in a property model.

Thanks

Bera


Keep the state or value of a DropDownChoice and TextField both inside a ListView

2013-05-05 Thread Bruno Moura
I have implemented a listView and every time that a new item is added in
this ListView the values inserted in the textField and selected in a
DropDownChoice are lost.

The following pictures show what's happen before and after add a new
ListView item:

[image: Imagem inline 1]

And after Add a new item:

[image: Imagem inline 1]

I'm implemented the code bellow:




  var listData = workSheetDAO.listWorkSheetUser(selectedUser,
beginDate, endDate)

  var lbPeriodTotal = new Label(periodTotal)
  lbPeriodTotal.setOutputMarkupId(true)
  add(lbPeriodTotal)

  add(new ListView[WorkSheet](listWorkSheet, listData) {

override protected def onBeforeRender() {
  super.onBeforeRender()
}

def populateItem(item: ListItem[WorkSheet]) = {
  var workSheet = item.getModelObject()

  item.add(new LinkDate(initDate, workSheet, 1))
  item.add(new LinkDate(endDate, workSheet, 1))

  item.add(new TextField(description))

  val listCustomer: java.util.List[Customer] =
customerDAO.listCustomers

  item.add(new DropDownChoice(customerSelection, listCustomer,
new ChoiceRenderer[Customer](id)))

  if (workSheet.endDate == None) {
item.add(new Label(total, ))
  } else {
var period = new Period(workSheet.initDate,
workSheet.endDate.get)
periodTotal = periodTotal.plus(period)
lbPeriodTotal.setDefaultModel(new
Model(periodTotal.toPeriod().normalizedStandard().toString(getFormatter(
period = period.normalizedStandard()
item.add(new Label(total, period.toString(getFormatter(
  }

   }
}

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/ HH:mm:ss)
  } else
  result = workSheet.endDate.toString(dd/MM/ HH:mm:ss)
  return result
}
  }))

  def onClick() {}
}


The only values preserved are the values of the labels.

Please, someone could help me, thanks



Bera


Re: Keep the state or value of a DropDownChoice and TextField both inside a ListView

2013-05-05 Thread Ernesto Reinaldo Barreiro
From javadoc of ListView

 * p
 * strongWARNING:/strong though you can nest ListViews within Forms,
you HAVE to set the
 * setReuseItems property to true in order to have validation work
properly. By default,
 * setReuseItems is false, which has the effect that ListView replaces all
child components by new
 * instances. The idea behind this is that you always render the fresh
data, and as people usually
 * use ListViews for displaying read-only lists (at least, that's what we
think), this is good
 * default behavior. br /
 * However, as the components are replaced before the rendering starts, the
search for specific
 * messages for these components fails as they are replaced with other
instances. Another problem is
 * that 'wrong' user input is kept as (temporary) instance data of the
components. As these
 * components are replaced by new ones, your user will never see the wrong
data when setReuseItems
 * is false.
 * /p



On Mon, May 6, 2013 at 5:32 AM, Bruno Moura brunormo...@gmail.com wrote:

 I have implemented a listView and every time that a new item is added in
 this ListView the values inserted in the textField and selected in a
 DropDownChoice are lost.

 The following pictures show what's happen before and after add a new
 ListView item:

 [image: Imagem inline 1]

 And after Add a new item:

 [image: Imagem inline 1]

 I'm implemented the code bellow:




   var listData = workSheetDAO.listWorkSheetUser(selectedUser,
 beginDate, endDate)

   var lbPeriodTotal = new Label(periodTotal)
   lbPeriodTotal.setOutputMarkupId(true)
   add(lbPeriodTotal)

   add(new ListView[WorkSheet](listWorkSheet, listData) {

 override protected def onBeforeRender() {
   super.onBeforeRender()
 }

 def populateItem(item: ListItem[WorkSheet]) = {
   var workSheet = item.getModelObject()

   item.add(new LinkDate(initDate, workSheet, 1))
   item.add(new LinkDate(endDate, workSheet, 1))

   item.add(new TextField(description))

   val listCustomer: java.util.List[Customer] =
 customerDAO.listCustomers

   item.add(new DropDownChoice(customerSelection, listCustomer,
 new ChoiceRenderer[Customer](id)))

   if (workSheet.endDate == None) {
 item.add(new Label(total, ))
   } else {
 var period = new Period(workSheet.initDate,
 workSheet.endDate.get)
 periodTotal = periodTotal.plus(period)
 lbPeriodTotal.setDefaultModel(new
 Model(periodTotal.toPeriod().normalizedStandard().toString(getFormatter(
 period = period.normalizedStandard()
 item.add(new Label(total, period.toString(getFormatter(
   }

}
 }

 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/ HH:mm:ss)
   } else
   result = workSheet.endDate.toString(dd/MM/ HH:mm:ss)
   return result
 }
   }))

   def onClick() {}
 }


 The only values preserved are the values of the labels.

 Please, someone could help me, thanks



 Bera




-- 
Regards - Ernesto Reinaldo Barreiro