ContextImage not generating path relative to context root
I'm a bit confused about ContextImage; according to the javadocs the image path "will be prefixed such that the image is relative to the context root". In my markup I've got: Then I add the Context image to my WebPage: add(new ContextImage("logo", "images/logos/mylogo.gif")); ... and I end up with: My application is deployed with a context root of /myapp and this doesn't work, it will only work if the application is deployed with a context root of /. I've checked the source which ContextImage uses to get the context root and in org.apache.wicket.Request it says: /** * Gets a prefix to make this relative to the context root. * * For example, if your context root is http://server.com/myApp/ and the request is for * /myApp/mountedPage/, then the prefix returned might be "../../". * * For a particular technology, this might return either an absolute prefix or a relative one. * * @return Prefix relative to this request required to back up to context root. */ public abstract String getRelativePathPrefixToContextRoot(); To me this just seems plain wrong, here it clearly states that the context root is "http://server.com/myApp/"; but the example prefix of "../../" relative to "/myApp/mountedPage/" does not take you to the context root of /myApp/ but to /. This is very confusing as I've always considered the context root of a java web application to to be the path upon which it is deployed on the application server, whether that be /, /myApp or /apps/myApp and in the above case I do not end up with an image path relative to the context root. Without hard-coding the name of my context root in the image path (bad idea for portability) how can I reference static images stored in an images directory under the context root? Should I file this as a bug or am I missing something? Thanks Gianni - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
LoadableDetachableModel for drop-down menu selection
I'm starting out with Wicket and following the Wicket In Action examples through and I'm a bit stuck on how to make use of a LoadableDetachableModel in a drop-down menu situation. I've got a drop-down menu of countries which is populated from a LoadableDetachableModel, this works perfectly but my selected Country is then stored in the page as a complete object, I'd like to be able to make use of LoadableDetachableModel also for the selectedCountry but I'm not clear on where and how I should instantiate it. i.e. for the example below where do I put the "new LoadableRefDataModel(selectedCountry);". I'd appreciate some suggestions, I think I'm getting the hang of the Model idea but can't see the wood for the trees at the moment. public class LocationSearchPage extends WebPage { private DropDownChoice countryChoice; private DropDownChoice locationChoice; private Country selectedCountry; private List locations = new ArrayList(); private Location selectedLocation; @SpringBean private RefDataService refDataService; public LocationSearchPage() { Form searchForm = new Form("searchForm") { @Override protected void onSubmit() { //... } }; add(searchForm); ChoiceRenderer countryRenderer = new ChoiceRenderer("description", "id"); IModel> countryModel = new LoadableDetachableModel>() { @Override protected List load() { return refDataService.getCountries(); } }; countryChoice = new DropDownChoice( "country", selectedCountry, countryModel, countryRenderer); countryChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { this.selectedLocation = null; locationChoice.setChoices(new ArrayList(selectedCountry.getLocations())); target.addComponent(locationChoice); } }); ChoiceRenderer locationRenderer = new ChoiceRenderer("description", "id"); locationChoice = new DropDownChoice( "location", new PropertyModel(this, "selectedLocation"), locations, locationRenderer); } } public class LoadableRefDataModel extends LoadableDetachableModel { @SpringBean private RefDataService refDataService; private Class type; private Serializable id; public LoadableRefDataModel(Class type, Serializable id) { InjectorHolder.getInjector().inject(this); this.type = type; this.id = id; } public LoadableRefDataModel(T domainObject) { super(domainObject); InjectorHolder.getInjector().inject(this); this.type = (Class) domainObject.getClass(); this.id = domainObject.getCode(); } @Override protected T load() { return refDataService.load(type, id); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: validation message-keys differences on m3 to rc2
https://issues.apache.org/jira/browse/WICKET-2159 On 10/mar/09, at 15:55, Igor Vaynberg wrote: jira, quickstart, you know the drill -igor On Tue, Mar 10, 2009 at 3:15 AM, gilberthuph wrote: I'm having exactly the same problem after moving from 1.4-rc1 -> 1.4-rc2 Here's the extract from my properties file TaxiBookingPage.xml. http://java.sun.com/dtd/properties.dtd";> key="generalDetails.numberOfVehiclesRequired.Required">You must enter the number of vehicles .. snip .. RC1 The key "generalDetails.numberOfVehiclesRequired.Required" is found immediately and the appropriate message retrieved. 11:00:38.595 [http-8180-3] DEBUG org.apache.wicket.Session - Getting page [path = 4:taxiBookingForm, versionNumber = 0] 11:00:38.609 [http-8180-3] DEBUG org.apache.wicket.resource.loader.ComponentStringResourceLoader - Found resource from: com/rp/webapp/taxi/TaxiBookingPage.; key: generalDetails.numberOfVehiclesRequired.Required RC2 Does not attempt to look up "generalDetails.numberOfVehiclesRequired.Required" but the key "taxiBookingForm .numberOfVehiclesContainer .numberOfVehiclesRequiredBorder .generalDetails.numberOfVehiclesRequired.Required" which is not found. 10:47:47.902 [http-8180-1] DEBUG org.apache.wicket.Localizer - Locate property: key: 'Required'; Component: '[MarkupContainer [Component id = generalDetails.numberOfVehiclesRequired]]' 10:47:47.903 [http-8180-1] DEBUG org.apache.wicket.resource.loader.ComponentStringResourceLoader - component: '[MarkupContainer [Component id = generalDetails.numberOfVehiclesRequired]]'; key: 'Required' 10:47:47.903 [http-8180-1] DEBUG org.apache.wicket.resource.loader.ComponentStringResourceLoader - key: 'taxiBookingForm .numberOfVehiclesContainer .numberOfVehiclesRequiredBorder .generalDetails.numberOfVehiclesRequired.Required'; class: 'com.rp.webapp.taxi.TaxiBookingPage'; locale: 'en_GB'; Style: 'null' 10:47:47.903 [http-8180-1] DEBUG org.apache.wicket.resource.loader.ComponentStringResourceLoader - Found properties file: 'com/rp/webapp/taxi/TaxiBookingPage.' but it doesn't contain the property So it seems the lookup algorithm hasn't changed but the message key. Is this a bug or should we now be using the full form-relative key as shown above? Alexander Lohse wrote: I could not find any reported changes concerning validation message keys from version 1.4-m3 to 1.4-rc2, but I have the following "required" key in my application resources that does not work anymore. .. trim .. -- View this message in context: http://www.nabble.com/validation-message-keys-differences-on-m3-to-rc2-tp22155986p22431244.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: validation message-keys differences on m3 to rc2
ComponentStringResourceLoader's javadoc is very helpful here: assume a component hierarchy like page1.form1.input1 and your are requesting a key named 'Required'. Wicket will search the property in the following order: page1.properties => form1.input1.Required page1.properties => Required form1.properties => input1.Required form1.properties => Required input1.properties => Required myApplication.properties => page1.form1.input1.Required myApplication.properties => Required What it doesn't mention is that if the form component is nested in another container such as a border then the border id needs to be included in the key. e.g. if I have page1.form1.border1.input1 then in the form's properties file I have to include the border component in the key - border1.input1.Required, it would be cleaner just to be able to use input1.Required. -Gianni On 18/mar/09, at 21:09, Gianni Doe wrote: https://issues.apache.org/jira/browse/WICKET-2159 On 10/mar/09, at 15:55, Igor Vaynberg wrote: jira, quickstart, you know the drill -igor On Tue, Mar 10, 2009 at 3:15 AM, gilberthuph wrote: I'm having exactly the same problem after moving from 1.4-rc1 -> 1.4-rc2 Here's the extract from my properties file TaxiBookingPage.xml. http://java.sun.com/dtd/ properties.dtd"> key="generalDetails.numberOfVehiclesRequired.Required">You must enter the number of vehicles .. snip .. RC1 The key "generalDetails.numberOfVehiclesRequired.Required" is found immediately and the appropriate message retrieved. 11:00:38.595 [http-8180-3] DEBUG org.apache.wicket.Session - Getting page [path = 4:taxiBookingForm, versionNumber = 0] 11:00:38.609 [http-8180-3] DEBUG org.apache.wicket.resource.loader.ComponentStringResourceLoader - Found resource from: com/rp/webapp/taxi/TaxiBookingPage.; key: generalDetails.numberOfVehiclesRequired.Required RC2 Does not attempt to look up "generalDetails.numberOfVehiclesRequired.Required" but the key "taxiBookingForm .numberOfVehiclesContainer .numberOfVehiclesRequiredBorder .generalDetails.numberOfVehiclesRequired.Required" which is not found. 10:47:47.902 [http-8180-1] DEBUG org.apache.wicket.Localizer - Locate property: key: 'Required'; Component: '[MarkupContainer [Component id = generalDetails.numberOfVehiclesRequired]]' 10:47:47.903 [http-8180-1] DEBUG org.apache.wicket.resource.loader.ComponentStringResourceLoader - component: '[MarkupContainer [Component id = generalDetails.numberOfVehiclesRequired]]'; key: 'Required' 10:47:47.903 [http-8180-1] DEBUG org.apache.wicket.resource.loader.ComponentStringResourceLoader - key: 'taxiBookingForm .numberOfVehiclesContainer .numberOfVehiclesRequiredBorder .generalDetails.numberOfVehiclesRequired.Required'; class: 'com.rp.webapp.taxi.TaxiBookingPage'; locale: 'en_GB'; Style: 'null' 10:47:47.903 [http-8180-1] DEBUG org.apache.wicket.resource.loader.ComponentStringResourceLoader - Found properties file: 'com/rp/webapp/taxi/TaxiBookingPage.' but it doesn't contain the property So it seems the lookup algorithm hasn't changed but the message key. Is this a bug or should we now be using the full form-relative key as shown above? Alexander Lohse wrote: I could not find any reported changes concerning validation message keys from version 1.4-m3 to 1.4-rc2, but I have the following "required" key in my application resources that does not work anymore. .. trim .. -- View this message in context: http://www.nabble.com/validation-message-keys-differences-on-m3-to-rc2-tp22155986p22431244.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - 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
Add AJAX behaviour to embedded custom form component
I've developed a custom form component (FormComponentPanel), a date picker, that makes use of 2 fields - a display TextField and a HiddenField for the model data. I'm then adding this to the page with a span tag: [dropoff date picker] Then in the java : DatePicker dropoffDatePicker = new DatePicker("dropoffDate", new PropertyModel(this, "dropoffDate"), (new LocalDate()).minusDays(0), (new LocalDate()).plusYears(3)); I'm after some advice on the best way to attach an AJAX behaviour to the component. If for example I add an AJAX behaviour directly to the date picker component then it's attached to the span tag and obviously doesn't work. The only way I've found to get around this is to expose the date display field with a public getter so I can then attach the onchange event. dropoffDatePicker.getDateDisplayField().add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { .. } }); Any suggestions for a better way to do this that doesn't involve exposing the innards? -Gianni - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Custom validator variablesMap() - Value of variable [[input]] could not be resolved
Hi I've written a custom validator and error message and I'm adding my own variables to the error message by overriding variablesMap(). My error message looks like thie: ${input} must be between ${startDate} and ${endDate} As I understand 3 default variables should be substituted by the validator for ${label} ${input} and ${name}; if I use ${label} and $ {name} they get substituted fine but ${input} is not: WicketMessage: Exception 'java.lang.IllegalArgumentException: Value of variable [[input]] could not be resolved while interpolating [[$ {input} must be between ${startDate} and ${endDate}]]' occurred during validation com.resprompt.webapp.validation.LocalDateTimeValidator $LocalDateTimeRangeValidator on component 0:carHireSearchForm:dropoffDate I've had a look through the source for the Wicket built-in validators and I can't seem any instance of 'input' being added explicitly to the variablesMap, any ideas why this isn't being set for me? public abstract class LocalDateTimeValidator extends AbstractValidator { private static final long serialVersionUID = -5922211613447031430L; private static Logger log = LoggerFactory.getLogger(LocalDateTimeValidator.class); public static LocalDateTimeValidator range(U startDate, U endDate) { return new LocalDateTimeRangeValidator(startDate, endDate); } public static class LocalDateTimeRangeValidatorBaseLocal> extends LocalDateTimeValidator { private static final long serialVersionUID = -6335920679560594249L; private T startDate; private T endDate; public LocalDateTimeRangeValidator(T startDate, T endDate) { this.startDate = startDate; this.endDate = endDate; } @Override protected void onValidate(IValidatable validatable) { BaseLocal date = validatable.getValue(); if (!(date.isAfter(startDate) && date.isBefore(endDate))) { error(validatable); } } @Override protected String resourceKey() { return "LocalDateTimeRangeValidator"; } @Override protected Map variablesMap(IValidatable validatable) { Map map = super.variablesMap(validatable); map.put("startDate", startDate); map.put("endDate", endDate); return map; } } } Thanks Gianni - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
FormComponentPanel and specifying tabindex for form input
I've got a custom date picker component that extends FormComponentPanel and I include it in my markup with. [date picker] The component uses a hidden form field to store an ISO formatted date value and a display field to show the localised full date. It's the hidden field that is used as the component model. I'd like to somehow be able to specify the tabindex attribute for the date display field in the page markup, so that this can be controlled by the page designer. I tried setting a tabindex attribute on the with the intention of removing it and then setting it on the date field, but the attribute is immutable and can't be removed from the . Any ideas? Thanks Gianni - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org