Re: Resources can't object HTTP request body
Martin, Ticket has been created: https://issues.apache.org/jira/browse/WICKET-6135 Will attach quick start today/tomorrow. Thanks, Ilia 2016-03-29 6:39 GMT-07:00 Martin Grigorov: > Please create a ticket at JIRA. > With a quickstart would be nice! > Thank you! > > Martin Grigorov > Wicket Training and Consulting > https://twitter.com/mtgrigorov > > On Tue, Mar 29, 2016 at 3:30 PM, Илья Нарыжный wrote: > >> Martin, >> >> There are 3 problems: >> >> 1) Map can not guarantee that order of keys remain the same. In my >> case Jetty use HashMap as underling storage. >> 2) Some part of content might be URL encoded. So after collecting all >> back: it's hard to revert exectly to initial value due to fact that >> some parts contained URL encoded stuff. >> 3) POST can contain huge body. So it looks very strange. >> >> As a work-around I use Filter configured prior to wicket to intercept >> body whenever it's needed: >> >> https://github.com/OrienteerDW/wicket-orientdb/commit/c9e706d9e84a828901a5ad97ed50aa46521f7bfb >> >> Is it really required for isAjax() method check POST parameters as >> well? I mean, may be flag is in query string and there is even no goal >> to check POST body. >> >> Thanks, >> >> Ilia >> >> 2016-03-27 4:07 GMT-07:00 Martin Grigorov : >> > Hi, >> > >> > I remember dealing with this in the past but I cannot find the mail >> thread >> > now. >> > I think the complete body should be available as a valueless key in the >> > post parameters: >> > getRequest().getPostParameters().getParameterNames().iterator().next(). >> > Please confirm whether this works! >> > If it does then I think it would be good to add a helper method to >> simplify >> > this. >> > >> > Martin Grigorov >> > Wicket Training and Consulting >> > https://twitter.com/mtgrigorov >> > >> > On Sat, Mar 26, 2016 at 5:28 AM, Илья Нарыжный wrote: >> > >> >> It seems that Wicket Resource can't obtain whole HTTP POST body. >> >> The reason of that is the following: >> >> Mappers invoke WebRequest.isAjax() and isAjax() is trying to >> >> getRequestParameters() - so body of POST parsed prior to actual >> >> getInputStream() in a Resource object. >> >> >> >> Is there any chances to allow Resources to get request body? >> >> >> >> Thanks, >> >> >> >> Ilia >> >> >> >> - >> >> 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: Getting the model
Hi, yeah, of course this is right: protected void onComponentTag(final ComponentTag tag) { if (getModelObject().doubleValue() < 0.0) { tag.put("class", " negative"); } } Otherwise you'll end up with one additional behavior for each render - stupid copy-paste error :/. BTW this might be an additional candidate for the new Wicket 8 lambdas: label.add(onTag(tag -> if (getModelObject().doubleValue() < 0.0) tag.put("class", "negative") )); Sven On 31.03.2016 21:16, Martin Grigorov wrote: Hi, On Thu, Mar 31, 2016 at 4:29 PM, Sven Meierwrote: Hi, you can access a component's model with #getDefaultModel() or - if it is a generic component - with #getModel(). To properly 'bind' to a model you should delay invocation of #getObject() as late as possible, so better overwrite #onComponentTag(): protected void onComponentTag(final ComponentTag tag) { if (getModelObject().doubleValue() < 0.0) { add(new AttributeAppender("class", " negative")); Since you are in #onComponentTag() there is no reason to add a Behavior. Just use the tag: tag.append("class", "negative", " "); } } Have fun Sven On 31.03.2016 16:06, Ron Smits wrote: I have searched but I dont find a clear way of getting the model when one is creating a custom component: public MoneyLabel(String id) { super(id); add(new AttributeAppender("class", " number")); } It sounds like you always need the model. If there is a CompoundPropertyModel in the parents' hierarchy then move your logic to #onComponentTag(), as per Sven's suggestion. If there is no CPM in the parents then just remove this constructor. public MoneyLabel(String id, Model bigDecimalModel) { super(id, bigDecimalModel); add(new AttributeAppender("class", " number")); if (bigDecimalModel.getObject().doubleValue() < 0.0) { add(new AttributeAppender("class", " negative")); } } In the second constructor I can use the supplied model to determine to add the negative class. However in the first constructor I cannot find a way to access the model. What am I missing? Ron - 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: Getting the model
Hi, On Thu, Mar 31, 2016 at 4:29 PM, Sven Meierwrote: > Hi, > > you can access a component's model with #getDefaultModel() or - if it is a > generic component - with #getModel(). > > To properly 'bind' to a model you should delay invocation of #getObject() > as late as possible, so better overwrite #onComponentTag(): > > protected void onComponentTag(final ComponentTag tag) { > > if (getModelObject().doubleValue() < 0.0) { > add(new AttributeAppender("class", " negative")); > Since you are in #onComponentTag() there is no reason to add a Behavior. Just use the tag: tag.append("class", "negative", " "); > } > } > > > Have fun > Sven > > > > > On 31.03.2016 16:06, Ron Smits wrote: > >> I have searched but I dont find a clear way of getting the model when one >> is creating a custom component: >> >> >> public MoneyLabel(String id) { >> super(id); >> add(new AttributeAppender("class", " number")); >> } >> > It sounds like you always need the model. If there is a CompoundPropertyModel in the parents' hierarchy then move your logic to #onComponentTag(), as per Sven's suggestion. If there is no CPM in the parents then just remove this constructor. > >> public MoneyLabel(String id, Model bigDecimalModel) >> { >> super(id, bigDecimalModel); >> add(new AttributeAppender("class", " number")); >> if (bigDecimalModel.getObject().doubleValue() < 0.0) { >> add(new AttributeAppender("class", " negative")); >> } >> } >> >> In the second constructor I can use the supplied model to determine to add >> the negative class. However in the first constructor I cannot find a way >> to >> access the model. >> >> What am I missing? >> >> Ron >> >> >> > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Re: Getting the model
2016-03-31 17:06 GMT+03:00 Ron Smits: > I have searched but I dont find a clear way of getting the model when one > is creating a custom component: > > > public MoneyLabel(String id) { > super(id); > add(new AttributeAppender("class", " number")); > } > > public MoneyLabel(String id, Model bigDecimalModel) { > super(id, bigDecimalModel); > add(new AttributeAppender("class", " number")); > if (bigDecimalModel.getObject().doubleValue() < 0.0) { > add(new AttributeAppender("class", " negative")); > } > } > > In the second constructor I can use the supplied model to determine to add > the negative class. However in the first constructor I cannot find a way to > access the model. > > What am I missing? > 1. To answer your question: Is this MoneyLabel your own design? If it is you are free to implement as you whish, or even drop the first constructor. 2. To give a recommendation on your design, I would attach the AttributeAppender in any case and only check if the model is negative at runtime (hollywood principle) like this: add(new AttributeAppender("class", " negative") { @Override isEnabled(..) { bigDecimalModel.getObject().doubleValue() < 0.0 } }); ** Martin > > Ron > >
Re: Getting the model
Hi, you can access a component's model with #getDefaultModel() or - if it is a generic component - with #getModel(). To properly 'bind' to a model you should delay invocation of #getObject() as late as possible, so better overwrite #onComponentTag(): protected void onComponentTag(final ComponentTag tag) { if (getModelObject().doubleValue() < 0.0) { add(new AttributeAppender("class", " negative")); } } Have fun Sven On 31.03.2016 16:06, Ron Smits wrote: I have searched but I dont find a clear way of getting the model when one is creating a custom component: public MoneyLabel(String id) { super(id); add(new AttributeAppender("class", " number")); } public MoneyLabel(String id, Model bigDecimalModel) { super(id, bigDecimalModel); add(new AttributeAppender("class", " number")); if (bigDecimalModel.getObject().doubleValue() < 0.0) { add(new AttributeAppender("class", " negative")); } } In the second constructor I can use the supplied model to determine to add the negative class. However in the first constructor I cannot find a way to access the model. What am I missing? Ron - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Getting the model
I have searched but I dont find a clear way of getting the model when one is creating a custom component: public MoneyLabel(String id) { super(id); add(new AttributeAppender("class", " number")); } public MoneyLabel(String id, Model bigDecimalModel) { super(id, bigDecimalModel); add(new AttributeAppender("class", " number")); if (bigDecimalModel.getObject().doubleValue() < 0.0) { add(new AttributeAppender("class", " negative")); } } In the second constructor I can use the supplied model to determine to add the negative class. However in the first constructor I cannot find a way to access the model. What am I missing? Ron
Re: Failing test SpringBeanWithGenericsTest in 7.3.0.0 SNAPSHOT
Guten Tag Martin Grigorov, am Mittwoch, 30. März 2016 um 15:54 schrieben Sie: > Please create a patch / Pull Request and a ticket. https://issues.apache.org/jira/browse/WICKET-6133 Mit freundlichen Grüßen, Thorsten Schöning -- Thorsten Schöning E-Mail: thorsten.schoen...@am-soft.de AM-SoFT IT-Systeme http://www.AM-SoFT.de/ Telefon...05151- 9468- 55 Fax...05151- 9468- 88 Mobil..0178-8 9468- 04 AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org