feedback message

2010-02-08 Thread Swarnim Ranjitkar

Is there a way to tell feedbackpanel not to encode my string eg
error(test a href='test.jsp'/a);
thank you

  

not addding componet in case of error

2009-12-11 Thread Swarnim Ranjitkar

I have a case where I check some error condition at the beginning of the code. 
If there is error I just want to display error message so
basically it is
if (error == true){
display message
} else {
//render regular page
add(component1)
add(compnent2)
}

if there is error I don't have any data to generate my component. Is there a 
clean way to do this. I'm getting 
 Unable to find component with id 'chart1image' exception. Appreciate your 
feedback
thank you


  

palette and event

2009-12-02 Thread Swarnim Ranjitkar

I was trying to attach AjaxFormComponentUpdatingBehavior to palette and looks 
like I can't do it this way. Is there anyways to attach action to palette 
change event. 
Here is my code. Appreciate you feedback

PaletteDtAddDisplay affiliatePalette  = new 
PaletteDtAddDisplay(affiliatePalette,
new PropertyModel(this.getModel(),allFilteredDtAdd), 
affiliateRenderer, 12, false);
affiliatePalette.add(new  AjaxFormComponentUpdatingBehavior(onchange) 
{
protected void onUpdate(AjaxRequestTarget target) {

}
});   

expandPath in AbstractTree

2009-11-19 Thread Swarnim Ranjitkar

I see that wicket 1.2  had expandPath in AbstractTree which i don't see anymore 
in 1.4. I want to use this so that I can expand some node (not the current 
node) can you please let me know how I can do this in 1.4

expandPath
public void expandPath(javax.swing.tree.TreePath path)
Ensures that the node identified by the specified path is expanded and
 viewable. If the last item in the path is a leaf, this will have no
 effect.


Parameters:path - the TreePath identifying a node
  

RE: expandPath in AbstractTree

2009-11-19 Thread Swarnim Ranjitkar

I figured it out. i used
tree.getTreeState().expandNode(destinationNode);

 From: swarn...@hotmail.com
 To: users@wicket.apache.org
 Subject: expandPath in AbstractTree
 Date: Thu, 19 Nov 2009 14:38:23 -0800
 
 
 I see that wicket 1.2  had expandPath in AbstractTree which i don't see 
 anymore in 1.4. I want to use this so that I can expand some node (not the 
 current node) can you please let me know how I can do this in 1.4
 
 expandPath
 public void expandPath(javax.swing.tree.TreePath path)
 Ensures that the node identified by the specified path is expanded and
  viewable. If the last item in the path is a leaf, this will have no
  effect.
 
 
 Parameters:path - the TreePath identifying a node
 
  

RE: Updating a Dynamic Image with AJAX (and JFreeChart)

2009-11-14 Thread Swarnim Ranjitkar

I would be nice for this work as we have a JFreeChart written which is called 
by other apps too.

 Date: Sat, 14 Nov 2009 10:23:38 +0100
 From: zabia...@gmail.com
 To: user
se...@wicket.apache.org
 Subject: Re: Updating a Dynamic Image with AJAX (and JFreeChart)
 
 Hi there,
 is JFreeChart your only possible approach? Check out flot integration 
 from wicketstuff-core.
 It draws nicer charts and you can update datasets sending json object 
 and redraw it by js.
 
 Regards,
 Wojtek
 
 
 Swarnim Ranjitkar pisze:
  I couldn't override getResourceState of DynamicImageResource as it new 
  Resource state uses variable from DynamicImageResource eg format. Instead i 
  copied DynamicImageResource class and made my own version of it and 
  modified the getResourceState() get method. When I changed the drop down I 
  was expecting it to call the geImageData but it wasn't calling it. Could 
  you please advice.
  Here is the modified method.
  protected synchronized ResourceState getResourceState()
  {
  return new ResourceState()
  {
  private byte[] imageData;
  private final String contentType = image/ + format;
 
  @Override
  public Time lastModifiedTime()
  {
  if (lastModifiedTime == null)
  {
  lastModifiedTime = 
  DynamicImageResource.this.lastModifiedTime;
  if (lastModifiedTime == null)
  {
  lastModifiedTime = Time.now();
  }
  }
  return lastModifiedTime;
  }
 
  @Override
  public byte[] getData()
  {
  // here is what I made the change.
  imageData = getImageData();
  return imageData;
  }
 
  @Override
  public String getContentType()
  {
  return contentType;
  }
  };
  }
 
  From my  Image Class I called the copied version of   in getImageResource() 
  {
 
  return new DynamicImageResource(){
 
 
  public class TugboatChartImage extends NonCachingImage  {
 
  private int width;
  private int height;
 
  public TugboatChartImage(String id, JFreeChart chart, int width, int 
  height){
  super(id, new Model(chart));
  this.width = width;
  this.height = height;
  }
 
  @Override
  protected Resource getImageResource() {
  return new DynamicImageResource(){//my copied version of 
  DynamicResouce
  @Override
  protected byte[] getImageData() {
  JFreeChart chart = (JFreeChart)getDefaultModelObject();
  return toImageData(chart.createBufferedImage(width, 
  height));
  }
  
 
  };
  }
 
  }
 
 

  To: users@wicket.apache.org
  From: craig.mcil...@openroadsconsulting.com
  Subject: Re: Updating a Dynamic Image with AJAX (and JFreeChart)
  Date: Fri, 13 Nov 2009 23:31:39 -0500
 
  Look at the source of the DynamicImageResource class.  The 
  getResourceState method does something like (sorry for the lame 
  pseudocode) 'if image data is null then save and return value of 
  getImageData else return the previous image data'.  So its gonna call your 
  getImageData() method once and save the value.  This falls in line with 
  the super class's (DynamicWebResource) javadoc that says:
 
  very useful for things you   generate dynamically, but reuse for a while 
  after that. If you need resources that stream   directly and are not 
  cached, extend WebResource directly and implement 
  Resouce.getResourceStream() yourself.
 
  It has nothing to do with HTTP caching, which it looks like you're trying 
  to solve with your headers, but server-side caching.  Anyways... in this 
  case, getResourceStream of WebResource ends up calling getResourceState of 
  DynamicImageResource.  All you need to do is is override getResourceState 
  (and therefore kind of overrides the behavior of getResourceStream) of 
  your DynamicImageResource and ensure that it doesn't cache the result of 
  getImageData() and you should be set.
 
  Craig
_  
 
  From: wicketnewuser [mailto:swarn...@hotmail.com]
  To: users@wicket.apache.org
  Sent: Fri, 13 Nov 2009 20:32:05 -0500
  Subject: Re: Updating a Dynamic Image with AJAX (and JFreeChart)
 
 
I have same situation. I'm not able to refresh my image. But if i view 
  the
image i do get refreshed image
Here is my code. Based on my dropdownchoice it should make new Jfreechart
and the image should refresh. I couldn't get it working so i wrapped the
image with in a span but it still doesn't work. TugboatChartImage extends
NonCachingImage . Can any one point out what I'm doing wrong
Chart chart1 = new Chart(this.getString(column1.toString()), Date,
Dollars);
  final String

RE: Updating a Dynamic Image with AJAX (and JFreeChart)

2009-11-13 Thread Swarnim Ranjitkar

I couldn't override getResourceState of DynamicImageResource as it new Resource 
state uses variable from DynamicImageResource eg format. Instead i copied 
DynamicImageResource class and made my own version of it and modified the 
getResourceState() get method. When I changed the drop down I was expecting it 
to call the geImageData but it wasn't calling it. Could you please advice.
Here is the modified method.
protected synchronized ResourceState getResourceState()
{
return new ResourceState()
{
private byte[] imageData;
private final String contentType = image/ + format;

@Override
public Time lastModifiedTime()
{
if (lastModifiedTime == null)
{
lastModifiedTime = 
DynamicImageResource.this.lastModifiedTime;
if (lastModifiedTime == null)
{
lastModifiedTime = Time.now();
}
}
return lastModifiedTime;
}

@Override
public byte[] getData()
{
// here is what I made the change.
imageData = getImageData();
return imageData;
}

@Override
public String getContentType()
{
return contentType;
}
};
}

From my  Image Class I called the copied version of   in getImageResource() {

return new DynamicImageResource(){


public class TugboatChartImage extends NonCachingImage  {

private int width;
private int height;

public TugboatChartImage(String id, JFreeChart chart, int width, int 
height){
super(id, new Model(chart));
this.width = width;
this.height = height;
}

@Override
protected Resource getImageResource() {
return new DynamicImageResource(){//my copied version of DynamicResouce
@Override
protected byte[] getImageData() {
JFreeChart chart = (JFreeChart)getDefaultModelObject();
return toImageData(chart.createBufferedImage(width, height));
}


};
}

}


 To: users@wicket.apache.org
 From: craig.mcil...@openroadsconsulting.com
 Subject: Re: Updating a Dynamic Image with AJAX (and JFreeChart)
 Date: Fri, 13 Nov 2009 23:31:39 -0500
 
 Look at the source of the DynamicImageResource class.  The getResourceState 
 method does something like (sorry for the lame pseudocode) 'if image data is 
 null then save and return value of getImageData else return the previous 
 image data'.  So its gonna call your getImageData() method once and save the 
 value.  This falls in line with the super class's (DynamicWebResource) 
 javadoc that says:
 
 very useful for things you   generate dynamically, but reuse for a while 
 after that. If you need resources that stream   directly and are not cached, 
 extend WebResource directly and implement Resouce.getResourceStream() 
 yourself.
 
 It has nothing to do with HTTP caching, which it looks like you're trying to 
 solve with your headers, but server-side caching.  Anyways... in this case, 
 getResourceStream of WebResource ends up calling getResourceState of 
 DynamicImageResource.  All you need to do is is override getResourceState 
 (and therefore kind of overrides the behavior of getResourceStream) of your 
 DynamicImageResource and ensure that it doesn't cache the result of 
 getImageData() and you should be set.
 
 Craig
   _  
 
 From: wicketnewuser [mailto:swarn...@hotmail.com]
 To: users@wicket.apache.org
 Sent: Fri, 13 Nov 2009 20:32:05 -0500
 Subject: Re: Updating a Dynamic Image with AJAX (and JFreeChart)
 
 
   I have same situation. I'm not able to refresh my image. But if i view the
   image i do get refreshed image
   Here is my code. Based on my dropdownchoice it should make new Jfreechart
   and the image should refresh. I couldn't get it working so i wrapped the
   image with in a span but it still doesn't work. TugboatChartImage extends
   NonCachingImage . Can any one point out what I'm doing wrong
   Chart chart1 = new Chart(this.getString(column1.toString()), Date,
   Dollars);
 final String yAxisType = linear;
 final int smallChartWidth=400;
 final int smallChartHeight=200;
 JFreeChart jfChartOne = chart1.render(chartOneCollection, null, yAxisType,
   smallChartWidth, smallChartHeight);
 
 
 // make an image
 final TugboatChartImage imageOne = new TugboatChartImage(chart1image,
   jfChartOne, smallChartWidth, smallChartHeight);
 final WebMarkupContainer chart1Span = new
   WebMarkupContainer(chart1Span);
 chart1Span.add(imageOne);
 add(chart1Span);
   
 // draw chart 2
 Chart chart2 = new Chart(this.getString(column2.toString()), Date,
   Count);
 JFreeChart jfChartTwo = chart2.render(chartTwoCollection, null, yAxisType,
   smallChartWidth, 

RE: Datepicker model change problem

2009-11-12 Thread Swarnim Ranjitkar

Thank you that did work. I don't know why you have to do modelChanged() on this 
component exclusively  while other component like the minute drop down didn't 
need it. form.modelchanged() did the refresh on those component. Anyways my 
problem is solved thank you very much

 From: igor.vaynb...@gmail.com
 Date: Thu, 12 Nov 2009 13:19:17 -0800
 Subject: Re: Datepicker model change problem
 To: users@wicket.apache.org
 
 you need to either call modelchanged() or clearinput() on the ddcs
 
 -igor
 
 On Thu, Nov 12, 2009 at 12:57 PM, wicketnewuser swarn...@hotmail.com wrote:
 
  Hi Anyone has any idea about this
 
  wicketnewuser wrote:
 
 
  I have a page with date picker that picks the date, DropdownChoice for
  hour and minute. When I click today button I change the model in
  onsubmit method. It is suppose to change the form value in datepicker,
  hour and minute to today/now.This changes hour and minute but doesn't
  change the value in the
  datepicker. Is there something that I need to do to make this work. Here
  is the partial code
 
 
public void onSubmit() {
 
  Calendar startDate = Calendar.getInstance();
 
 
 
  // initialize end date
 
  Calendar endDate = Calendar.getInstance();
 
 
 
  model.getObject().setStartDate(startDate);
 
  model.getObject().setEndDate(endDate);
 
  getForm().modelChanged();
 
  super.onSubmit();
 
  }
 
  Here is the whole code.
 
  public final class DateTimeSelectionModel implements IClusterable {
 
  private Calendar startDate;
  private Calendar endDate;
 
  public DateTimeSelectionModel() {
 
  // initialize start date
  startDate = Calendar.getInstance();
  startDate.add(Calendar.DATE, -5);
  startDate.set(Calendar.HOUR_OF_DAY, 0);
  startDate.set(Calendar.MINUTE, 0);
  startDate.set(Calendar.SECOND, 0);
 
  // initialize end date
  endDate = Calendar.getInstance();
  endDate.add(Calendar.DATE, -5);
  endDate.set(Calendar.HOUR_OF_DAY, 23);
  endDate.set(Calendar.MINUTE, 59);
  endDate.set(Calendar.SECOND, 59);
 
  System.out.println(hello);
  }
 
  public void setStartDate(Calendar startDate) {
  this.startDate = startDate;
  }
 
  public void setEndDate(Calendar endDate) {
  this.endDate = endDate;
  }
 
  // this method is called to get the default for the form.
  public Date getStartDate() {
  return startDate.getTime();
  }
  public void setStartDate(Date date) {
  //we want to set only year month and day here not the whole date
  Calendar cal = Calendar.getInstance();
  cal.setTime(date);
  this.startDate.set(cal.get(Calendar.YEAR),
  cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
  }
 
  public SelectOption getStartHour() {
  SelectOption option = new SelectOption(Unknown, new String( +
  startDate.get(Calendar.HOUR_OF_DAY)));
  return option;
  }
  public void setStartHour(SelectOption hour) {
  startDate.set(Calendar.HOUR_OF_DAY,
  Integer.valueOf(hour.getValue()));
  }
 
  public void setStartMinute(String minute) {
  startDate.set(Calendar.MINUTE, Integer.valueOf(minute));
  }
  public void setStartMinute(int minute) {
  startDate.set(Calendar.MINUTE, minute);
  }
  public int getStartMinute() {
  return startDate.get(Calendar.MINUTE);
  }
 
 
  public Date getEndDate() {
  return endDate.getTime();
  }
  public void setEndDate(Date date) {
  //we want to set only year month and day here not the whole date
  Calendar cal = Calendar.getInstance();
  cal.setTime(date);
  this.endDate.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH),
  cal.get(Calendar.DAY_OF_MONTH));
  }
 
  public SelectOption getEndHour() {
  SelectOption option = new SelectOption(Unknown, new String( +
  endDate.get(Calendar.HOUR_OF_DAY)));
  return option;
  }
  public void setEndHour(SelectOption hour) {
  endDate.set(Calendar.HOUR_OF_DAY,
  Integer.valueOf(hour.getValue()));
  }
 
  public void setEndMinute(String minute) {
  endDate.set(Calendar.MINUTE, Integer.valueOf(minute));
  }
  public void setEndMinute(int minute) {
  endDate.set(Calendar.MINUTE, minute);
  }
  public int getEndMinute() {
  return endDate.get(Calendar.MINUTE);
  }
 
 
 
  }
 
 
  public class DateTimeSelectionForm extends Form {
 
  public DateTimeSelectionForm(String id, final
  IModelDateTimeSelectionModel model) {
  //super(id);
  super(id, model);
 
  final DateTextField dateStartField = new
  DateTextField(startDate,new PropertyModelDate(model, startDate), new
  PatternDateConverter(MM-dd-,true)) ;
  

Datepicker model change problem

2009-11-11 Thread Swarnim Ranjitkar

I have a page with date picker that picks the date, DropdownChoice for hour and 
minute. When I click today button I change the model in onsubmit method. It 
is suppose to change the form value in datepicker, hour and minute to 
today/now.This changes hour and minute but doesn't change the value in the
datepicker. Is there something that I need to do to make this work. Here is the 
partial code


  public void onSubmit() {

Calendar startDate = Calendar.getInstance();



// initialize end date

Calendar endDate = Calendar.getInstance();



model.getObject().setStartDate(startDate);

model.getObject().setEndDate(endDate);

getForm().modelChanged();

super.onSubmit();

}

Here is the whole code.

public final class DateTimeSelectionModel implements IClusterable {
   
private Calendar startDate;
private Calendar endDate;

public DateTimeSelectionModel() {

// initialize start date
startDate = Calendar.getInstance();
startDate.add(Calendar.DATE, -5);
startDate.set(Calendar.HOUR_OF_DAY, 0);
startDate.set(Calendar.MINUTE, 0);
startDate.set(Calendar.SECOND, 0);

// initialize end date
endDate = Calendar.getInstance();
endDate.add(Calendar.DATE, -5);
endDate.set(Calendar.HOUR_OF_DAY, 23);
endDate.set(Calendar.MINUTE, 59);
endDate.set(Calendar.SECOND, 59);

System.out.println(hello);
}

public void setStartDate(Calendar startDate) {
this.startDate = startDate;
}

public void setEndDate(Calendar endDate) {
this.endDate = endDate;
}

// this method is called to get the default for the form.
public Date getStartDate() {
return startDate.getTime();
}
public void setStartDate(Date date) {
//we want to set only year month and day here not the whole date
Calendar cal = Calendar.getInstance();
cal.setTime(date);
this.startDate.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), 
cal.get(Calendar.DAY_OF_MONTH));
}

public SelectOption getStartHour() {
SelectOption option = new SelectOption(Unknown, new String( + 
startDate.get(Calendar.HOUR_OF_DAY)));
return option;
}
public void setStartHour(SelectOption hour) {
startDate.set(Calendar.HOUR_OF_DAY, Integer.valueOf(hour.getValue()));
}

public void setStartMinute(String minute) {
startDate.set(Calendar.MINUTE, Integer.valueOf(minute));
}
public void setStartMinute(int minute) {
startDate.set(Calendar.MINUTE, minute);
}
public int getStartMinute() {
return startDate.get(Calendar.MINUTE);
}


public Date getEndDate() {
return endDate.getTime();
}
public void setEndDate(Date date) {
//we want to set only year month and day here not the whole date
Calendar cal = Calendar.getInstance();
cal.setTime(date);
this.endDate.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), 
cal.get(Calendar.DAY_OF_MONTH));
}

public SelectOption getEndHour() {
SelectOption option = new SelectOption(Unknown, new String( + 
endDate.get(Calendar.HOUR_OF_DAY)));
return option;
}
public void setEndHour(SelectOption hour) {
endDate.set(Calendar.HOUR_OF_DAY, Integer.valueOf(hour.getValue()));
}

public void setEndMinute(String minute) {
endDate.set(Calendar.MINUTE, Integer.valueOf(minute));
}
public void setEndMinute(int minute) {
endDate.set(Calendar.MINUTE, minute);
}
public int getEndMinute() {
return endDate.get(Calendar.MINUTE);
}



}


public class DateTimeSelectionForm extends Form {

public DateTimeSelectionForm(String id, final 
IModelDateTimeSelectionModel model) {
//super(id);
super(id, model);

final DateTextField dateStartField = new DateTextField(startDate,new 
PropertyModelDate(model, startDate), new 
PatternDateConverter(MM-dd-,true)) ;
add(dateStartField);
dateStartField.add(new DatePicker());

// Start Hour
DropDownChoiceSelectOption startHourChoice = new 
DropDownChoiceSelectOption(startHour, getHourChoices(), new 
ChoiceRendererSelectOption(label, value));
startHourChoice.setNullValid(false);
add(startHourChoice);

DropDownChoiceInteger startMinuteChoice = new 
DropDownChoiceInteger(startMinute , getMinuteChoices());
startMinuteChoice.setNullValid(false);
add(startMinuteChoice);

DateTextField dateEndField = new DateTextField(endDate, new 
PropertyModelDate(model, endDate), new PatternDateConverter(MM-dd-, 
true)) ;
add(dateEndField);
dateEndField.add(new DatePicker());

DropDownChoiceSelectOption endHourChoice = new 

column in listview that is combination of two fields

2009-11-10 Thread Swarnim Ranjitkar

 I have a ListView with a requirement that I display one one the column as 
combination of two fields eg. my cnameID should be cname:id.
 Is there a way to get the model so that it is Label is combination of two 
fields or do I have to create a wrapper object for this purpose.
 
 ListView = new ListView(test, testList) {
  @Override
  protected void populateItem(ListItem item) {
TestObject testObj = (TestObj) item.getModelObject();
item.add(new Label(Name, new PropertyModel(testObj, name)));
//second column should be cname:id
   item.add(new Label(cnameID, new PropertyModel(testObj, cname)));
   
 public class TestObj{
 public String name;
 public int id;
 public String cname;
 }
 thank you

model update in moveuplink and movedownlink onclick

2009-11-07 Thread Swarnim Ranjitkar

Is there anyway that you can update model before you move the item up or down 
using moveuplink and movedownlink in listview. My goal is to save the input 
data to the model so that I don't loose use input on the item before moving the 
item. I did try to extend the ListView and added my own moveuplink and downlink 
code called form's updateFormComponentModels()  method but that didn't really 
help. Does anyone have any idea how this can be done.

LeadTransnodeChain lc = new LeadTransnodeChain(1, 2, 3, 4, 5, 
LeadTransnodeChain.MODE.ASYNC);
masterChainList.add(lc);
masterChainList.add(new LeadTransnodeChain(11, 12, 13, 14, 15, 
LeadTransnodeChain.MODE.SYNC));
masterChainList.add(new LeadTransnodeChain(21, 22, 23, 24, 25, 
LeadTransnodeChain.MODE.SYNC));

ListView propertiesList = new MyListView(masterChainList, 
masterChainList) {

@Override
protected void populateItem(ListItem item) {
LeadTransnodeChain leadTransnodeChain = (LeadTransnodeChain) 
item.getModelObject();

  
item.add(new Label(masterChain, new 
PropertyModel(leadTransnodeChain, m_masterChainID)));
item.add(new DropDownChoice(runAs, new 
PropertyModel(leadTransnodeChain, m_mode), 
Arrays.asList(LeadTransnodeChain.MODE.values()), new IChoiceRenderer() {
public Object getDisplayValue(Object mode) {
return ((LeadTransnodeChain.MODE) mode).toString();
}

public String getIdValue(Object obj, int index) {
return obj.toString();
}
}
   
));
item.add(moveMyUpLink(moveUp, item, form));
item.add(moveMyDownLink(moveDown, item, form)); 


}
};
add(new Button(submitButton));

propertiesList.setReuseItems(true);
add(propertiesList);
}public void updateComponentModels(){
super.updateFormComponentModels();
}


public abstract class MyListViewT extends ListViewT {

...

protected abstract void populateItem(ListItem item) ;

/**
 * Returns a link that will move the given item down (towards the end) in 
the listView.
 * 
 * @param id
 *Name of move-down link component to create
 * @param item
 * @return The link component
 */
public final LinkVoid moveMyDownLink(final String id, final ListItemT 
item, final MasterChainListForm form)
{
return new LinkVoid(id)
{
private static final long serialVersionUID = 1L;

/**
 * @see org.apache.wicket.markup.html.link.Link#onClick()
 */
@Override
public void onClick()
{
final int index = getList().indexOf(item.getModelObject());
if (index != -1)
{   
form.updateComponentModels();
addStateChange(new Change()
{
private static final long serialVersionUID = 1L;

final int oldIndex = index;

@Override
public void undo()
{
Collections.swap(getList(), oldIndex + 1, oldIndex);
}

});

// Swap list items and invalidate listView
Collections.swap(getList(), index, index + 1);
MasterChainListView.this.removeAll();
}
}

/**
 * @see org.apache.wicket.Component#onBeforeRender()
 */
@Override
protected void onBeforeRender()
{
super.onBeforeRender();
setAutoEnable(false);
if (getList().indexOf(item.getModelObject()) == 
(getList().size() - 1))
{
setEnabled(false);
}
}
};
}

/**

  

RE: model update in moveuplink and movedownlink onclick

2009-11-07 Thread Swarnim Ranjitkar
public void undo()
{
Collections.swap(getList(), oldIndex - 1, 
oldIndex);
}

});

// Swap items and invalidate listView
Collections.swap(getList(), index, index - 1);
MasterChainListView.this.removeAll();
}

}
}

};
}

ListView propertiesList = new MyListView(masterChainList, 
masterChainList) {

@Override
protected void populateItem(ListItem item) {
LeadTransnodeChain leadTransnodeChain = (LeadTransnodeChain) 
item.getModelObject();

  
item.add(new Label(masterChain, new 
PropertyModel(leadTransnodeChain, m_masterChainID)));
item.add(new DropDownChoice(runAs, new 
PropertyModel(leadTransnodeChain, m_mode), 
Arrays.asList(LeadTransnodeChain.MODE.values()), new IChoiceRenderer() {
public Object getDisplayValue(Object mode) {
return ((LeadTransnodeChain.MODE) mode).toString();
}

public String getIdValue(Object obj, int index) {
return obj.toString();
}
}
   
));
item.add(moveMyUpLink(moveUp, item, form));
item.add(moveMyDownLink(moveDown, item, form)); 


}



 From: igor.vaynb...@gmail.com


 Date: Sat, 7 Nov 2009 17:58:01 -0800
 Subject: Re: model update in moveuplink and movedownlink onclick
 To: users@wicket.apache.org
 
 you have to use submitlinks for move up/down.
 
 -igor
 
 On Sat, Nov 7, 2009 at 4:31 PM, Swarnim Ranjitkar swarn...@hotmail.com 
 wrote:
 
  Is there anyway that you can update model before you move the item up or 
  down using moveuplink and movedownlink in listview. My goal is to save the 
  input data to the model so that I don't loose use input on the item before 
  moving the item. I did try to extend the ListView and added my own 
  moveuplink and downlink code called form's updateFormComponentModels() 
  ámethod but that didn't really help. Does anyone have any idea how this can 
  be done.
 
  LeadTransnodeChain lc = new LeadTransnodeChain(1, 2, 3, 4, 5, 
  LeadTransnodeChain.MODE.ASYNC);
  á á á ámasterChainList.add(lc);
  á á á ámasterChainList.add(new LeadTransnodeChain(11, 12, 13, 14, 15, 
  LeadTransnodeChain.MODE.SYNC));
  á á á ámasterChainList.add(new LeadTransnodeChain(21, 22, 23, 24, 25, 
  LeadTransnodeChain.MODE.SYNC));
 
  á á á áListView propertiesList = new MyListView(masterChainList, 
  masterChainList) {
 
  á á á á á �...@override
  á á á á á áprotected void populateItem(ListItem item) {
  á á á á á á á áLeadTransnodeChain leadTransnodeChain = (LeadTransnodeChain) 
  item.getModelObject();
 
 
  á á á á á á á áitem.add(new Label(masterChain, new 
  PropertyModel(leadTransnodeChain, m_masterChainID)));
  á á á á á á á áitem.add(new DropDownChoice(runAs, new 
  PropertyModel(leadTransnodeChain, m_mode), 
  Arrays.asList(LeadTransnodeChain.MODE.values()), new IChoiceRenderer() {
  á á á á á á á á á ápublic Object getDisplayValue(Object mode) {
  á á á á á á á á á á á á á áreturn ((LeadTransnodeChain.MODE) 
  mode).toString();
  á á á á á á á á á á}
 
  á á á á á á á á á ápublic String getIdValue(Object obj, int index) {
  á á á á á á á á á á á á á áreturn obj.toString();
  á á á á á á á á á á}
  á á á á á á á á á á}
 
  á á á á á á á á));
  á á á á á á á áitem.add(moveMyUpLink(moveUp, item, form));
  á á á á á á á áitem.add(moveMyDownLink(moveDown, item, form));
 
 
  á á á á á á}
  á á á á};
  á áadd(new Button(submitButton));
 
  á á á ápropertiesList.setReuseItems(true);
  á á á áadd(propertiesList);
  }public void updateComponentModels(){
  á á á ásuper.updateFormComponentModels();
  á á}
 
 
  public abstract class MyListViewT extends ListViewT {
 
  á á...
 
  á áprotected abstract void populateItem(ListItem item) ;
 
  á á/**
  á á * Returns a link that will move the given item down (towards the end) 
  in the listView.
  á á *
  á á * @param id
  á á * á á á á á áName of move-down link component to create
  á á * @param item
  á á * @return The link component
  á á */
  á ápublic final LinkVoid moveMyDownLink(final String id, final 
  ListItemT item, final MasterChainListForm form)
  á á{
  á á á áreturn new LinkVoid(id)
  á á á á{
  á á á á á áprivate static final long serialVersionUID = 1L;
 
  á á á á á á/**
  á á á á á á * @see org.apache.wicket.markup.html.link.Link#onClick()
  á á á á á á */
  á á á á á �...@override
  á á á á á ápublic void onClick()
  á á á á á á{
  á á á á á á á áfinal int index = getList().indexOf(item.getModelObject());
  á á á á á á á áif (index != -1)
  á á á á á á á á{
  á á á á á á á á á

table inside a td in wicket table

2009-11-04 Thread Swarnim Ranjitkar

 I'm trying put a table inside a td in datatable so that my column can have 
more than one row I overode  the createLableModel method and tried to but html 
tag like this
wicket:panel 
tabletbodytrtdfads/td/trtrtdfdsafas/td/tr/tbody/tabletable
 /table/wicket:panel
look like it everything in a cell is put under 
td wicket:id=cells  span wicket:id=cell

because it of  span wicket:id=cell it gets displayed as text. Is there 
anyway you could overide this or any better way of doing this
thank you



  

RE: table inside a td in wicket table

2009-11-04 Thread Swarnim Ranjitkar

Here are the two classes. What I was thinking was i would overide 
createLabelModel and create table with the tag like below.


import java.math.BigDecimal;

import 
org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.html.basic.Label
;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.link.PopupSettings;
import org.apache.wicket.markup.html.panel.Panel; 
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;

public class TablePropertyColumn extends PropertyColumn {



public TablePropertyColumn(IModel displayModel,
final String sortProperty, final String propertyExpression) {
super(displayModel, sortProperty, propertyExpression);
// TODO Auto-generated constructor stub
}



protected IModel createLabelModel(final IModel rowModel) {
final IModel prop = super.createLabelModel(rowModel);
return new AbstractReadOnlyModel() {
public Object getObject() {
String data = (String) prop.getObject();
// will get it from the object and create table
dataString = wicket:panel 
tabletbodytrtdfads/td/trtrtdfdsafas/td/tr/tbody/tabletable
 /table/wicket:panel;
   
return dataString;

}
};
}

}



import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.markup.html.panel.Panel;
import 
org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; 
import 
org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn; 
import org.apache.wicket.model.Model;

import com.swishmark.tugboat.util.ReportTemplateListProvider;
import com.swishmark.tugboat.util.TablePropertyColumn;

// http://cwiki.apache.org/WICKET/simple-sortable-datatable-example.html
// AJAX: 
http://www.wicket-library.com/wicket-examples/repeater/?wicket:bookmarkablePage=:org.apache.wicket.examples.repeater.AjaxDataTablePage

public class RelatedProductListPanel extends Panel {

public RelatedProductListPanel(String id, int transNodeId) {
super(id);

ListIColumn? columns = new ArrayListIColumn?();
columns.add(new PropertyColumn(new Model(product_id), product_id, 
product_id));
columns.add(new PropertyColumn(new Model(Name), name, name));
columns.add(new PropertyColumn(new Model(Status), status, 
status));
columns.add(new PropertyColumn(new Model(vertical), vertical, 
vertical));
columns.add(new TablePropertyColumn(new Model(transname), 
transname, transname));
add(new AjaxFallbackDefaultDataTable(relatedProductListTable, 
columns, new RelatedProductListProvider(transNodeId), 8));
}
}
-
Even though I use a panel and write my own and populate my panel i
think  it will put everything inside wicket:cell . I'm looking
for a way so that it doesn't write the tag.

public void populateItem(Item item, String componentId, IModel model) {

item.add(new TablePanel(item, componentId, model));



wicket:panel

table

 tr wicket:id=tablerow

   td wicket:id=tabletd/td

 /tr

 /table

/wicket:panel


 From: igor.vaynb...@gmail.com
 Date: Wed, 4 Nov 2009 17:37:59 -0800
 Subject: Re: table inside a td in wicket table
 To: users@wicket.apache.org
 
 show us some code.
 
 -igor
 
 On Wed, Nov 4, 2009 at 5:06 PM, Swarnim Ranjitkar swarn...@hotmail.com 
 wrote:
 
   I'm trying put a table inside a td in datatable so that my column can 
  have more than one row I overode  the createLableModel method and tried to 
  but html tag like this
  wicket:panel 
  tabletbodytrtdfads/td/trtrtdfdsafas/td/tr/tbody/tabletable
   /table/wicket:panel
  look like it everything in a cell is put under
  td wicket:id=cells  span wicket:id=cell
 
  because it of  span wicket:id=cell it gets displayed as text. Is there 
  anyway you could overide this or any better way of doing this
  thank you
 
 
 
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
  

RE: table inside a td in wicket table

2009-11-04 Thread Swarnim Ranjitkar

If you do that will it not put the panel with table inside span 
wicket:id=cell which will make anything inside it as literal string.

 From: igor.vaynb...@gmail.com
 Date: Wed, 4 Nov 2009 17:58:16 -0800
 Subject: Re: table inside a td in wicket table
 To: users@wicket.apache.org
 
 you should start by subclassing abstractcolumn and adding a panel that
 contains a table in populateitem()
 
 -igor
 
 On Wed, Nov 4, 2009 at 5:53 PM, Swarnim Ranjitkar swarn...@hotmail.com 
 wrote:
 
  Here are the two classes. What I was thinking was i would overide 
  createLabelModel and create table with the tag like below.
 
 
  import java.math.BigDecimal;
 
  import 
  org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
  import org.apache.wicket.markup.html.basic.Label
  ;
  import org.apache.wicket.markup.html.link.Link;
  import org.apache.wicket.markup.html.link.PopupSettings;
  import org.apache.wicket.markup.html.panel.Panel;
  import org.apache.wicket.markup.repeater.Item;
  import org.apache.wicket.model.AbstractReadOnlyModel;
  import org.apache.wicket.model.IModel;
 
  public class TablePropertyColumn extends PropertyColumn {
 
 
 
 public TablePropertyColumn(IModel displayModel,
 final String sortProperty, final String propertyExpression) {
 super(displayModel, sortProperty, propertyExpression);
 // TODO Auto-generated constructor stub
 }
 
 
 
 protected IModel createLabelModel(final IModel rowModel) {
 final IModel prop = super.createLabelModel(rowModel);
 return new AbstractReadOnlyModel() {
 public Object getObject() {
 String data = (String) prop.getObject();
 // will get it from the object and create table
 dataString = wicket:panel 
  tabletbodytrtdfads/td/trtrtdfdsafas/td/tr/tbody/tabletable
   /table/wicket:panel;
 
 return dataString;
 
 }
 };
 }
 
  }
 
 
 
  import java.util.ArrayList;
  import java.util.List;
 
  import org.apache.wicket.markup.html.panel.Panel;
  import 
  org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable;
  import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
  import 
  org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
  import org.apache.wicket.model.Model;
 
  import com.swishmark.tugboat.util.ReportTemplateListProvider;
  import com.swishmark.tugboat.util.TablePropertyColumn;
 
  // http://cwiki.apache.org/WICKET/simple-sortable-datatable-example.html
  // AJAX: 
  http://www.wicket-library.com/wicket-examples/repeater/?wicket:bookmarkablePage=:org.apache.wicket.examples.repeater.AjaxDataTablePage
 
  public class RelatedProductListPanel extends Panel {
 
 public RelatedProductListPanel(String id, int transNodeId) {
 super(id);
 
 ListIColumn? columns = new ArrayListIColumn?();
 columns.add(new PropertyColumn(new Model(product_id), 
  product_id, product_id));
 columns.add(new PropertyColumn(new Model(Name), name, name));
 columns.add(new PropertyColumn(new Model(Status), status, 
  status));
 columns.add(new PropertyColumn(new Model(vertical), vertical, 
  vertical));
 columns.add(new TablePropertyColumn(new Model(transname), 
  transname, transname));
 add(new AjaxFallbackDefaultDataTable(relatedProductListTable, 
  columns, new RelatedProductListProvider(transNodeId), 8));
 }
  }
  -
  Even though I use a panel and write my own and populate my panel i
  think  it will put everything inside wicket:cell . I'm looking
  for a way so that it doesn't write the tag.
 
  public void populateItem(Item item, String componentId, IModel model) {
 
 item.add(new TablePanel(item, componentId, model));
 
 
 
  wicket:panel
 
  table
 
   tr wicket:id=tablerow
 
td wicket:id=tabletd/td
 
   /tr
 
   /table
 
  /wicket:panel
 
 
  From: igor.vaynb...@gmail.com
  Date: Wed, 4 Nov 2009 17:37:59 -0800
  Subject: Re: table inside a td in wicket table
  To: users@wicket.apache.org
 
  show us some code.
 
  -igor
 
  On Wed, Nov 4, 2009 at 5:06 PM, Swarnim Ranjitkar swarn...@hotmail.com 
  wrote:
  
I'm trying put a table inside a td in datatable so that my column can 
   have more than one row I overode  the createLableModel method and tried 
   to but html tag like this
   wicket:panel 
   tabletbodytrtdfads/td/trtrtdfdsafas/td/tr/tbody/tabletable
/table/wicket:panel
   look like it everything in a cell is put under
   td wicket:id=cells  span wicket:id=cell
  
   because it of  span wicket:id=cell it gets displayed as text. Is 
   there anyway you could overide this or any better way of doing this
   thank you
  
  
  
  
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h

Using email in SignInPanel Username

2009-10-27 Thread Swarnim Ranjitkar

I'm trying to use wicket signinpanel . When and choose remember me checkbox and 
use email address in username  (eg@ttt.com , next time when i come it it 
just remembers abc as user name instead of a...@ttt.com). It seems when storing 
and retreving value from cookies we need to encode and decode the value . It 
doesn't look like wicket is doing this by default which is why this is 
happening. Does any one know what is the solution for this. 

html
head
titleSign In/title
link rel=stylesheet type=text/css href=style.css/
style
body { background-image: none; }
/style
/head
body
h2Sign In/h2

span wicket:id=signInPanel/
/body
/html

thank you
  

refreshing AjaxFallbackDefaultDataTable

2009-10-23 Thread Swarnim Ranjitkar

If I attach AjaxSelfUpdatingTimerBehavior to  AjaxFallbackDefaultDataTable 
should it refresh   AjaxFallbackDefaultDataTable at the set interval. Is it 
possible to refresh datatable every 10 sec using this. Looks like it refreshes 
the datatable but it doesn't call ReportListProvider to refresh the data before 
it refreshes the datatable. could you please let me know what is the best way 
to do this.


 final AjaxFallbackDefaultDataTable datatable = new 
AjaxFallbackDefaultDataTable(listdatatable, columns, new 
ReportListProvider(ABC, true), 8);

datatable.add(new 
AjaxSelfUpdatingTimerBehavior(Duration.seconds(10)) {
@Override
protected void onPostProcessTarget(AjaxRequestTarget 
target) {
 System.out.println(called);
}
}); 
thank you
 
  

RE: AjaxFallbackLink problem on Internet Explorer 6

2009-10-22 Thread Swarnim Ranjitkar

Thank you for you suggestion. It didn't really work. Looks like the setvisible 
inside  onclick doesn't work . Here is the code that I have
 //this.replaceWith(replacement);
replacement.setOutputMarkupId(true);
datatable.replaceWith(replacement);
showMineSpan.setVisible(true);
showAllSpan.setVisible(false);
showMineSpan.setOutputMarkupId(true);
showAllSpan.setOutputMarkupId(true);
target.addComponent(showMineSpan);
target.addComponent(showAllSpan);
target.addComponent(replacement);

}
};
showAllLink.setOutputMarkupId(true);



 Date: Thu, 22 Oct 2009 18:05:46 -0700
 Subject: Re: AjaxFallbackLink problem on Internet Explorer 6
 From: danelave...@gmail.com
 To: users@wicket.apache.org
 
 You need to add the spans to the target in onClick, and the links need to
 have their outputMarkupId set to true, as follows (I've added the ***
 lines):
 
 final Link showMineLink =new AjaxFallbackLink(trafficreportlistmine) {
   public void onClick(AjaxRequestTarget target) {
  AjaxFallbackDefaultDataTable replacement = new
 AjaxFallbackDefaultDataTable(trafficreportlistdatatable, columns, new
 ReportListProvider(Traffic, mine), 8);
 //this.replaceWith(replacement);
 replacement.setOutputMarkupId(true);
 datatable.replaceWith(replacement);
 showMineSpan.setVisible(true);
 showAllSpan.setVisible(false);
 target.addComponent(replacement);
 ***target.addComponent(showMineSpan);
 ***target.addComponent(showAllSpan);
   }
 };
 *** showMineLink.setOutputMarkupId(true);
 
 Then do the same with the other link.
 
 Dane
 
 
 On Thu, Oct 22, 2009 at 4:42 PM, wicketnewuser swarn...@hotmail.com wrote:
 
 
  It's suppose to hide Show All and show Show Mine when I click on Show All
  but
  that doesn't happen. on the onclick of showmine it is supposed to be
 showMineSpan.setVisible(false);
 showAllSpan.setVisible(true);
  instead of  what I listed earlier as
  showMineSpan.setVisible(true);
 showAllSpan.setVisible(false);
 
 
  wicketnewuser wrote:
  
   Hi tried to follow this and having problem with it . Could someone please
   let me know what I'm doing wrong
   Here is the code
   package com.swishmark.tugboat;
  
   import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.List;
  
   import org.apache.wicket.PageParameters;
   import org.apache.wicket.Session;
   import org.apache.wicket.markup.html.WebMarkupContainer;
   import org.apache.wicket.markup.html.basic.Label;
   import org.apache.wicket.markup.html.link.Link;
   import org.apache.wicket.markup.html.panel.Panel;
   import org.apache.wicket.markup.repeater.Item;
   import org.apache.wicket.ajax.AjaxRequestTarget;
   import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
   import
  
  org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable;
   import
  
  org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
   import
   org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
   import
  
  org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
   import org.apache.wicket.model.IModel;
   import org.apache.wicket.model.Model;
  
   import com.swishmark.tugboat.util.DateTimePropertyColumn;
   import com.swishmark.tugboat.util.LinkPropertyColumn;
   import com.swishmark.tugboat.util.ReportListProvider;
   import com.swishmark.tugboat.util.TugboatReport;
  
   // http://cwiki.apache.org/WICKET/simple-sortable-datatable-example.html
   // AJAX:
  
  http://www.wicket-library.com/wicket-examples/repeater/?wicket:bookmarkablePage=:org.apache.wicket.examples.repeater.AjaxDataTablePage
  
   public class TrafficReportListPanel extends Panel {
  
 Integer contactId;
  
 public TrafficReportListPanel(String id, final String include) {
 super(id);
  
 final ListIColumn? columns = new
  ArrayListIColumn?();
  
 columns.add(new PropertyColumn(new Model(Report ID),
  reportId,
   reportId));
 columns.add(new PropertyColumn(new Model(Contact Name),
  contactName,
   contactName));
  
   //
  http://www.mail-archive.com/wicket-u...@lists.sourceforge.net/msg16575.html
 if (include != null  include.equals(running)){
 columns.add(new PropertyColumn(new Model(Report
  Name), reportName,
   reportName));
 } else {
 columns.add(new LinkPropertyColumn(new Model(Report
  Name),
   reportName, reportName) {
  
 @Override
 public void 

Right justify in DataTable

2009-10-13 Thread Swarnim Ranjitkar

If I user DefaultDataTable to display table. Is there a way justify the 
numberic column. eg.  I want NumberCol to be right justified then left

IColumn[] columns = new IColumn[2];
columns[0] = new PropertyColumn(new Model(NumberCol), NumberCol, 
NumberCol)
columns[1] = new PropertyColumn(new Model(Last Name), name.last, 
name.last);

DefaultDataTable table = new DefaultDataTable(datatable, columns, 
userProvider, 10);
  

Ajaxfallbackdefautldatatable sort

2009-10-12 Thread Swarnim Ranjitkar

Looks like ajaxfallbackdefaultdatatable column sort is aphabetical by default. 
Is there anyways I can make column sort by integer or date.
thank you