Hi Friends ,
Am trying to execute a wicket program to accomplish the below task,
a. a submit button is in place in a form
b. when I click that i have to show the ouput in data view of the same page
My codes are below and need your help to fix the erros and get the ouput
*Demoapplication.java*
package com.demo.application;
import org.apache.wicket.Page;
import org.apache.wicket.protocol.http.WebApplication;
import com.demo.pages.*;
public class DemoApplication extends WebApplication {
@Override
public Class<? extends Page> getHomePage() {
// TODO Auto-generated method stub
return DemoHomePage.class;
}
}
DemoHomePage.html:
<html>
<body>
<form wicket:id="homePageForm">
<input type="submit" value="ok">
</form>
Id
Name
</body>
</html>
DemoHomePage.java
package com.demo.pages;
import java.util.ArrayList;
import java.util.List;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.*;
import org.apache.wicket.markup.html.list.*;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
import com.sun.xml.internal.ws.org.objectweb.asm.Label;
public class DemoHomePage extends WebPage {
public DemoHomePage ()
{
Form form=new Form("homePageForm"){
public void submit(){
List<DemoBean> list = new ArrayList();
list.add(new DemoBean("1","ram"));
list.add(new DemoBean("2","sam"));
ListDataProvider<DemoBean> listDataProvider = new
ListDataProvider<DemoBean>(list);
DataView<DemoBean> dataView = new
DataView<DemoBean>("row",listDataProvider){
protected void populateItem(Item<DemoBean> item){
DemoBean bean=item.getModelObject();
RepeatingView repeatingView = new
RepeatingView("dataRow");
repeatingView.add(new
Label(repeatingView.newChildId().bean.getId()));
repeatingView.add(new
Label(repeatingView.newChildId().bean.getName()));
item.add(repeatingView);
}
};
add(dataView);
}
};
}
}
Am getting the below error in the highlighted red area ListDataProvider
<DemoBean> and repeatingView.add.(.....)
Error:
Bound mismatch: The type DemoBean is not a valid substitute for the bounded
parameter <T extends Serializable> of the type ListDataProvider<T>
The method add(Component...) in the type MarkupContainer is not applicable
for the arguments (Label)
DemoBean.java
package com.demo.pages;
public class DemoBean {
public String id;
public String name;
public DemoBean(String id,String name)
{
this.id=id;this.name=name;
}
public String getId(){
return this.id;
}
public void setId(String id){
this.id=id;
}
public String getName(){
return this.name;
}
public void setName(String name){
this.name=name;
}
}
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Errors-in-data-view-req-for-help-to-fix-the-error-in-code-tp4666025.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]