Re: Best way to work with the iterator of IDataProvider

2009-09-28 Thread cmoulliard

I have found the error.

List Result = new ArrayListPlatformDTO(); must be defined outside of the
iterator method

and also the answer to my question. 

When the result is empty or null, then I must return a null iterator



T Ames wrote:
 
 I see several undefined objects:
 
 result
 requestFormModel
 it
 
 If these are defined at the class level, they must be serializable.
 
 If you have Logging set at Info, Wicket will give you the actual field
 that
 is not serializable, although from the error it looks like something to do
 with AbstractList
 
 Iterator objects are not serializable.  I would look at how you are
 defining
 the it variable.
 
 
 
 On Mon, Sep 28, 2009 at 7:25 AM, Charles Moulliard
 cmoulli...@gmail.comwrote:
 
 Hi,

 I would like to know what is the best way to work with the method
 iterator of DataProvider.

 I have created a class implementing IDataProvider. Depending of a
 parameter, the DAO service called is not the same inside in the
 iterator method. For some DAO services, a list is returned but for one
 service, an object is returned instead of a list.

 If I try to create a ArrayList inside the iterator, the following
 error is generated :


 org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException:
 Unable to serialize class: java.util.AbstractList$Itr
 Field hierarchy is:
  0 [class=com.xpectis.x3s.fundbox.web.RequestPage, path=0]
private java.lang.Object
 org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;]
  java.lang.Object org.apache.wicket.Component.data[3]
 [class=com.xpectis.x3s.fundbox.web.RequestPage$1, path=0:requestList]
private final
 org.apache.wicket.markup.repeater.data.IDataProvider
 org.apache.wicket.markup.repeater.data.DataViewBase.dataProvider
 [class=com.xpectis.x3s.fundbox.web.data.RequestProvider]
  private java.util.Iterator
 com.xpectis.x3s.fundbox.web.data.RequestProvider.it
 [class=java.util.AbstractList$Itr] - field that is not
 serializable
at
 org.apache.wicket.util.io.SerializableChecker.check(SerializableChecker.java:346)

 How can I avoid this issue ?

 Here is my code :

 public class RequestProvider implements IDataProvider {

 ...

public Iterator iterator(int first, int count) {

result = new ArrayListPlatformDTO();

if (requestFormModel != null) {

if (requestFormModel.getId() != null) {
request =
 requestService.getRequest(requestFormModel.getId());
result.add(request);
it = result.iterator();

} else if (requestFormModel.getFileName() != null)
 {
it =
 requestService.findRequestByFileName(requestFormModel.getFileName()).iterator();

}

 Regards,


 Charles Moulliard
 Senior Enterprise Architect
 Apache Camel Committer

 *
 blog : http://cmoulliard.blogspot.com

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


 
 


-
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 
http://www.nabble.com/Best-way-to-work-with-the-iterator-of-IDataProvider-tp25644122p25645386.html
Sent from the Wicket - User 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



Re: Is it the best way to code a Link depending on a condition

2009-09-25 Thread cmoulliard

In fact, the example createLabel is not really the most interesting. Let's me
explaining what I consider as a good candidate and what I have done

1) A HTML page contains a table which is populated dynamically using a
service collecting data from a DB. the last column of the table is a link
(wicket id=linkRequest) that we would like to show or not depending if we
have receive from the DB, the id (= primary key of the table DB)
corresponding to the record Request to be opened in the screen page
Request.html / RequestPage)

2) The populateItem method of the DataView allows me for each record to link
the model (= item) returned by the IDataprovider to the columns of my table.
To create the link to the HTML page, I use the Link class that I have
modified like this :

public class LinkRequestT extends LinkT {

private static final long serialVersionUID = 3283912033862898645L;
private RequestFormModel requestFormModel;

public LinkRequest(String id) {
super(id);
}

@Override
public void onClick() {
setResponsePage(new RequestPage(requestFormModel)); 
}

public RequestFormModel getRequestFormModel() {
return requestFormModel;
}

public void setRequestFormModel(RequestFormModel requestFormModel) {
this.requestFormModel = requestFormModel;
}   

}

As you see the onClick() method is defined so I don't need to modify it when
I add the link to my item. To create the link, I call a createLinkRequest
Method who play the role of a factory for me 

public static LinkRequest createLinkRequest(String id) {

LinkRequest linkReq = new LinkRequest(linkRequest);

if ( id != null ) {

// Link is enable with parameters required to open 
RequestPage
RequestFormModel requestFormModel = new 
RequestFormModel();
requestFormModel.setId( Integer.parseInt( id ) );
linkReq.setRequestFormModel(requestFormModel);

linkReq.add(getLinkRequestTxt( id ));

} else {
// Link is disable
linkReq.add(getLinkRequestTxt());
linkReq.setEnabled(false);

}

return linkReq;

}

and I call this method from my polulateItem like this 

item.add( createLinkRequest( id which is equal to null or to a value ) );

Depending if the value is null or not, the link will be enable or disabled
and the model required by my page request created accordingly.

Is it a correct implementation or a stupid one ? In a previous reply,
someone argues that we must override the method isEnabled() instead of using
setEnable() ?

Regards,

Charles


josephpachod wrote:
 
 hi Charles
 
 The whole issue is that you don't know how the data (in this case a
 String) is to be retrieved. Can it be read only once ? Should it be
 refresh on each request cycle ? On each access to the data ? Does it come
 from a database ?
 
 Wicket's model allows you to go away from all these considerations : you
 just want to be able to get the string. Just let the users of your wicket
 component decide how they want to provide the data.
 
 As such, your example is, I think, broken :
  private Label labelTitle;
  public static Label createLabelTitle(String title) {
  return new Label(title,new PropertyModel( ModelClass, title ));
  }
 
 What if someone wants to change this string ? title = my new title won't
 work there !
 
 Thus, it should be, IMO :
  public static Label createLabelTitle(final IModelString titleModel) {
  return new Label(title,titleModel.get());
  }
 
 ++
 
 NB : you might be interested by this article
 http://blog.jteam.nl/2009/09/16/wicket-dos-and-donts/
 

 Joseph,

 Can you explain a little bit what you mean by provide it with attribute
 (IModelString) ?

  private Label labelTitle;
  public static Label createLabelTitle(String title) {
  return new Label(title,new Model( title ));
  }

 -- becomes

  private Label labelTitle;
  public static Label createLabelTitle(String title) {
  return new Label(title,new PropertyModel( ModelClass, title ));
  }

 Is it right what I create ?


 Joseph Pachod wrote:

 cmoulliard wrote:
 What I have done to avoid to repeat the creation of the labels is to
 define
 and use static method

private Label labelTitle;
public static Label getLabelTitle(String title) {
return new Label(title,new Model( title ));
}

 I personally would name this method createLabelTitle(String title) or
 getNewLabelTitle(String title), for explicitness.

 Furthermore, I would directly

Re: Is it the best way to code a Link depending on a condition

2009-09-21 Thread cmoulliard

Joseph,

Can you explain a little bit what you mean by provide it with attribute
(IModelString) ?

private Label labelTitle;
public static Label createLabelTitle(String title) {
return new Label(title,new Model( title ));
}

-- becomes

private Label labelTitle;
public static Label createLabelTitle(String title) {
return new Label(title,new PropertyModel( ModelClass, title ));
}

Is it right what I create ?


Joseph Pachod wrote:
 
 cmoulliard wrote:
 What I have done to avoid to repeat the creation of the labels is to
 define
 and use static method 

  private Label labelTitle;
  public static Label getLabelTitle(String title) {
  return new Label(title,new Model( title ));
  }
   
 I personally would name this method createLabelTitle(String title) or 
 getNewLabelTitle(String title), for explicitness.
 
 Furthermore, I would directly provide it with a final IModelString 
 title attribute, not to dictate how the data has to be provided 
 (dynamic or not for example).
 
 In the end, this method is fine for just a label, but for anything more 
 complex a panel would be the way to go I would say. The main exception 
 here I see right now is the case of pages.
 
 For example, if we're speaking of a page title, then I would define it 
 in my base page and make an abstract String getTitle() method in the 
 base page so I'm sure everyone set it up later on. I would do the same 
 if it's a specific kind of structured page, for example an abstract 
 class ContentHoldingPage extend TheBasePage.
 
 ++
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 


-
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 
http://www.nabble.com/Is-it-the-best-way-to-code-a-Link-depending-on-a-condition-tp25488603p25530206.html
Sent from the Wicket - User 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



Re: Is it the best way to code a Link depending on a condition

2009-09-18 Thread cmoulliard

What I have done to avoid to repeat the creation of the labels is to define
and use static method 

private Label labelTitle;
public static Label getLabelTitle(String title) {
return new Label(title,new Model( title ));
}


Joseph Pachod wrote:
 
 cmoulliard wrote:
 (...)
 I think that this is a general remark that some users make about Wicket.
 It
 is very difficult to reuse part of the code.

 Here is another example :

 I have a label called id which is used in different page. The way
 proposes
 by Wicket to code it is 

 Page Request

 item.add(new Label(id, String.valueOf(request.getId(;

 Page Notification

 item.add(new Label(id, String.valueOf(notification.getId(;

 When we compare page request and page notification, we see that we repeat
 the same code two times.
 Hi
 
 I think the wicket way here may be to create a panel containing this 
 label and then reuse the panel. The panel could also have a model in 
 order to get the label content.
 
 Would this solve your repetition issue ?
 
 ++
 joseph
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 


-
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 
http://www.nabble.com/Is-it-the-best-way-to-code-a-Link-depending-on-a-condition-tp25488603p25504977.html
Sent from the Wicket - User 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



Re: Is it the best way to code a Link depending on a condition

2009-09-17 Thread cmoulliard

You are right. I don't need the setEnabled(false) in the onClick method

I have changed my code :

link = new Link(linkRequest) {

@Override
public void onClick() {
setResponsePage(new 
RequestPage(requestFormModel));
}

};

link.add(new
Label(linkRequestTxt,String.valueOf(audit.getRequest().getId(;
item.add(link);

} else {
link = new Link(linkRequest) {

@Override
public void onClick() { }

};
Label label = new 
Label(linkRequestTxt,);
link.add(label);
link.setEnabled(false);
item.add(link);
}

Remark : 

It should be interesting to be able to create an instance of the Link class
without having to override the onclick() method. Otherwise the code becomes
very verbose and requires as here that we instantiate two times the class
Link


Matthias Keller wrote:
 
 Sure, just create it (including the onClick which might be invalid), but 
 afterwards set the  setEnabled()  as needed.
 As long as the link is disabled, it can never be clicked thus the 
 onClick() will never be executed anyway, so it's irrelevant if the 
 requestFormModel is valid or not...
 I dont think you want the setEnabled(false) inside the onClick - do you? 
 That would deactivate the link after the first click which doesn't make 
 that much sense?
 
 Matt
 
 Charles Moulliard wrote:
 Hi,

 I would like to know if there is a better way to code this case : What
 I would like to do is to enable/disable a link depending on a
 condition. If the condition is true, than we create the link otherwise
 we disable it. In both case, a label must be defined for the Link.

 I mean, is it possible to avoid to double the creation of the link =
 new Link() 

 Here is my code

 1) HTML

 #  wicket:id=linkRequestTxt/ 


 2) JAVA

 // Set link for requestId
 Link link;

 if (audit.getRequest() != null) {

 final RequestFormModel requestFormModel = new
 RequestFormModel();
 requestFormModel.setRequestId( (int)
 audit.getRequest().getId() );

 link = new Link(linkRequest) {

 @Override
 public void onClick() {
 setResponsePage(new
 RequestPage(requestFormModel));
 }

 };

 link.add(new
 Label(linkRequestTxt,String.valueOf(audit.getRequest().getId(;
 item.add(link);

 } else {
 link = new Link(linkRequest) {

 @Override
 public void onClick() {
 this.setEnabled(false);
 }

 };
 Label label = new Label(linkRequestTxt,);
 link.add(label);
 item.add(link);


 Charles Moulliard
 Senior Enterprise Architect
 Apache Camel Committer

 *
 blog : http://cmoulliard.blogspot.com

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

   
 
 
 -- 
 matthias.kel...@ergon.ch  +41 44 268 83 98
 Ergon Informatik AG, Kleinstrasse 15, CH-8008 Zürich
 http://www.ergon.ch
 __
 e r g o nsmart people - smart software
 
 
 
  
 


-
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 
http://www.nabble.com/Is-it-the-best-way-to-code-a-Link-depending-on-a-condition-tp25488603p25488926.html
Sent from the Wicket - User 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



Re: Is it the best way to code a Link depending on a condition

2009-09-17 Thread cmoulliard

Mattias,

OK about what you propose but we repeat the test a second time so the code
still remains very verbose.
Thanks for the suggestion.

I think that this is a general remark that some users make about Wicket. It
is very difficult to reuse part of the code.

Here is another example :

I have a label called id which is used in different page. The way proposes
by Wicket to code it is 

Page Request

item.add(new Label(id, String.valueOf(request.getId(;

Page Notification

item.add(new Label(id, String.valueOf(notification.getId(;

When we compare page request and page notification, we see that we repeat
the same code two times.

It could be interesting to set the value of the label in the page and to
declare it separately

e.g

public class Commons {

public static Label labelId = new Label(id);
...
}


Page Request

item.add( labelId.setValue( String.valueOf(request.getId()) );

Page Notification

item.add( labelId.setValue( String.valueOf(notification.getId()) );

Regards,

Charles


Matthias Keller wrote:
 
 Hi
 
 As I said in my previous mail, just initialize the link once using the 
 upper variant.
 Use an if before to create the requestFormModel, in case 2, the 
 requestFormModel can be null - as the onClick is never executed this 
 will not matter.
 Have something like:
 
 final Model requestFormModel;
 if (case1)
 requestFormModel = new MyModel(...);
 else
 requestFormModel = null;
 
 // Creating the one and only Link instance.
 link = new Link(linkRequest) {
 public void onClick() {
setResponsePage(new RequestPage(requestFormModel));
 }
 }
 item.add(link);
 
 if (case1) {
 link.add(whatever);
 ...
 } else {
 link.add(whatever for case 2);
 link.setEnabled(false);
 }
 
 
 cmoulliard wrote:
 You are right. I don't need the setEnabled(false) in the onClick method

 I have changed my code :

  link = new Link(linkRequest) {

  @Override
  public void onClick() {
  setResponsePage(new 
 RequestPage(requestFormModel));
  }
  
  };
  
  link.add(new
 Label(linkRequestTxt,String.valueOf(audit.getRequest().getId(;
  item.add(link);

  } else {
  link = new Link(linkRequest) {

  @Override
  public void onClick() { }
  
  };
  Label label = new 
 Label(linkRequestTxt,);
  link.add(label);
  link.setEnabled(false);
  item.add(link);
  }

 Remark : 

 It should be interesting to be able to create an instance of the Link
 class
 without having to override the onclick() method. Otherwise the code
 becomes
 very verbose and requires as here that we instantiate two times the class
 Link


 Matthias Keller wrote:
   
 Sure, just create it (including the onClick which might be invalid), but 
 afterwards set the  setEnabled()  as needed.
 As long as the link is disabled, it can never be clicked thus the 
 onClick() will never be executed anyway, so it's irrelevant if the 
 requestFormModel is valid or not...
 I dont think you want the setEnabled(false) inside the onClick - do you? 
 That would deactivate the link after the first click which doesn't make 
 that much sense?

 Matt

 Charles Moulliard wrote:
 
 Hi,

 I would like to know if there is a better way to code this case : What
 I would like to do is to enable/disable a link depending on a
 condition. If the condition is true, than we create the link otherwise
 we disable it. In both case, a label must be defined for the Link.

 I mean, is it possible to avoid to double the creation of the link =
 new Link() 

 Here is my code

 1) HTML

 #  wicket:id=linkRequestTxt/ 


 2) JAVA

 // Set link for requestId
 Link link;

 if (audit.getRequest() != null) {

 final RequestFormModel requestFormModel = new
 RequestFormModel();
 requestFormModel.setRequestId( (int)
 audit.getRequest().getId() );

 link = new Link(linkRequest) {

 @Override
 public void onClick() {
 setResponsePage(new
 RequestPage(requestFormModel));
 }

 };

 link.add

Re: DropDownChoice with Java Enum

2009-09-11 Thread cmoulliard

If understand correctly, the value displayed in as value in the html options
will not be used to set my requestStatus property in the model class
RequestFormModel but use by the DropDownchoice to find the value to be
setted (like key for hashmap, index for array, ...).

In consequenc,e I have to change the code of my property setter inside my
model to set the value (coming from the ENUM) :

public void setRequestType(String requestType) {
// Set requestType field with the value (and not the 
description) of the
enum
this.requestType = ProcessingStatusType.valueOf( requestType 
).getValue();
}



Pedro Santos-6 wrote:
 
 The value on model are on ProcessingStatusType instance. Use
 ((ProcessingStatusType)model.getObject()).getValue() to access the value
 REJEC
 
 
 On Thu, Sep 10, 2009 at 12:39 PM, cmoulliard cmoulli...@gmail.com wrote:
 

 Thks for all.

 With the following syntax :

add(new DropDownChoice(requestStatus,
 Arrays.asList(ProcessingStatusType.values()), new IChoiceRenderer() {

 public Object getDisplayValue(Object status) {
return ((ProcessingStatusType)
 status).getDescription();
}

public String getIdValue(Object status, int index)
 {
return ((ProcessingStatusType)
 status).getValue();
}}));

 html generated :

 select wicket:id=requestStatus name=requestStatus
 option selected=selected value=Choose One/option
 option value=NEWNew/option
 option value=ACCPTAccepted/option

 option value=VALIDValidated/option
 option value=TRFRMTransformed/option
 option value=TRFRDTransferred/option
 option value=REJECRejected/option
 option value=FAILFailed/option
 /select

 Everything is ok except that the value receives by my RequestFormModel
 after
 the post is equal to the description (e.g : REJECTED instead of REJEC)
 and
 not the value 






 Here is what I have in html :



 Matthias Keller wrote:
 
  Hi
 
  Close but not quite. getDisplayValue gets the catual ELEMENT of the
 list
  - so objDispl is of type ProcessingStatusType already.
  So in your case it would be something like:
 
  public Object getDisplayValue(Object objDispl) {
   return ((ProcessingStatusType) objDispl).getDescription();
  }
 
  public String getIdValue(Object obj, int index) {
   return obj.toString();
   // or if you prefer to have the value of your enum in the HTML
 code:
   // return ((ProcessingStatusType) objDispl).getValue()
  }
  Which one of the getIdValue implementations you chose doesn't matter
 for
  wicket, it just needs an ID for every entry which is unique.
  In your case you could even   return String.valueOf(index)   as your
  backing List of the Enums will not ever change while deployed.
 
  Be careful though with using index, there are circumstances where no
  useful index will be provided (always -1) - That happens when you
  externally change the selected value of the DropDownChoice.
 
  you could also just use or extend ChoiceRenderer which might already do
  what you want...
  For example
  new ChoiceRenderer(description, value)
 
  Matt
 
  cmoulliard wrote:
  You mean create something like this :
 
  add(new DropDownChoice(requestStatus,
  Arrays.asList(ProcessingStatusType.values()), new IChoiceRenderer() {
 
   public Object getDisplayValue(Object objDispl) {
   return
 ProcessingStatusType.valueOf((String)
  objDispl).getDescription();
   }
 
   public String getIdValue(Object obj, int index) {
   return obj.toString();
   }}));
 
  I have an error during initialisation :
 
  WicketMessage: Exception in rendering component: [MarkupContainer
  [Component
  id = requestStatus]]
 
  Root cause:
 
  java.lang.ClassCastException:
  com.xpectis.x3s.model.usertype.ProcessingStatusType
  at
 
 com.xpectis.x3s.fundbox.web.form.RequestForm$1.getDisplayValue(RequestForm.java:38)
 
  I suppose that what I defined in getDisplayValue is not correct ?
 
  Matthias Keller wrote:
 
  Hi Charles
 
  No problem. Just make an IChoiceRenderer which calls getDescription
 for
  the display value and getValue for the id.
 
  Matt
 
  Charles Moulliard wrote:
 
  Hi,
 
  I would like to know if I can create a DropDownChoice where the
 value
  to
  be
  displayed in the drop down list corresponds to the description of my
  enumeration (e.g. Accepted) while the value to be returned is the
 value
  defined in the enumeration (e.g: ACCPT) ?
 
  public enum ProcessingStatusType {
  NEW (NEW, New),
  ACCEPTED (ACCPT, Accepted),
  VALIDATED (VALID, Validated),
  TRANSFORMED(TRFRM, Transformed),
  TRANSFERRED(TRFRD, Transferred),
  REJECTED(REJEC, Rejected),
  FAILED(FAIL, Failed);
 
  private final String value;
  private final String

Re: DropDownChoice with Java Enum

2009-09-10 Thread cmoulliard

You mean create something like this :

add(new DropDownChoice(requestStatus,
Arrays.asList(ProcessingStatusType.values()), new IChoiceRenderer() {

public Object getDisplayValue(Object objDispl) {
return ProcessingStatusType.valueOf((String) 
objDispl).getDescription();
}

public String getIdValue(Object obj, int index) {
return obj.toString(); 
}}));

I have an error during initialisation :

WicketMessage: Exception in rendering component: [MarkupContainer [Component
id = requestStatus]]

Root cause:

java.lang.ClassCastException:
com.xpectis.x3s.model.usertype.ProcessingStatusType
at
com.xpectis.x3s.fundbox.web.form.RequestForm$1.getDisplayValue(RequestForm.java:38)

I suppose that what I defined in getDisplayValue is not correct ?

Matthias Keller wrote:
 
 Hi Charles
 
 No problem. Just make an IChoiceRenderer which calls getDescription for 
 the display value and getValue for the id.
 
 Matt
 
 Charles Moulliard wrote:
 Hi,

 I would like to know if I can create a DropDownChoice where the value to
 be
 displayed in the drop down list corresponds to the description of my
 enumeration (e.g. Accepted) while the value to be returned is the value
 defined in the enumeration (e.g: ACCPT) ?

 public enum ProcessingStatusType {
 NEW (NEW, New),
 ACCEPTED (ACCPT, Accepted),
 VALIDATED (VALID, Validated),
 TRANSFORMED(TRFRM, Transformed),
 TRANSFERRED(TRFRD, Transferred),
 REJECTED(REJEC, Rejected),
 FAILED(FAIL, Failed);

 private final String value;
 private final String description;

 ProcessingStatusType( String value, String description ) {
 this.value = value;
 this.description = description;
 }

   
 
 
  
 


-
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 
http://www.nabble.com/DropDownChoice-with-Java-Enum-tp25382303p25382688.html
Sent from the Wicket - User 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



Re: DropDownChoice with Java Enum

2009-09-10 Thread cmoulliard

Thks for all.

With the following syntax :

add(new DropDownChoice(requestStatus,
Arrays.asList(ProcessingStatusType.values()), new IChoiceRenderer() {

public Object getDisplayValue(Object status) {
return ((ProcessingStatusType) status).getDescription();
} 

public String getIdValue(Object status, int index) {
return ((ProcessingStatusType) 
status).getValue(); 
}}));

html generated :

select wicket:id=requestStatus name=requestStatus
option selected=selected value=Choose One/option
option value=NEWNew/option
option value=ACCPTAccepted/option

option value=VALIDValidated/option
option value=TRFRMTransformed/option
option value=TRFRDTransferred/option
option value=REJECRejected/option
option value=FAILFailed/option
/select

Everything is ok except that the value receives by my RequestFormModel after
the post is equal to the description (e.g : REJECTED instead of REJEC) and
not the value 






Here is what I have in html :



Matthias Keller wrote:
 
 Hi
 
 Close but not quite. getDisplayValue gets the catual ELEMENT of the list 
 - so objDispl is of type ProcessingStatusType already.
 So in your case it would be something like:
 
 public Object getDisplayValue(Object objDispl) {
  return ((ProcessingStatusType) objDispl).getDescription();
 }

 public String getIdValue(Object obj, int index) {
  return obj.toString();
  // or if you prefer to have the value of your enum in the HTML code:
  // return ((ProcessingStatusType) objDispl).getValue()
 }
 Which one of the getIdValue implementations you chose doesn't matter for 
 wicket, it just needs an ID for every entry which is unique.
 In your case you could even   return String.valueOf(index)   as your 
 backing List of the Enums will not ever change while deployed.
 
 Be careful though with using index, there are circumstances where no 
 useful index will be provided (always -1) - That happens when you 
 externally change the selected value of the DropDownChoice.
 
 you could also just use or extend ChoiceRenderer which might already do 
 what you want...
 For example
 new ChoiceRenderer(description, value)
 
 Matt
 
 cmoulliard wrote:
 You mean create something like this :

 add(new DropDownChoice(requestStatus,
 Arrays.asList(ProcessingStatusType.values()), new IChoiceRenderer() {

  public Object getDisplayValue(Object objDispl) {
  return ProcessingStatusType.valueOf((String)
 objDispl).getDescription();
  }

  public String getIdValue(Object obj, int index) {
  return obj.toString(); 
  }}));
 
 I have an error during initialisation :

 WicketMessage: Exception in rendering component: [MarkupContainer
 [Component
 id = requestStatus]]

 Root cause:

 java.lang.ClassCastException:
 com.xpectis.x3s.model.usertype.ProcessingStatusType
 at
 com.xpectis.x3s.fundbox.web.form.RequestForm$1.getDisplayValue(RequestForm.java:38)

 I suppose that what I defined in getDisplayValue is not correct ?

 Matthias Keller wrote:
   
 Hi Charles

 No problem. Just make an IChoiceRenderer which calls getDescription for 
 the display value and getValue for the id.

 Matt

 Charles Moulliard wrote:
 
 Hi,

 I would like to know if I can create a DropDownChoice where the value
 to
 be
 displayed in the drop down list corresponds to the description of my
 enumeration (e.g. Accepted) while the value to be returned is the value
 defined in the enumeration (e.g: ACCPT) ?

 public enum ProcessingStatusType {
 NEW (NEW, New),
 ACCEPTED (ACCPT, Accepted),
 VALIDATED (VALID, Validated),
 TRANSFORMED(TRFRM, Transformed),
 TRANSFERRED(TRFRD, Transferred),
 REJECTED(REJEC, Rejected),
 FAILED(FAIL, Failed);

 private final String value;
 private final String description;

 ProcessingStatusType( String value, String description ) {
 this.value = value;
 this.description = description;
 }

   
   
 
  
 


-
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 
http://www.nabble.com/DropDownChoice-with-Java-Enum-tp25382303p25385339.html
Sent from the Wicket - User 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



Re: Form and PageParameters

2009-09-07 Thread cmoulliard

Thx for the reply. 

You are right, it is not a must to use PageParameters but as this is my
first Wicket project, I have started to work with simple things.

In the meantime, I have had a look to the formInput example where a
CompoundPropertyModel is used. I have adapted the Form to work with it.

My question is now :

When I call the first time my page, the url is : http://localhost/request.
Wicket receives this request and the constructor RequestPage(PageParameter
pageParameter) is called. Next, after filling my form in the page and
clicking on the onSubmit button, the request is submitted to the same page. 

How can I retrieve the values of the CompoundPropertyModel from my form in
this case ? Do I have to do something particular in the
setResponsePage(RequestPage.Class) to pass the compoundPropertyModel ? Do I
need to create two different constructors : one for PageParameters and the
other to handle CompoundPropertyModel ?

Regards,

Charles


egolan74 wrote:
 
 Is it a must that you use PageParameters for RequestPage?
 Do you need an access to it also from a URL (after mounting it in your
 Application).
 
 I think that a nicer way is to add a constructor that accepts the values.
 Even better, I would have created a POJO model.
 Use a CompoundPropertyModel with the form, and pass this object to the
 RequestPage.
 
 Eyal Golan
 egola...@gmail.com
 
 Visit: http://jvdrums.sourceforge.net/
 LinkedIn: http://www.linkedin.com/in/egolan74
 
 P  Save a tree. Please don't print this e-mail unless it's really
 necessary
 
 
 On Mon, Sep 7, 2009 at 11:38 AM, Charles Moulliard
 cmoulli...@gmail.comwrote:
 
 Hi,

 I have created a RequestPage html page containing a form (= search
 criteria) and a list (= Data View where the result set of data retrieved
 in
 a DB according to search criteria is displayed). When the user clicks on
 the
 search criteria button of this page, the request is redirected to the
 RequestPage where we extract the search criteria values and pass them to
 the
 service in charge to retrieve the data. In the java class accompagning
 this
 page, I have overrided the onSubmit method of the submit button to pass
 the value of the form fields

public RequestPage(final PageParameters parameters) {
 ...
   Form form = new Form(searchCriteriaRequest);

// Add fields
fRequestId = new TextField(fRequestId, new Model());
fFileName = new TextField(fFileName, new Model());
form.add(fRequestId);
form.add(fFileName);

// Add buttons
button = new Button(button) {
@Override
public void onSubmit() {
parameters.add(requestId, fRequestId.getValue());
parameters.add(fileName, fFileName.getValue());
setResponsePage(RequestPage.class, parameters);
}
};
form.add(button);
add(form);

 In the constructor of this RequestPage, I call a populate method with
 PageParameters

// Populate list with search criteria values
populateList(parameters.getKey(requestId),
 parameters.getKey(fileName));

 Questions :
 1) Is it the good way to handle PageParameters and Form in Wicket ? If
 this
 is not the case, can someone point me to a good example ?
 2) The fields filled in the previous post of my page are not removed when
 I
 repost a new request on my page. How can I reset these fields from the
 request of the new post ?

 Regards,

 Charles Moulliard
 Senior Enterprise Architect
 Apache Camel Committer

 *
 blog : http://cmoulliard.blogspot.com

 
 
 -
 Eyal Golan
 egola...@gmail.com
 
 Visit: JVDrums 
 LinkedIn: LinkedIn 
 


-
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 
http://www.nabble.com/Form-and-PageParameters-tp25326933p25328647.html
Sent from the Wicket - User 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



Modify class : org.apache.wicket.spring.SpringWebApplicationFactory (possible) ?

2009-04-01 Thread cmoulliard

Hi,

Is it possible to modify the following class :
org.apache.wicket.spring.SpringWebApplicationFactory
in order to retrieve the class org.springframework.osgi.BundleContext where
info about class loading are. This is required when Wicket is deployed on
OSGI server

Regards,

Charles Moulliard
SOA Architect

cmoulliard wrote:
 
  Hi,
 
 When I start my Apache Wicket bundle using Apache Service Mix (based on
 Felix and Spring DM), I receive the following error :
  Quote:
   16:35:58,415 | DEBUG | localShell | jetty |
 .service.internal.util.JCLLogger 85 | started
 org.ops4j.pax.web.service.internal.model.ServletMo del-66
 16:35:58,415 | INFO | localShell | HttpServiceProxy |
 ervice.internal.HttpServiceProxy 129 | Registering event listener
 [org.springframework.web.context.ContextLoaderListe n...@196dc61]
 16:35:58,415 | DEBUG | localShell | HttpServiceStarted |
 vice.internal.HttpServiceStarted 324 | Using context
 [ContextModel{id=org.ops4j.pax.web.service.internal
 .model.ContextModel-64,name=reportincident,httpContext=org.ops4j.pax.w
 eb.extender.war.internal.webapphttpcont...@fe404a,
 contextParams={webapp.context=reportincident,
 contextClass=org.springframework.osgi.web.context.
 support.OsgiBundleXmlWebApplicationContext}}]
 16:35:58,415 | INFO | localShell | /reportincident |
 .service.internal.util.JCLLogger 102 | Initializing Spring root
 WebApplicationContext
 16:35:58,415 | INFO | localShell | ContextLoader |
 mework.web.context.ContextLoader 189 | Root WebApplicationContext:
 initialization started
 16:35:58,415 | ERROR | localShell | ContextLoader |
 mework.web.context.ContextLoader 215 | Context initialization failed
 java.lang.IllegalArgumentException: bundle context should be set before
 refreshing the application context
 at org.springframework.util.Assert.notNull(Assert.jav a:112)
 at org.springframework.osgi.context.support.AbstractD
 elegatedExecutionApplicationContext.normalRefresh(
 AbstractDelegatedExecutionApplicationContext.java: 179)
 at org.springframework.osgi.context.support.AbstractD
 elegatedExecutionApplicationContext$NoDependencies
 WaitRefreshExecutor.refresh(AbstractDelegatedExecu
 tionApplicationContext.java:89)
 at org.springframework.osgi.context.support.AbstractD
 elegatedExecutionApplicationContext.refresh(Abstra
 ctDelegatedExecutionApplicationContext.java:175)
 at org.springframework.web.context.ContextLoader.crea
 teWebApplicationContext(ContextLoader.java:255)
 at org.springframework.web.context.ContextLoader.init
 WebApplicationContext(ContextLoader.java:199)
 at org.springframework.web.context.ContextLoaderListe
 ner.contextInitialized(ContextLoaderListener.java: 45)
 Here is the config of my web.xml file :
 
  Quote:
   ?xml version=1.0 encoding=ISO-8859-1?
 web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=
 http://www.w3.org/2001/XMLSchema-instance;
 xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee
 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd;
 version=2.4
 
 display-namereportincident.web/display-name
 
 context-param
 param-namecontextClass/param-name
 param-valueorg.springframework.osgi.web.context.support
 .OsgiBundleXmlWebApplicationContext/param-value
 /context-param
 
 listener
 listener-classorg.springframework.web.context.ContextLoade
 rListener/listener-class
 /listener
 
 filter
 filter-namewicket.reportincident.web/filter-name
 filter-classorg.apache.wicket.protocol.http.WicketFilter /filter-class
 init-param
 param-nameapplicationClassName/param-name
 param-valueorg.apache.camel.example.WicketApplication/param-value
 /init-param
 /filter
 
 filter-mapping
 filter-namewicket.reportincident.web/filter-name
 url-pattern/*/url-pattern
 /filter-mapping
 
 
 /web-app
 Any idea to solve this problem is welcome ?
 
 Regards,
 
 Charles
  __
 SOA Architect
 
 
 -
 Charles Moulliard
 SOA Architect
 
 My Blog : http://cmoulliard.blogspot.com/  
 


-
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 
http://www.nabble.com/java.lang.IllegalArgumentException%3A-bundle-context-should-be-set--before-refreshing-the-application-context-tp22807226p22825852.html
Sent from the Wicket - User 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



Re: example application for spring wicket hibernate

2009-02-06 Thread cmoulliard

Another very interesting example is described here in the java world
publication :

http://www.javaworld.com/javaworld/jw-09-2008/jw-09-wicket3.html

This is (from my point of view) the best spring/hibernate implementation see
with Wicket (have a look to the code of the example : scramble-spring)

Compare to the phonebook that I know, spring service dependency is injected
in the web page through @SpringBean which is not the case in phone-book
example

Regards,

Charles

yowzator wrote:
 
 It's in /trunk/wicketstuff-core/phonebook
 
 Tauren
 
 On Thu, Jan 22, 2009 at 12:21 PM, Dane Laverty
 danelave...@chemeketa.edu wrote:
 I'd like to check out the phonebook app as well, but I can't find it.
 The link at
 http://wicketstuff.org/confluence/display/STUFFWIKI/wicket-phonebook
 says the SVN repository is at
 https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wick
 et-phonebook/ . That doesn't work, but if I replace the https with http,
 then I get to a directory tree. However, I don't see any phonebook app
 under trunk in there. Am I missing something obvious?

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


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


-
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 
http://www.nabble.com/example-application-for-spring-wicket-hibernate-tp20293119p21874186.html
Sent from the Wicket - User 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



Bug in wicket-stuff phonebook

2009-02-06 Thread cmoulliard

Hi,

I would like to mention that there is a bug in the maven pom.xml file of the
project phonebook because the properties files located here
wicketstuff-core\phonebook\src\main\java\wicket\contrib\phonebook\web\page
are not at copied in the WAR generated. In consequence, the following error
is generated :

WicketMessage: Can't instantiate page using constructor public
wicket.contrib.phonebook.web.page.ListContactsPage()

Root cause:

java.util.MissingResourceException: Unable to find property: 'actions' for
component: [class=wicket.contrib.phonebook.web.page.ListContactsPage]
at org.apache.wicket.Localizer.getString(Localizer.java:342)
at org.apache.wicket.Localizer.getString(Localizer.java:118)
at org.apache.wicket.Component.getString(Component.java:1869)
at org.apache.wicket.Component.getString(Component.java:1856)

Can the owner of this application adapt the pom.xml to copy these properties
files in the WAR ?

Regards,




-
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 
http://www.nabble.com/Bug-in-wicket-stuff-phonebook-tp21869788p21869788.html
Sent from the Wicket - User 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



wicket-phonebook has been removed from svn ?

2009-02-04 Thread cmoulliard

Hi,

Can someone tell me where the project wicket-phonebook is located under svn
because the following link mentioned on this page is not correct/accurate
(http://wicketstuff.org/confluence/display/STUFFWIKI/wicket-phonebook/) ?

https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicket-phonebook/



-
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 
http://www.nabble.com/wicket-phonebook-has-been-removed-from-svn---tp21832291p21832291.html
Sent from the Wicket - User 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



RE: How to personalise HTML content with Wicket ?

2009-02-02 Thread cmoulliard

Thks.

Can I also use Model to define HTML section containing regular HTML with
wicket id ?

table
tdtrtrtr/td
td wicket id=


Additional question : in this case, where content is define dynamically,
which java class will trigger the wicket tags ?
 

Stefan Lindner wrote:
 
 Several Ways to to this. The easiest way for your example
 
 
 HTML:
 H2H2/
 
 In Java
 ModelString contentModel = new ModelString();
 add(new Label(content, contentModel));
 if (user=='admin'=
contenModel.setObject(Admin part);
 else if (user == 'anonymous')
contenModel.setObject(Anonymous part);
 
 
 
 
 
 Or in JAVA
 if (user=='admin'=
add(new Label(content, (Admin part));
 else if (user == 'anonymous')
add(new Label(content, (Anonymous part));
 
 
 -Ursprüngliche Nachricht-
 Von: cmoulliard [mailto:cmoulli...@gmail.com] 
 Gesendet: Montag, 2. Februar 2009 11:10
 An: users@wicket.apache.org
 Betreff: How to personalise HTML content with Wicket ?
 
 
 Hi,
 
 I would like to know how we can personalize the content with Wicket ?
 
 With framework like Struts, ... it is possible in a JSP page to display
 different HTML contents (let's say personalize content) according to
 conditions (e.g. profile user, ...).
 
 if (user == 'admin')
 
 H2Admin partH2/
 
 if ( user == 'anonymous')
 
 H2Anonymous part/H2
 
 Regards,
 
 Charles
 
 
 
 
 -
 Charles Moulliard
 SOA Architect
 
 My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
 -- 
 View this message in context:
 http://www.nabble.com/How-to-personalise-HTML-content-with-Wicket---tp21787067p21787067.html
 Sent from the Wicket - User 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
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 


-
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 
http://www.nabble.com/How-to-personalise-HTML-content-with-Wicket---tp21787067p21787287.html
Sent from the Wicket - User 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



How to personalise HTML content with Wicket ?

2009-02-02 Thread cmoulliard

Hi,

I would like to know how we can personalize the content with Wicket ?

With framework like Struts, ... it is possible in a JSP page to display
different HTML contents (let's say personalize content) according to
conditions (e.g. profile user, ...).

if (user == 'admin')

H2Admin partH2/

if ( user == 'anonymous')

H2Anonymous part/H2

Regards,

Charles




-
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: 
http://www.nabble.com/How-to-personalise-HTML-content-with-Wicket---tp21787067p21787067.html
Sent from the Wicket - User 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