I was trying to show that in fact you where right, but what can I do?
Here is the code for the panel only, the page only has the code adding the
panel (I've bolded the ajax part):
package ch.logismata.wicket.panels.ajax;
import ch.logismata.serverwrapper.DossierSearch;
import ch.logismata.serverwrapper.DossierSearchResult;
import ch.logismata.serverwrapper.DossierSearchResultList;
import ch.logismata.wicket.panels.BasePanel;
import java.io.Serializable ;
import java.util.ArrayList;
import wicket.AttributeModifier;
import wicket.Component;
import wicket.ajax.AjaxRequestTarget;
import wicket.ajax.markup.html.form.AjaxSubmitButton;
import wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigator ;
import wicket.markup.html.WebMarkupContainer;
import wicket.markup.html.basic.Label;
import wicket.markup.html.form.Form;
import wicket.markup.html.form.TextField;
import wicket.markup.html.list.ListItem;
import wicket.markup.html.list.PageableListView;
import wicket.markup.html.panel.FeedbackPanel;
import wicket.model.AbstractReadOnlyModel;
import wicket.model.CompoundPropertyModel;
import wicket.model.Model ;
import wicket.model.ResourceModel;
/**
* Panel to make a Dossier Search and display the results
*
* @author gm
*/
public class DossierSearchPanel extends BasePanel {
private SearchDossierModel m_cSearchDossierModel = new
SearchDossierModel();
private ArrayList<DossierSearchResult> m_cSearchResults = new
ArrayList<DossierSearchResult>();
public DossierSearchPanel(String id) {
//Call super base panel
super(id);
// create feedback panel to show errors
final FeedbackPanel feedback = new FeedbackPanel("searchFeedback");
//add feedback panel
feedback.setOutputMarkupId(true);
add(feedback);
// create form with markup id setter so it can be updated via ajax
Form form = new Form("dossierSearchForm", new
CompoundPropertyModel(m_cSearchDossierModel));
form.setOutputMarkupId(true);
form.add(new Label("legend", new ResourceModel("fields.legend
")));
form.add(new Label("nameLabel", new ResourceModel(" fields.name
")));
//Construct TextFields
TextField cNameTextField = new TextField("name");
TextField cLastNameTextField = new TextField("lastName");
//add Fields to the form
form.add(cNameTextField);
form.add(new Label("lastNameLabel", new ResourceModel("
fields.lastName")));
form.add(cLastNameTextField);
///Add pageable table
final WebMarkupContainer datacontainer = new
WebMarkupContainer("data");
datacontainer.setOutputMarkupId(true);
add(datacontainer);
Model modelForList = new Model(){
public Object getObject(Component component){
return m_cSearchResults;
}
};
final PageableListView listview = new PageableListView("rows",
modelForList, 10) {
protected void populateItem(final ListItem item) {
DossierSearchResult dossierSearchResult =
(DossierSearchResult)item.getModelObject();
item.add(new Label("composedName",
dossierSearchResult.getComposedName()));
item.add(new Label("streetAddress",
dossierSearchResult.getStreetWithNumber()));
item.add (new AttributeModifier("class", true, new
AbstractReadOnlyModel() {
public Object getObject(Component component) {
return (item.getIndex() % 2 == 1) ? "even" : "odd";
}
}));
}
};
if(m_cSearchResults.size()==0){
}
listview.setOutputMarkupId(true);
datacontainer.add (listview);
datacontainer.add(new AjaxPagingNavigator("navigator", listview));
datacontainer.setVersioned(false);
// add a button that can be used to submit the form via ajax
form.add(new AjaxSubmitButton("searchButton", form) {
protected void onSubmit(AjaxRequestTarget target, Form form) {
// repaint the feedback panel so that it is hidden
searchDossiers(m_cSearchDossierModel.getName(),
m_cSearchDossierModel.getLastName());
if(m_cSearchResults.size()==0){
datacontainer.setVisible(false);
}else{
datacontainer.setVisible(true);
}
target.addComponent(feedback);
target.addComponent(datacontainer);
}
protected void onError(AjaxRequestTarget target, Form form) {
// repaint the feedback panel so errors are shown
target.addComponent(feedback);
}
});
//Add Form
add(form);
}
private void searchDossiers(String name, String lastName){
String message = null;
try{
if(m_cSearchResults==null){
m_cSearchResults = new ArrayList<DossierSearchResult>();
}
m_cSearchResults.clear();
DossierSearch cDossierSearch;
DossierSearchResultList cDossierSearchResultList;
cDossierSearch = new DossierSearch();
if(name==null){
name = "";
}
if(lastName==null){
lastName = "";
}
cDossierSearch.setFirstName(name);
cDossierSearch.setName(lastName);
cDossierSearchResultList = cDossierSearch.search();
message =
cDossierSearchResultList.size()>0?cDossierSearchResultList.size()+"
Dossiers found at search.":"No Dossiers found at search.";
info(message);
for(int iIterator=0;iIterator< cDossierSearchResultList.size
();iIterator++){
m_cSearchResults.add((DossierSearchResult)cDossierSearchResultList.getItem(iIterator));
}
/*
for(int iIterator=0;iIterator<100;iIterator++){
DossierSearchResultEntity cDossierResultEntity = new
DossierSearchResultEntity("DossierObjectId-"+iIterator,
"ComposedName-"+iIterator, "StreetWithNumber-"+iIterator,
"ZipWithLocation-"+iIterator, iIterator);
m_cSearchResults.add(cDossierResultEntity);
}*/
} catch(Exception xException){
message = "Error Occured at
DossierSearchPanel.searchDossiers().\n"+xException.toString();
error(message);
}
}
public boolean isVisible() {
return getWicketSession().isUserLoggedIn();
}
/** simple java bean. */
private static class SearchDossierModel implements Serializable {
private String name, lastName;
/**
* Gets lastName.
*
*
* @return lastName
*/
public String getLastName() {
return lastName;
}
/**
* Sets lastName.
*
*
* @param lastName
* lastName
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
* Gets name.
*
* @return name
*/
public String getName() {
return name;
}
/**
* Sets name.
*
* @param name
* name
*/
public void setName(String name) {
this.name = name;
}
}
}
On 5/31/07, Johan Compagner <[EMAIL PROTECTED] > wrote:
that code doesn't say much (for example where is the ajax code?)
don't you have a small quickstart application ?
On 5/30/07, Francisco Diaz Trepat - gmail <[EMAIL PROTECTED]>
wrote:
>
> Johan many thanks for answering I think so.
>
> Here is the structure of the code:
>
> 1) A panel that contains a Form (fields name and lastName) and a Table
> (PageableListView).
>
> 2) A small SearchPage like this:
>
> public DossierSearch() {
> super();
> add(new ch.logismata.wicket.panels.ajax.DossierSearchPanel
> ("ajaxDossierSearchPanel"));
> }
>
>
> f(t)
>
>
> On 5/29/07, Johan Compagner < [EMAIL PROTECTED]> wrote:
> >
> > Are you sure that you don't set another page to render in the ajax
> > button submit code??
> >
> > Because if you a pure ajax call and you don't set anohter response
> > page then the url in your browser shouldn't change
> >
> > johan
> >
> >
> > On 5/29/07, Francisco Diaz Trepat - gmail <[EMAIL PROTECTED]>
> > wrote:
> >
> > > Hi all,
> > >
> > > I have the following behavior:
> > >
> > > On one side of a Page I have a list of links (acting as a menu :P)
> > > that is created by building links by obtaining the page class
> > > NameOfThePage.class.
> > >
> > > That gives me the url:
> > >
> > >
http://localhost:8084/WicketDemo?wicket:bookmarkablePage=:ch.logismata.wicket.pages.DossierSearch
> > >
> > >
> > > Then I click on my AJAX Submit button to get a search result, but
> > > instead of that, the page is refreshed, now with this url:
> > >
> > > http://localhost:8084/WicketDemo?wicket:interface=:8:1 :
> > >
> > > Then I click the AJAX SubmitButton and everything works fine.
> > >
> > > This happens most times, but I don't know how yet, sometimes it
> > > works on the first step.
> > >
> > > Best regards,
> > > f(t)
> > >
> > >
> > > -------------------------------------------------------------------------
> > > This SF.net email is sponsored by DB2 Express
> > > Download DB2 Express C - the FREE version of DB2 express and take
> > > control of your XML. No limits. Just data. Click to get it now.
> > > http://sourceforge.net/powerbar/db2/
> > > _______________________________________________
> > > Wicket-user mailing list
> > > Wicket-user@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/wicket-user
> > >
> > >
> >
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by DB2 Express
> > Download DB2 Express C - the FREE version of DB2 express and take
> > control of your XML. No limits. Just data. Click to get it now.
> > http://sourceforge.net/powerbar/db2/
> > _______________________________________________
> > Wicket-user mailing list
> > Wicket-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
> >
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user