Re: File upload with inner form and modal window
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 : > final FormBean formBean = new FormBean(); > Model model = new Model(formBean); > Form form = new Form("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 >> > xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd";> >> >> >> feedback >> >> >> Input text: >> >> files >> >> modalPanel >> modalPage >> Add new file (panel modal) | >> Add new file (page modal) >> >> >> >> >> >> >> >> >> >> >> *** UploadPanel.html >> >> >> >> feedback >> >> >> File: >> >> >> >> >> >> >> >> >> *** 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(); >> Model model = new Model(formBean); >> Form form = new Form("form", model); >> form.setMultiPart(false); >> add(form); >> >> form.add(new TextField("text", new >> PropertyModel(model, "text"))); >> >> IColumn column = new AbstractColumn(new >> Model("File")) { >> �...@override >> public void populateItem(Item> cellItem, >> String componentId, IModel rowModel) { >> cellItem.add(new Label(componentId, rowModel)); >> } >> }; >> >> final DataTable filesDataTable = new >> DataTable("files", new IColumn[] { column }, >> new ListDataProvider(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 AjaxLink("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 AjaxLink("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) { >>
Re: File upload with inner form and modal window
} 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 : > 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 : >>> 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 >>>> >>>> >>>> >>>> >>>> >>>> upload-window.html >>>> >>>> >>>> >>>> >>>> >>>> >>>> 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.(MultipartServletWebRequest.java:113) >>>> at >>>> org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest.(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
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 : > 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 >> >> >> >> >> >> upload-window.html >> >> >> >> >> >> >> 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.(MultipartServletWebRequest.java:113) >> at >> org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest.(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
File upload with inner form and modal window
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 upload-window.html 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.(MultipartServletWebRequest.java:113) at org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest.(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: Javascript Wicket wrapper (like ExtGwt and SmartGWT) ?
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) ?
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
> 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
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]
Re: Non-modal ModalWindow ?
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]
Non-modal ModalWindow ?
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: Checkbox and enum value
Thanks for the input... I've updated my code :) James, I have the same question as Francisco: how do you get the values from the class of an enum? Cedric On Fri, Sep 26, 2008 at 6:57 PM, francisco treacy <[EMAIL PROTECTED]> wrote: > * i meant enum class > > On Fri, Sep 26, 2008 at 7:51 PM, francisco treacy > <[EMAIL PROTECTED]> wrote: >>> Also, you could have a varargs feature so that users could specify >>> exactly what they want without having to instantiate an array. >> >> yes, of course there is place for improvements... >> public EnumCheckGroup(String id, T... values) >> >>>> Why not just pass the enum class into the constructor? >> >> if i pass the enum object itself, how do i actually get the values? >> >> francisco >> >>>> >>>> On Fri, Sep 26, 2008 at 4:43 PM, francisco treacy >>>> <[EMAIL PROTECTED]> wrote: >>>>> i'm sorry i didn't see this post before-- i came up with a solution a >>>>> couple of weeks ago. >>>>> >>>>> i called it EnumCheckGroup (that is, i went for CheckGroup rather than >>>>> CheckBox). >>>>> >>>>> usage: >>>>> >>>>> for a given enum: >>>>> >>>>>public static enum Niveau { >>>>>etage, mezzanine, sous_sol; >>>>>} >>>>> >>>>> form.add(new EnumCheckGroup("niveaux", >>>>> Plan.Niveau.values())); >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> impl: >>>>> >>>>> public class EnumCheckGroup> extends CheckGroup { >>>>> >>>>> public EnumCheckGroup(String id, T[] values) { >>>>> super(id); >>>>> >>>>> ListView listview = new ListView("items", >>>>> Arrays.asList(values)) { >>>>> protected void populateItem(ListItem item) { >>>>> item.add(new Check("check", item.getModel())); >>>>> item.add(new Label("label", new >>>>> ResourceModel(item.getModelObject().name(; >>>>> }; >>>>> }.setReuseItems(true); >>>>> >>>>> add(listview); >>>>> >>>>> } >>>>> >>>>> } >>>>> >>>>> obviously you must have the keys in your properties file, such as: >>>>> >>>>> etage=Étage >>>>> mezzanine=Mezzanine >>>>> sous_sol=Sous-sol >>>>> >>>>> >>>>> francisco >>>>> >>>>> >>>>> On Fri, Sep 26, 2008 at 4:29 PM, Cédric Thiébault >>>>> <[EMAIL PROTECTED]> wrote: >>>>>> 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'
Re: Checkbox and enum value
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
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
I tried both but it was worst with multiple session because entities were already associated in an other session and it throws exceptions... On Thu, Sep 18, 2008 at 10:17 AM, James Carman <[EMAIL PROTECTED]> wrote: > Are you using the single session setting on OSIV? Or, are you using > multiple sessions? > > On Thu, Sep 18, 2008 at 9:12 AM, Cédric Thiébault > <[EMAIL PROTECTED]> wrote: >> In fact my example with the collection updating automatically was >> wrong... because, as it was said, the transaction is not committed at >> the end. >> >> But I remember other kind of problems when I wanted to save and commit >> my modified entities after I loaded and associated them during the >> request (via OSIV) : >> I was passing a graph of persistent objects to the manager and I had >> exception like "a different object with the same identifier value was >> already associated with the session". >> I tried then to use a merge but in this case I had other exception (I >> don't remember exactly which one)... >> >> If I don't use OSIV and pass a graph of transient object, it works fine! >> >> It must be something wrong with my hibernate mapping but it hard to locate >> :-( >> >> Cedric >> >> >> On Thu, Sep 18, 2008 at 3:26 AM, Maarten Bosteels >> <[EMAIL PROTECTED]> wrote: >>> >>> Hi, >>> >>> I never really used OpenSessionInViewFilter, but I remember Juergen >>> Hoeller saying that he sometimes wished he never wrote OSIV because of >>> all the potential side-effects. >>> At the time a ridiculous big percentage of questions on the spring >>> forum where about OSIV. >>> >>> This was several years ago though, and I have the impression that a >>> lot of people are using OSIV now without problems. >>> >>> I guess it all works fine when you know what you're doing :-) >>> >>> Maarten >>> >>> >>> On Tue, Sep 16, 2008 at 10:28 PM, Cédric Thiébault >>> <[EMAIL PROTECTED]> wrote: >>> > 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 anothe
Re: DropDownChoice and lazy loaded choices
In fact my example with the collection updating automatically was wrong... because, as it was said, the transaction is not committed at the end. But I remember other kind of problems when I wanted to save and commit my modified entities after I loaded and associated them during the request (via OSIV) : I was passing a graph of persistent objects to the manager and I had exception like "a different object with the same identifier value was already associated with the session". I tried then to use a merge but in this case I had other exception (I don't remember exactly which one)... If I don't use OSIV and pass a graph of transient object, it works fine! It must be something wrong with my hibernate mapping but it hard to locate :-( Cedric On Thu, Sep 18, 2008 at 3:26 AM, Maarten Bosteels <[EMAIL PROTECTED]> wrote: > > Hi, > > I never really used OpenSessionInViewFilter, but I remember Juergen > Hoeller saying that he sometimes wished he never wrote OSIV because of > all the potential side-effects. > At the time a ridiculous big percentage of questions on the spring > forum where about OSIV. > > This was several years ago though, and I have the impression that a > lot of people are using OSIV now without problems. > > I guess it all works fine when you know what you're doing :-) > > Maarten > > > On Tue, Sep 16, 2008 at 10:28 PM, Cédric Thiébault > <[EMAIL PROTECTED]> wrote: > > 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
Re: DropDownChoice and lazy loaded choices
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 b
Re: DropDownChoice and lazy loaded choices
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 { > >>> Collection 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
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 { >> Collection 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]