Re: validation message-keys differences on m3 to rc2

2009-04-06 Thread Gianni Doe

ComponentStringResourceLoader's javadoc is very helpful here:

quote
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
/quote

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 gdoe6...@yahoo.it  
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.

?xml version=1.0 encoding=UTF-8?
!DOCTYPE properties SYSTEM http://java.sun.com/dtd/ 
properties.dtd

properties
  entry  
key=generalDetails.numberOfVehiclesRequired.RequiredYou must

enter the number of vehicles/entry
  .. snip ..
/properties

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



Re: validation message-keys differences on m3 to rc2

2009-03-18 Thread Gianni Doe

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 gdoe6...@yahoo.it  
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.

?xml version=1.0 encoding=UTF-8?
!DOCTYPE properties SYSTEM http://java.sun.com/dtd/properties.dtd;
properties
   entry  
key=generalDetails.numberOfVehiclesRequired.RequiredYou must

enter the number of vehicles/entry
   .. snip ..
/properties

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



FormComponentPanel and specifying tabindex for form input

2009-01-29 Thread Gianni Doe
I've got a custom date picker component that extends  
FormComponentPanelT and I include it in my markup with.

span wicket:id=startDatePicker[date picker]/span

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.

wicket:panel
input wicket:id=dateDisplay type=text class=dateDisplay/
input wicket:id=dateValue type=hidden/
/wicket:panel

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  
span 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 span.


Any ideas?
Thanks
Gianni


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



Custom validator variablesMap() - Value of variable [[input]] could not be resolved

2008-11-06 Thread Gianni Doe

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:
properties
entry key=LocalDateTimeRangeValidator${input} must be between  
${startDate} and ${endDate}/entry

/properties

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 LocalDateTimeValidatorT extends BaseLocal  
extends AbstractValidatorT {


private static final long serialVersionUID = -5922211613447031430L;
private static Logger log =  
LoggerFactory.getLogger(LocalDateTimeValidator.class);


public static U extends BaseLocal LocalDateTimeValidatorU  
range(U startDate, U endDate) {

return new LocalDateTimeRangeValidatorU(startDate, endDate);
}

public static class LocalDateTimeRangeValidatorT extends  
BaseLocal extends LocalDateTimeValidatorT {


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(IValidatableT validatable) {
BaseLocal date = validatable.getValue();
if (!(date.isAfter(startDate)  date.isBefore(endDate))) {
error(validatable);
}
}

@Override
protected String resourceKey() {
return LocalDateTimeRangeValidator;
}

@Override
protected MapString, Object variablesMap(IValidatableT  
validatable) {

MapString, Object 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]



Add AJAX behaviour to embedded custom form component

2008-11-03 Thread Gianni Doe
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:

span wicket:id=dropoffDate[dropoff date picker]/span

Then in the java :
DatePicker  dropoffDatePicker = new DatePicker(dropoffDate, new  
PropertyModelLocalDate(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]



LoadableDetachableModel for drop-down menu selection

2008-10-28 Thread Gianni Doe
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  
LoadableRefDataModelCountry(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 DropDownChoiceCountry countryChoice;

private DropDownChoiceLocation locationChoice;

private Country selectedCountry;

private ListLocation locations = new ArrayListLocation();

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);
IModelList? extends Country countryModel = new  
LoadableDetachableModelList? extends Country() {

@Override
protected ListCountry load() {
return refDataService.getCountries();
}
};

countryChoice = new DropDownChoiceCountry(
country, selectedCountry, countryModel,  
countryRenderer);


countryChoice.add(new  
AjaxFormComponentUpdatingBehavior(onchange) {

protected void onUpdate(AjaxRequestTarget target) {
this.selectedLocation = null;
locationChoice.setChoices(new  
ArrayListCountry(selectedCountry.getLocations()));

target.addComponent(locationChoice);
}
});

ChoiceRenderer locationRenderer = new  
ChoiceRenderer(description, id);

locationChoice = new DropDownChoiceLocation(
location, new PropertyModelLocation(this,  
selectedLocation), locations, locationRenderer);

}
}


public class LoadableRefDataModelT extends RefData extends  
LoadableDetachableModel {


@SpringBean
private RefDataService refDataService;

private ClassT type;

private Serializable id;

public LoadableRefDataModel(ClassT 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 = (ClassT) 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]



ContextImage not generating path relative to context root

2008-10-21 Thread Gianni Doe
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:
img wicket:id=logo src=mylogo.gif /

Then I add the Context image to my WebPage:
add(new ContextImage(logo, images/logos/mylogo.gif));

... and I end up with:
img src=../images/logos/mylogo.gif /

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.
 * p
 * For example, if your context root is http://server.com/myApp/ and  
the request is for

 * /myApp/mountedPage/, then the prefix returned might be ../../.
 * p
 * 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]