File upload with inner form and modal window

2010-12-07 Thread Cédric Thiébault
Hi,

I want to upload files with an Ajax form that is in a modal window
(using a Panel, not a WebPage). The modal and its form are part of the
main form:

main-page.html
form wicket:id=form
  div wicket:id=modal /
  input type=submit wicket:id=submit /
/form

upload-window.html
form wicket:id=form
  input type=file wicket:id=file /
  input type=submit wicket:id=submit /
/form


I'm able to upload a file but once the modal is closed, when I submit
the main form (not the one for uploading), I get an exception:

java.lang.IllegalStateException: ServletRequest does not contain
multipart content. One possible solution is to explicitly call
Form.setMultipart(true), Wicket tries its best to auto-detect
multipart forms but there are certain situation where it cannot.
 at 
org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest.init(MultipartServletWebRequest.java:113)
 at 
org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest.init(MultipartServletWebRequest.java:83)
 at 
org.apache.wicket.protocol.http.servlet.ServletWebRequest.newMultipartWebRequest(ServletWebRequest.java:489)
 at org.apache.wicket.markup.html.form.Form.handleMultiPart(Form.java:1708)
 at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:886)
 at 
org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.onEvent(AjaxFormSubmitBehavior.java:135)
 at 
org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:177)
 at 
org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:300)
 at 
org.apache.wicket.request.target.component.listener.BehaviorRequestTarget.processEvents(BehaviorRequestTarget.java:142)
 at 
org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
 at 
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250)
 at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
 at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1436)
 at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
 at 
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:486)
 at 
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:319)


I've created a JIRA issue with code example
(https://issues.apache.org/jira/browse/WICKET-3236) but maybe I
misunderstood something here...
Any help would be appreciated ;-)

Thanks

Cedric

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



Re: File upload with inner form and modal window

2010-12-07 Thread Cédric Thiébault
I've done this in the modal window form... And I set it to false for
the main form that is not used for uploading.
The upload works well, it's when my modal is closed, the main form
(not the one for the upload) throws an exception on submit.

Here is the code that I've attached to the Jira issue:
http://dl.dropbox.com/u/2167784/wicket-modal-upload.zip

Cedric


2010/12/7 François Meillet fm...@meillet.com:
 just add
 form.setMultiPart(true);

 in your form

 François

 Le 7 déc. 2010 à 20:11, Cédric Thiébault a écrit :

 Hi,

 I want to upload files with an Ajax form that is in a modal window
 (using a Panel, not a WebPage). The modal and its form are part of the
 main form:

 main-page.html
 form wicket:id=form
  div wicket:id=modal /
  input type=submit wicket:id=submit /
 /form

 upload-window.html
 form wicket:id=form
  input type=file wicket:id=file /
  input type=submit wicket:id=submit /
 /form


 I'm able to upload a file but once the modal is closed, when I submit
 the main form (not the one for uploading), I get an exception:

 java.lang.IllegalStateException: ServletRequest does not contain
 multipart content. One possible solution is to explicitly call
 Form.setMultipart(true), Wicket tries its best to auto-detect
 multipart forms but there are certain situation where it cannot.
     at 
 org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest.init(MultipartServletWebRequest.java:113)
     at 
 org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest.init(MultipartServletWebRequest.java:83)
     at 
 org.apache.wicket.protocol.http.servlet.ServletWebRequest.newMultipartWebRequest(ServletWebRequest.java:489)
     at 
 org.apache.wicket.markup.html.form.Form.handleMultiPart(Form.java:1708)
     at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:886)
     at 
 org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.onEvent(AjaxFormSubmitBehavior.java:135)
     at 
 org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:177)
     at 
 org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:300)
     at 
 org.apache.wicket.request.target.component.listener.BehaviorRequestTarget.processEvents(BehaviorRequestTarget.java:142)
     at 
 org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
     at 
 org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250)
     at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
     at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1436)
     at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
     at 
 org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:486)
     at 
 org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:319)


 I've created a JIRA issue with code example
 (https://issues.apache.org/jira/browse/WICKET-3236) but maybe I
 misunderstood something here...
 Any help would be appreciated ;-)

 Thanks

 Cedric

 -
 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



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



Re: File upload with inner form and modal window

2010-12-07 Thread Cédric Thiébault
  protected void onSubmit(AjaxRequestTarget target,
@SuppressWarnings(hiding) Form? form) {
FileUpload fileUpload = uploadField.getFileUpload();
if (fileUpload != null) {
  String fileName = fileUpload.getClientFileName();
  logger.info(FILE:  + fileName);
  UploadPanel.this.onSubmit(target, fileName);
} else {
  error(Unable to upload file.);
  target.addComponent(feedbackPanel);
}
  }

  @Override
  protected void onError(AjaxRequestTarget target,
@SuppressWarnings(hiding) Form? form) {
target.addComponent(feedbackPanel);
  }

});

  }

  protected abstract void onSubmit(AjaxRequestTarget target, String fileName);

}






2010/12/7 François Meillet fm...@meillet.com:
 it has to be in the main form afaik
 François

 Le 7 déc. 2010 à 20:27, Cédric Thiébault a écrit :

 I've done this in the modal window form... And I set it to false for
 the main form that is not used for uploading.
 The upload works well, it's when my modal is closed, the main form
 (not the one for the upload) throws an exception on submit.

 Here is the code that I've attached to the Jira issue:
 http://dl.dropbox.com/u/2167784/wicket-modal-upload.zip

 Cedric


 2010/12/7 François Meillet fm...@meillet.com:
 just add
 form.setMultiPart(true);

 in your form

 François

 Le 7 déc. 2010 à 20:11, Cédric Thiébault a écrit :

 Hi,

 I want to upload files with an Ajax form that is in a modal window
 (using a Panel, not a WebPage). The modal and its form are part of the
 main form:

 main-page.html
 form wicket:id=form
  div wicket:id=modal /
  input type=submit wicket:id=submit /
 /form

 upload-window.html
 form wicket:id=form
  input type=file wicket:id=file /
  input type=submit wicket:id=submit /
 /form


 I'm able to upload a file but once the modal is closed, when I submit
 the main form (not the one for uploading), I get an exception:

 java.lang.IllegalStateException: ServletRequest does not contain
 multipart content. One possible solution is to explicitly call
 Form.setMultipart(true), Wicket tries its best to auto-detect
 multipart forms but there are certain situation where it cannot.
     at 
 org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest.init(MultipartServletWebRequest.java:113)
     at 
 org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest.init(MultipartServletWebRequest.java:83)
     at 
 org.apache.wicket.protocol.http.servlet.ServletWebRequest.newMultipartWebRequest(ServletWebRequest.java:489)
     at 
 org.apache.wicket.markup.html.form.Form.handleMultiPart(Form.java:1708)
     at 
 org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:886)
     at 
 org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.onEvent(AjaxFormSubmitBehavior.java:135)
     at 
 org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:177)
     at 
 org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:300)
     at 
 org.apache.wicket.request.target.component.listener.BehaviorRequestTarget.processEvents(BehaviorRequestTarget.java:142)
     at 
 org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
     at 
 org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250)
     at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
     at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1436)
     at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
     at 
 org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:486)
     at 
 org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:319)


 I've created a JIRA issue with code example
 (https://issues.apache.org/jira/browse/WICKET-3236) but maybe I
 misunderstood something here...
 Any help would be appreciated ;-)

 Thanks

 Cedric

 -
 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



 -
 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



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



Re: File upload with inner form and modal window

2010-12-07 Thread Cédric Thiébault
You're right, it works :-)

So if I understand, all request will be multipart just because one of
theme needs to be multipart...

Thanks for your help François!

Cedric


2010/12/7 François Meillet fm...@meillet.com:
   final FormBean formBean = new FormBean();
   ModelFormBean model = new ModelFormBean(formBean);
   FormFormBean form = new FormFormBean(form, model);

   form.setMultiPart(false);     should be true

   add(form);


 François



 Le 7 déc. 2010 à 20:45, Cédric Thiébault a écrit :

 It is...

 Here is the code...

  HomePage.html
 html 
 xmlns:wicket=http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd;
  body

    div wicket:id=feedbackfeedback/div

    form wicket:id=form
      Input text: input type=text wicket:id=text size=40 /
      br /
      div wicket:id=filesfiles/div
      br /
      div wicket:id=modalPanelmodalPanel/div
      div wicket:id=modalPagemodalPage/div
      a wicket:id=showModalPanelAdd new file (panel modal)/a |
      a wicket:id=showModalPageAdd new file (page modal)/a
      br /
      br /
      input type=submit wicket:id=submit value=Submit input text /

    /form

  /body
 /html


 *** UploadPanel.html
 html xmlns:wicket
  wicket:panel

    div wicket:id=feedbackfeedback/div

    form wicket:id=form
      File: input type=file wicket:id=uploadField size=40 /
      br /
      input type=submit wicket:id=submit value=Upload /
    /form

  /wicket:panel
 /html


 *** HomePage.java
 public class HomePage extends WebPage {

  private final transient Logger logger = LoggerFactory.getLogger(getClass());

  public HomePage() {

    final FeedbackPanel feedbackPanel = new FeedbackPanel(feedback);
    add(feedbackPanel);

    final FormBean formBean = new FormBean();
    ModelFormBean model = new ModelFormBean(formBean);
    FormFormBean form = new FormFormBean(form, model);
    form.setMultiPart(false);
    add(form);

    form.add(new TextFieldString(text, new
 PropertyModelString(model, text)));

    IColumnString column = new AbstractColumnString(new
 ModelString(File)) {
     �...@override
      public void populateItem(ItemICellPopulatorString cellItem,
 String componentId, IModelString rowModel) {
        cellItem.add(new Label(componentId, rowModel));
      }
    };

    final DataTableString filesDataTable = new
 DataTableString(files, new IColumn[] { column },
        new ListDataProviderString(formBean.getFiles()), 10);
    filesDataTable.setOutputMarkupId(true);
    form.add(filesDataTable);

    final ModalWindow modalPanel = new ModalWindow(modalPanel);
    modalPanel.setTitle(Upload File);
    modalPanel.setInitialWidth(500);
    modalPanel.setInitialHeight(200);
    form.add(modalPanel);

    form.add(new AjaxLinkVoid(showModalPanel) {
     �...@override
      public void onClick(AjaxRequestTarget target) {
        modalPanel.setContent(new UploadPanel(modalPanel.getContentId()) {
         �...@override
          protected void onSubmit(@SuppressWarnings(hiding)
 AjaxRequestTarget target, String fileName) {
            formBean.getFiles().add(fileName);
            target.addComponent(filesDataTable);
            modalPanel.close(target);
          }
        });
        modalPanel.show(target);
      }
    });

    final ModalWindow modalPage = new ModalWindow(modalPage);
    modalPage.setTitle(Upload File);
    modalPage.setInitialWidth(500);
    modalPage.setInitialHeight(200);
    form.add(modalPage);

    form.add(new AjaxLinkVoid(showModalPage) {
     �...@override
      public void onClick(AjaxRequestTarget target) {
        modalPage.setPageCreator(new PageCreator() {
         �...@override
          public Page createPage() {
            return new UploadPage() {
             �...@override
              protected void onSubmit(@SuppressWarnings(hiding)
 AjaxRequestTarget target, String fileName) {
                formBean.getFiles().add(fileName);
                target.addComponent(filesDataTable);
                modalPage.close(target);
              }
            };
          }
        });
        modalPage.show(target);
      }
    });

    form.add(new AjaxButton(submit) {

     �...@override
      protected void onSubmit(AjaxRequestTarget target,
 @SuppressWarnings(hiding) Form? form) {
        logger.info(SUBMIT:);
        logger.info(text:  + formBean.getText());
        logger.info(files:  + formBean.getFiles());
      }

     �...@override
      protected void onError(AjaxRequestTarget target,
 @SuppressWarnings(hiding) Form? form) {
        target.addComponent(feedbackPanel);
      }

    });

  }

  public static class FormBean implements Serializable {

    private String text;
    private ListString files = new ArrayListString();

    public String getText() {
      return text;
    }

    public void setText(String text) {
      this.text = text;
    }

    public ListString getFiles() {
      return files;
    }

    public void setFiles(ListString files) {
      this.files = files

Re: Javascript Wicket wrapper (like ExtGwt and SmartGWT) ?

2008-12-02 Thread Cédric Thiébault
Hi,
Yes I was thinking about something like this but with more complete
Javascript frameworks (but I don't know very well JQuery in fact).
Ext-JS and SmartClient offer lots of nice widgets with a sharp design.

Pure Wicket also offer built-in widgets but not as rich/sharp as these
frameworks...
I know that adding a layer on top of Wicket will complexify stuff and it
will be harder to debug but it seems to bring a new dimension to the user
experience...

I will follow your project with JQuery :-)

Cedric



On Mon, Dec 1, 2008 at 10:39 AM, jWeekend [EMAIL PROTECTED]wrote:


 Cedric,

 I have just started looking at  http://www.wickext.org Wickext .
 Is this the sort of thing you're thinking about?
 For version 1.0 we hope to bind widget state back to Wicket as well.

 Regards - Cemal
 http://www.jWeekend.co.uk http://jWeekend.co.uk



 thiebal wrote:
 
  Why don't we have some nice Javascript frameworks on top of Wicket
  like what exists for wrapping GWT ?
  http://extjs.com/explorer
  http://www.smartclient.com/smartgwt/showcase
 
  Is there a reason why people implements these wrappers for GWT and not
  for Wicket ?
  We should be able to do exactly the same thing with Wicket no?
 
  Cedric
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

 --
 View this message in context:
 http://www.nabble.com/Javascript-Wicket-wrapper-%28like-ExtGwt-and-SmartGWT%29---tp20773877p20774308.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Javascript Wicket wrapper (like ExtGwt and SmartGWT) ?

2008-12-01 Thread Cédric Thiébault
Why don't we have some nice Javascript frameworks on top of Wicket
like what exists for wrapping GWT ?
http://extjs.com/explorer
http://www.smartclient.com/smartgwt/showcase

Is there a reason why people implements these wrappers for GWT and not
for Wicket ?
We should be able to do exactly the same thing with Wicket no?

Cedric

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: @MountPath with same path

2008-10-21 Thread Cédric Thiébault
 Jörn
Yes I could do something like that but I don't really like the idea of
a unique page that dispatch to panels depending on parameters...

 David
It throws the same exception with @MountIndexedHybrid:
org.apache.wicket.WicketRuntimeException: products is already mounted
for HybridUrlCodingStrategy

I tried to do it without annotations and I have exactly the same
problems (hopefully):
mountBookmarkablePage(products, ProductListPage.class);
mount(new IndexedHybridUrlCodingStrategy(products, ProductDetailPage.class));


Cedric


On Mon, Oct 20, 2008 at 5:46 PM, David Leangen [EMAIL PROTECTED] wrote:

 You can use IndexedHybridUrlCodingStrategy (or something like that... 
 currently writing from [my poor] memory).


 Cheers,
 =dml




 -Original Message-
 From: Jorn Zaefferer [mailto:[EMAIL PROTECTED]
 Sent: 21 October 2008 06:33
 To: users@wicket.apache.org
 Subject: Re: @MountPath with same path


 How about mounting that to just products and displaying different
 content based on the presence of the parameter? You abstract the
 content of both pages into panels and show one or the other based on
 the paramter.

 Jörn

 On Mon, Oct 20, 2008 at 6:15 PM, Cédric Thiébault
 [EMAIL PROTECTED] wrote:
  Hi,
 
  I want to use REST url for my application using wicketstuff-annotation
  but it seems that I can't use the same path for 2 pages.
  For example :
  - /products for the list of products
   @MountPath(path = products)
   public class ProductListPage extends Webpage
 
  - /products/5 for the detail of product with id=5.
   @MountPath(path = products)
   @MountMixedParam(parameterNames = { id })
   public class ProductDetailPage extends Webpage
 
  It throws an WicketRuntimeException: its is already mounted for
  BookmarkablePageEncoder on start up.
  I tried to use the patch described in
  https://issues.apache.org/jira/browse/WICKET-1534 but it goes to first
  page with this path (ie /products displays the product detail page for
  id=null).
 
  I also tried:
  - /products for the list of products
   @MountPath(path = products)
   public class ProductListPage extends Webpage
 
  - /products/detail/5 for the detail of product with id=5.
   @MountPath(path = products/detail)
   @MountMixedParam(parameterNames = { id })
   public class ProductDetailPage extends Webpage
 
  but /products/detail/5 displays the list page because the list page
  path is a subset of the detail page path.
 
  Dis someone used this kind of urls with Wicket ?
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



@MountPath with same path

2008-10-20 Thread Cédric Thiébault
Hi,

I want to use REST url for my application using wicketstuff-annotation
but it seems that I can't use the same path for 2 pages.
For example :
- /products for the list of products
  @MountPath(path = products)
  public class ProductListPage extends Webpage

- /products/5 for the detail of product with id=5.
  @MountPath(path = products)
  @MountMixedParam(parameterNames = { id })
  public class ProductDetailPage extends Webpage

It throws an WicketRuntimeException: its is already mounted for
BookmarkablePageEncoder on start up.
I tried to use the patch described in
https://issues.apache.org/jira/browse/WICKET-1534 but it goes to first
page with this path (ie /products displays the product detail page for
id=null).

I also tried:
- /products for the list of products
  @MountPath(path = products)
  public class ProductListPage extends Webpage

- /products/detail/5 for the detail of product with id=5.
  @MountPath(path = products/detail)
  @MountMixedParam(parameterNames = { id })
  public class ProductDetailPage extends Webpage

but /products/detail/5 displays the list page because the list page
path is a subset of the detail page path.

Dis someone used this kind of urls with Wicket ?

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Non-modal ModalWindow ?

2008-10-06 Thread Cédric Thiébault
Is there an equivalent of the ModalWindow but non-modal, ie without a
mask that prevent user from interacting the rest of page ?
Thanks!

Cedric

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Non-modal ModalWindow ?

2008-10-06 Thread Cédric Thiébault
A ModalWindows is not just a DIV with a mask...
I need all the ModalWindow logic (show/hide, drag, resize, etc.) but
not the mask.

Cedric


On Mon, Oct 6, 2008 at 3:30 PM, Daan van Etten [EMAIL PROTECTED] wrote:
 Yes, it's called a DIV.

 Regards,

 Daan


 On 6 okt 2008, at 21:08, Cédric Thiébault wrote:

 Is there an equivalent of the ModalWindow but non-modal, ie without a
 mask that prevent user from interacting the rest of page ?
 Thanks!

 Cedric

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Checkbox and enum value

2008-09-26 Thread Cédric Thiébault
Thanks Igor, it was exactly what i needed :-)

To complete this post, here is the solution I found :
http://surunairdejava.blogspot.com/2008/09/wicket-checkbox-abstractcheckboxmodel.html

Sorry it's in french but the code is easy to understand...

Cedric


On Wed, Sep 24, 2008 at 2:46 PM, Igor Vaynberg [EMAIL PROTECTED] wrote:
 see abstractcheckboxmodel

 -igor

 On Wed, Sep 24, 2008 at 11:37 AM, Cédric Thiébault
 [EMAIL PROTECTED] wrote:
 Hi,

 I'm trying to use a checkbox to set an enum value on my form object
 but I always get a type mismatch error (boolean is not an enum and
 vice versa).

 My form object has an enum and I want to display a list of checkboxes
 to allow the user to select the value.
 I don't want to use a radio because my enum can be null and I can't
 unselect my radio group once a radio is selected.

 I tried to extends Checkbox to convert teh boolean to the specified
 enum... it works only in one way (to set the enum value) but it does
 not work when my enum has a value and the checkbox need to render
 itself (the value must be a boolean).


 public class CheckBoxEnum extends CheckBox {

  private final Enum? enumValue;

  public CheckBoxEnum(String id, IModel model, String property,
 Enum? enumValue) {
super(id, new PropertyModel(model, property));
this.enumValue = enumValue;
  }

  @Override
  protected void convertInput() {
String value = getValue();
if (value != null  BooleanUtils.toBoolean(value))
 setConvertedInput(enumValue);
  }
 }

 Any ideas ?

 Thanks

 Cedric

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Checkbox and enum value

2008-09-24 Thread Cédric Thiébault
Hi,

I'm trying to use a checkbox to set an enum value on my form object
but I always get a type mismatch error (boolean is not an enum and
vice versa).

My form object has an enum and I want to display a list of checkboxes
to allow the user to select the value.
I don't want to use a radio because my enum can be null and I can't
unselect my radio group once a radio is selected.

I tried to extends Checkbox to convert teh boolean to the specified
enum... it works only in one way (to set the enum value) but it does
not work when my enum has a value and the checkbox need to render
itself (the value must be a boolean).


public class CheckBoxEnum extends CheckBox {

  private final Enum? enumValue;

  public CheckBoxEnum(String id, IModel model, String property,
Enum? enumValue) {
super(id, new PropertyModel(model, property));
this.enumValue = enumValue;
  }

  @Override
  protected void convertInput() {
String value = getValue();
if (value != null  BooleanUtils.toBoolean(value))
setConvertedInput(enumValue);
  }
}

Any ideas ?

Thanks

Cedric

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DropDownChoice and lazy loaded choices

2008-09-16 Thread Cédric Thiébault
Thanks Michael.

But I don't use the OpenSessionInviewFilter and I don't want to use it.
It creates more problems than it solves in my edit pages.

The LoadableDetachableModel will load the whole list of choices, not
just the one that was selected by the user.
I will encounter the same error except if the
LoadableDetachableModel.load method pre-fetch the associations...

Cedric


On Tue, Sep 16, 2008 at 3:01 AM, Michael Sparer [EMAIL PROTECTED] wrote:

 Use LoadableDetachableModels (and be sure that the OpensessionInviewFilter
 goes before the wicketfilter) and your hibernate entity will always be in
 the right session

 regards,
 Michael

 thiebal wrote:

 My DropDownChoice contains a list of hibernate entities that are not
 fully loaded.
 But when I select a value in the dropdown I receive a
 LazyLoadingException because Wicket tries to add an entry in a
 collection that was not previously loaded.

 I tried to use a Converter but it is not called because
 PropertyResolverConverter set directly the value (because their
 classes are compatible) :
 if (clz.isAssignableFrom(object.getClass())) {
   return object;
 }

 It works if I preload each entry in the list of choices of the
 DropDownChoice but it is very expensive. To display the dropdown, I
 just need to retrieve the name of my hibernate entity, not the
 collection inside this bean.
 I would like to load the collection only when the user select an
 option in the select.

 Code :
 class Foo {
   Bar bar;

   void setBar(Bar bar) {
 this.bar = bar;
 bar.getFoos().add(this);  // this will throw a
 LazyLoadingException if I don't fetch the collections before I render
 the DropDownChoice
   }
 }

 class Bar {
   CollectionFoo foos;
 }

 Is there a nice way to do that ?

 Thanks in advance :-)

 Cedric

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





 -
 Michael Sparer
 http://talk-on-tech.blogspot.com
 --
 View this message in context: 
 http://www.nabble.com/DropDownChoice-and-lazy-loaded-choices-tp19501118p19506463.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: DropDownChoice and lazy loaded choices

2008-09-16 Thread Cédric Thiébault
I had lots of problems with a Spring MVC webapp that was using
OpenSessionInViewFilter : beans were associated directly in DB when they
were added to a collection (like the current Foo/Bar case) even if I didn't
commit explicitly.
Without the session opened, I can prepare all my entities and just save them
and commit.

I use this filter on another webapp that just load entities form DB but does
not update them. It works perfectly!

I though I would have the same kind of errors with Wicket because this is
not a Wicket part but just a Hibernate functionality.

If in my case, I use the filter, the Bar.foos association will be loaded
just on demand but if I add it a new created Foo entity (transient), it will
try to save it on flush (so before my save/commit) and I will have an
exception.
Maybe I'm wrong but I remember this kind of errors with Spring MVC...

Cedric


On Tue, Sep 16, 2008 at 10:16 AM, James Carman
[EMAIL PROTECTED]wrote:

 What problems does it cause?

 On Tue, Sep 16, 2008 at 9:14 AM, Cédric Thiébault
 [EMAIL PROTECTED] wrote:
  Thanks Michael.
 
  But I don't use the OpenSessionInviewFilter and I don't want to use it.
  It creates more problems than it solves in my edit pages.
 
  The LoadableDetachableModel will load the whole list of choices, not
  just the one that was selected by the user.
  I will encounter the same error except if the
  LoadableDetachableModel.load method pre-fetch the associations...
 
  Cedric
 
 
  On Tue, Sep 16, 2008 at 3:01 AM, Michael Sparer [EMAIL PROTECTED]
 wrote:
 
  Use LoadableDetachableModels (and be sure that the
 OpensessionInviewFilter
  goes before the wicketfilter) and your hibernate entity will always be
 in
  the right session
 
  regards,
  Michael
 
  thiebal wrote:
 
  My DropDownChoice contains a list of hibernate entities that are not
  fully loaded.
  But when I select a value in the dropdown I receive a
  LazyLoadingException because Wicket tries to add an entry in a
  collection that was not previously loaded.
 
  I tried to use a Converter but it is not called because
  PropertyResolverConverter set directly the value (because their
  classes are compatible) :
  if (clz.isAssignableFrom(object.getClass())) {
return object;
  }
 
  It works if I preload each entry in the list of choices of the
  DropDownChoice but it is very expensive. To display the dropdown, I
  just need to retrieve the name of my hibernate entity, not the
  collection inside this bean.
  I would like to load the collection only when the user select an
  option in the select.
 
  Code :
  class Foo {
Bar bar;
 
void setBar(Bar bar) {
  this.bar = bar;
  bar.getFoos().add(this);  // this will throw a
  LazyLoadingException if I don't fetch the collections before I render
  the DropDownChoice
}
  }
 
  class Bar {
CollectionFoo foos;
  }
 
  Is there a nice way to do that ?
 
  Thanks in advance :-)
 
  Cedric
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 
  -
  Michael Sparer
  http://talk-on-tech.blogspot.com
  --
  View this message in context:
 http://www.nabble.com/DropDownChoice-and-lazy-loaded-choices-tp19501118p19506463.html
  Sent from the Wicket - User mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: DropDownChoice and lazy loaded choices

2008-09-16 Thread Cédric Thiébault
Ok thanks all...
I will read again about Hibernate sessions :-)

Cedric


On Tue, Sep 16, 2008 at 4:26 PM, Igor Vaynberg [EMAIL PROTECTED]wrote:

 +1

 -igor

 On Tue, Sep 16, 2008 at 1:24 PM, James Carman
 [EMAIL PROTECTED] wrote:
  +1, OSIV works for me just fine, too.  You must be doing something
  weird.  The OSIV doesn't commit transactions by default.  So, it
  shouldn't be doing anything weird.
 
  On Tue, Sep 16, 2008 at 1:07 PM, Michael Sparer [EMAIL PROTECTED]
 wrote:
 
  Before dropping OpenSessionInviewFilter I'd suggest to have a more
 thorough
  look at how hibernate works. e.g. have a look at the different cascade
  styles hibernate offers and also at transaction management, then it's
 easy
  to know why, and when, hibernate commits without explicitly calling
 save
  ... but that's no wicket topic after all. I'm using
 opensessioninviewfilter
  with loadabledetachablemodels in my webapp and never had problems ...
 
  just my two cents,
  Michael
 
 
  thiebal wrote:
 
  I had lots of problems with a Spring MVC webapp that was using
  OpenSessionInViewFilter : beans were associated directly in DB when
 they
  were added to a collection (like the current Foo/Bar case) even if I
  didn't
  commit explicitly.
  Without the session opened, I can prepare all my entities and just save
  them
  and commit.
 
  I use this filter on another webapp that just load entities form DB but
  does
  not update them. It works perfectly!
 
  I though I would have the same kind of errors with Wicket because this
 is
  not a Wicket part but just a Hibernate functionality.
 
  If in my case, I use the filter, the Bar.foos association will be
 loaded
  just on demand but if I add it a new created Foo entity (transient), it
  will
  try to save it on flush (so before my save/commit) and I will have an
  exception.
  Maybe I'm wrong but I remember this kind of errors with Spring MVC...
 
  Cedric
 
 
  On Tue, Sep 16, 2008 at 10:16 AM, James Carman
  [EMAIL PROTECTED]wrote:
 
  What problems does it cause?
 
  On Tue, Sep 16, 2008 at 9:14 AM, Cédric Thiébault
  [EMAIL PROTECTED] wrote:
   Thanks Michael.
  
   But I don't use the OpenSessionInviewFilter and I don't want to use
 it.
   It creates more problems than it solves in my edit pages.
  
   The LoadableDetachableModel will load the whole list of choices, not
   just the one that was selected by the user.
   I will encounter the same error except if the
   LoadableDetachableModel.load method pre-fetch the associations...
  
   Cedric
  
  
   On Tue, Sep 16, 2008 at 3:01 AM, Michael Sparer 
 [EMAIL PROTECTED]
  wrote:
  
   Use LoadableDetachableModels (and be sure that the
  OpensessionInviewFilter
   goes before the wicketfilter) and your hibernate entity will always
 be
  in
   the right session
  
   regards,
   Michael
  
   thiebal wrote:
  
   My DropDownChoice contains a list of hibernate entities that are
 not
   fully loaded.
   But when I select a value in the dropdown I receive a
   LazyLoadingException because Wicket tries to add an entry in a
   collection that was not previously loaded.
  
   I tried to use a Converter but it is not called because
   PropertyResolverConverter set directly the value (because their
   classes are compatible) :
   if (clz.isAssignableFrom(object.getClass())) {
 return object;
   }
  
   It works if I preload each entry in the list of choices of the
   DropDownChoice but it is very expensive. To display the dropdown,
 I
   just need to retrieve the name of my hibernate entity, not the
   collection inside this bean.
   I would like to load the collection only when the user select an
   option in the select.
  
   Code :
   class Foo {
 Bar bar;
  
 void setBar(Bar bar) {
   this.bar = bar;
   bar.getFoos().add(this);  // this will throw a
   LazyLoadingException if I don't fetch the collections before I
 render
   the DropDownChoice
 }
   }
  
   class Bar {
 CollectionFoo foos;
   }
  
   Is there a nice way to do that ?
  
   Thanks in advance :-)
  
   Cedric
  
  
 -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
  
  
   -
   Michael Sparer
   http://talk-on-tech.blogspot.com
   --
   View this message in context:
 
 http://www.nabble.com/DropDownChoice-and-lazy-loaded-choices-tp19501118p19506463.html
   Sent from the Wicket - User mailing list archive at Nabble.com.
  
  
  
 -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
  
 -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED