validate() form (Form.class) - how to validate form by hand?
Hello everyone, How to run validation of form (Form.class) by hand? Form.class javadoc says: If you want you can call validate() to execute form validation, hasError() to find out whether validate() resulted in validation errors, and updateFormComponentModels() to update the models of nested form components. But in Wicket 1.4.3 the validate() method is protected so it's not visible. By the way actually only hasError() method is public. Why is this method protected? Is javadoc stale or there is just a misunderstanding on my side? Thank you. Best regards, michalb - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: Hippo's patch for wicket ids
Works for me, your xpath must be wrong. Your syntax is ok. Either there is no a element (link) with attribute wicketpath=tablePanel_leftList_tableList_pojoList_18_nameCell_namePanel Link_name or there is no div tag inside an a element... -Original Message- From: Douglas Ferguson [mailto:doug...@douglasferguson.us] Does anybody have sample of how to do this? I'm getting this error when I try to use the wicketpath [error] Element //a [...@wicketpath = 'tablePanel_leftList_tableList_pojoList_18_nameCell_namePanelLink_name ']/div not found - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: Localization of values coming from my Model
No, javadoc is ok. You are right. My mistake, sorry. -Original Message- From: Jeffrey Schneller [mailto:jeffrey.schnel...@envisa.com] Then is the javadoc wrong? This was taken right from the javadoc? http://wicket.apache.org/docs/wicket-1.3.2/wicket/apidocs/org/apache/wic ket/model/StringResourceModel.html === Example 2 In this example, the resource key is selected based on the evaluation of a property expression: public MyPage extends WebPage { public MyPage(final PageParameters parameters) { WeatherStation ws = new WeatherStation(); add(new Label(weatherMessage, new StringResourceModel(weather.${currentStatus}, this, new Model(ws))); } } Which will call the WeatherStation.getCurrentStatus() method each time the string resource model is used and where the resource bundle for the page contains the entries: weather.sunny=Don't forget sunscreen! weather.raining=You might need an umbrella weather.snowing=Got your skis? weather.overcast=Best take a coat to be safe -Original Message- From: Bernhard Michal [mailto:michal.bernh...@tigra.cz] It doesn't seem correct... StringResourceModel expect string which is supposed to be resource key to find localization in resource bundle. I recommend you to read http://cwiki.apache.org/WICKET/localization-and-skinning-of-applications .html. -Original Message- From: Jeffrey Schneller [mailto:jeffrey.schnel...@envisa.com] I tried this and it seems to work. Is this a correct way of doing it? Label gender = new Label(gender, new StringResourceModel(${gender}, this, model)); add(gender); Obviously the StringResourceModel uses the property file for the page. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: Localization of values coming from my Model
Why don't you use special model for each component? Because this is very specific thing - CompoundPropertyModel is not supposed for this kind of model value's processing stuff. For example for activeString: add(new Label(activeString, new AbstractReadOnlyModelString() { @Override public String getObject() { return getString(yourModel.getActiveString()); } })); Anyway if you want it you can still write your own implementation of CompoundPropertyModel... -Original Message- From: Jeffrey Schneller [mailto:jeffrey.schnel...@envisa.com] Sent: Friday, October 16, 2009 4:36 PM To: users@wicket.apache.org Subject: Localization of values coming from my Model I am trying to display a page using my CompoundPropertyModel however some of the values coming from the model need to be localized before displaying to the user. This is being done inside of a wizard step. For example: My model has the following properties String gender boolean active Gender is either male or female I have a getter in my object which is getActiveString which returns Yes or No based on the T/F of the Boolean.public String getActiveString() {if (active) { return Yes;} else {return No;}} The html is: span wicket:id=gender/span span wicket:id=activeString/span The java code is: add(new Label(gender)); add(new Label(activeString)); The issue is that I need to localize the gender value. The activeString also needs to be localized. How would one do this? I need to store the values in the model as they are since it is being persisted to a db. However for certain users the data needs to be shown in their particular language when presented on the page. Any ideas? BTW... thanks you all for your previous help. I am finally in the final steps of development for my project. Thanks. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: Localization of values coming from my Model
It doesn't seem correct... StringResourceModel expect string which is supposed to be resource key to find localization in resource bundle. I recommend you to read http://cwiki.apache.org/WICKET/localization-and-skinning-of-applications .html. -Original Message- From: Jeffrey Schneller [mailto:jeffrey.schnel...@envisa.com] I tried this and it seems to work. Is this a correct way of doing it? Label gender = new Label(gender, new StringResourceModel(${gender}, this, model)); add(gender); Obviously the StringResourceModel uses the property file for the page. -Original Message- From: Bernhard Michal [mailto:michal.bernh...@tigra.cz] Why don't you use special model for each component? Because this is very specific thing - CompoundPropertyModel is not supposed for this kind of model value's processing stuff. For example for activeString: add(new Label(activeString, new AbstractReadOnlyModelString() { @Override public String getObject() { return getString(yourModel.getActiveString()); } })); Anyway if you want it you can still write your own implementation of CompoundPropertyModel... -Original Message- From: Jeffrey Schneller [mailto:jeffrey.schnel...@envisa.com] I am trying to display a page using my CompoundPropertyModel however some of the values coming from the model need to be localized before displaying to the user. This is being done inside of a wizard step. For example: My model has the following properties String gender boolean active Gender is either male or female I have a getter in my object which is getActiveString which returns Yes or No based on the T/F of the Boolean.public String getActiveString() {if (active) { return Yes;} else {return No;}} The html is: span wicket:id=gender/span span wicket:id=activeString/span The java code is: add(new Label(gender)); add(new Label(activeString)); The issue is that I need to localize the gender value. The activeString also needs to be localized. How would one do this? I need to store the values in the model as they are since it is being persisted to a db. However for certain users the data needs to be shown in their particular language when presented on the page. Any ideas? - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: Can Wicket automatically remove beginning and trailing spaces in a text field?
Afaik there is no way to set this behavior by some flag. But 1) You can extend TextField to wrap it's model with model which on getObject() trim (ie. remove begging and trailing spaces) returning string if Model's type is Sting (in other cases it doesn't make sense)... when value is setted into model trimming is done by wicket (see FormComponent#shouldTrimInput) automatically (in older version you have to do this manually by overriding FormComponent#convertInput() method) 2) you can do aspect (AspectJ?) to do the same as 1) - with aspect there is no need to make new class of TextField's type so there is no need to change the code base... 3) you can override implementation of coverters override Application#newConverterLocator() to protected IConverterLocator newConverterLocator() { ConverterLocator locator = new ConverterLocator(); locator.set(String.class, new IConverter() { public Object convertToObject(String value, Locale locale) { return convertToString(value, locale); } public String convertToString(Object value, Locale locale) { return value.toString().trim(); // see trim() which remove trailing and beginning spaces } }); return locator; } I didn't test it but you've got the idea... But this solution is really bad, because if you want to turn off this behaviour (trimming) in some cases you can't do it without overriding for example Component#getConverter() to convert it in default way and it's a mess. I recommend you to trim it by hand on Model level (make some wrapper model to do it so) or on tier (layer) where you obtain data (data acces layer? service level?). It depends on if spaces have some business meaning. If yes do it on model level otherwise on that layer. Best wishes MB -Original Message- From: David Chang [mailto:david_q_zh...@yahoo.com] Sent: Friday, October 02, 2009 5:25 AM To: users@wicket.apache.org Subject: Can Wicket automatically remove beginning and trailing spaces in a text field? How to set it up in a Wicket application? I would like to set it up in the application level. Thanks! - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
image html element's (img) src attribute processing
Hello everyone. I noticed that wicket automatically translate url in img's src attribute in html to the right url regarding to changed url context. I mean when I've got eg. link img src=/img/someimage.png and that page is rendered in some context for example /appContext/ the src attribute is automatically changed to something like this: img src=/../img/someimage.png (notice two dots) to reflect changed context (and link still the same resource) 1) Where exactly is the code which doing this? 2) How can I obtain this changed url for static resources? I am asking this because I've got some static resources (javascripts) and I need to know their relative url regarding to changed context. Thank you for your response. Best wishes MB - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: image html element's (img) src attribute processing
Great! Thank you very much. I get new url through IRequestCodingStrategy#rewriteStaticRelativeUrl(String url): String newUrl = RequestCycle.get().getProcessor().getRequestCodingStrategy().rewriteStat icRelativeUrl(urlToChange); MB -Original Message- From: Pedro Santos [mailto:pedros...@gmail.com] Sent: Thursday, September 24, 2009 1:33 PM To: users@wicket.apache.org Subject: Re: image html element's (img) src attribute processing 1) Where exactly is the code which doing this? http://wicket.apache.org/docs/1.4/org/apache/wicket/request/IRequestCodi ngStrategy.html 2) How can I obtain this changed url for static resources? You can create an resource reference to your image resource. http://wicket.apache.org/docs/wicket-1.3.2/wicket/apidocs/org/apache/wic ket/ResourceReference.html On Thu, Sep 24, 2009 at 6:13 AM, Bernhard Michal michal.bernh...@tigra.czwrote: Hello everyone. I noticed that wicket automatically translate url in img's src attribute in html to the right url regarding to changed url context. I mean when I've got eg. link img src=/img/someimage.png and that page is rendered in some context for example /appContext/ the src attribute is automatically changed to something like this: img src=/../img/someimage.png (notice two dots) to reflect changed context (and link still the same resource) 1) Where exactly is the code which doing this? 2) How can I obtain this changed url for static resources? I am asking this because I've got some static resources (javascripts) and I need to know their relative url regarding to changed context. Thank you for your response. Best wishes MB - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Pedro Henrique Oliveira dos Santos - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org