Closing of meta tags

2010-07-28 Thread Gianni
I'm controlling the content of my meta tags with an AttributeAppender and in 
my markup they are closed with /

meta wicket:id=metaKeywords name=keywords content= /
meta wicket:id=metaDescription name=description content= /

WebComponent keywords = new WebComponent(metaKeywords);
StringResourceModel keyModel = new 
StringResourceModel(meta.standard-keywords, this, new ModelPage(this));
keywords.add(new AttributeAppender(content, keyModel,  ));
add(keywords);

On output the tags are getting closed with /meta
meta name=keywords content=my keywords /meta

Is there any way to prevent the separate closing tag and just keep the / ?
-Gianni
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Closing of meta tags

2010-07-28 Thread Gianni
I get an ugly error message in the Safari Web Inspector saying Unmatched 
/meta encountered. Ignoring tag

Not sure why it flags it up as an error as I'm using the XHTML 1.0 Transitional 
DTD and the closing tag must be valid, I'd just rather use the shorthand for 
neatness.


On 28/lug/2010, at 17.26, Igor Vaynberg wrote:

 is it causing you harm?
 
 -igor
 
 On Wed, Jul 28, 2010 at 8:09 AM, Gianni gdoe6...@yahoo.it wrote:
 I'm controlling the content of my meta tags with an AttributeAppender and 
 in my markup they are closed with /
 
 meta wicket:id=metaKeywords name=keywords content= /
 meta wicket:id=metaDescription name=description content= /
 
 WebComponent keywords = new WebComponent(metaKeywords);
 StringResourceModel keyModel = new 
 StringResourceModel(meta.standard-keywords, this, new ModelPage(this));
 keywords.add(new AttributeAppender(content, keyModel,  ));
 add(keywords);
 
 On output the tags are getting closed with /meta
 meta name=keywords content=my keywords /meta
 
 Is there any way to prevent the separate closing tag and just keep the / ?
 -Gianni
 -
 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: HttpsRequestCycleProcessor not immediately redirecting to https

2010-03-18 Thread Gianni
Apologies, I now see it's exactly the same problem as described here:
http://old.nabble.com/%40RequireHttps---forms-misbehaving-ts26845496.html

I can reproduce this in a quickstart, I just want to check before creating a 
jira:
- In my quickstart I'm calling setRedirect(true) within the form submit 
button's onSubmit(), is this the correct place to force a redirect?
- SignInPage has the @RequireHttps annotation, *should* the code below result 
in immediate redirection to the https page or am I missing something?

Button submitButton = new Button(submit) {
@Override
public void onSubmit() {
setRedirect(true);
setResponsePage(new SignInPage());
}
};

-Gianni


On 17/mar/2010, at 10.13, Gianni wrote:

 As part of a product purchase workflow I require users to sign-in or register 
 a new account in order to continue.
 In my purchase page I'm checking if the user is already signed-in and if not 
 I send them to a SignInOrRegisterPage which has the @RequireHttps annotation.
 
 BookingPage dest = new BookingPage(product);
 if (signedIn) {
   setResponsePage(dest);
 } else {
   session.getDefaultPageMap().put(dest);
   PageReference destPageRef = dest.getPageReference();
   setResponsePage(new SignInOrRegisterPage(destPageRef));
 }
 
 @RequireHttps
 public class SignInOrRegisterPage extends StandardBasePage {
private PageReference destination;
 
public SignInOrRegisterPage(PageReference finalDest) {
 ..
 
 In MyApplication:
 @Override
protected IRequestCycleProcessor newRequestCycleProcessor() {
HttpsConfig config = new 
 HttpsConfig(MyApplication.get().getHttpPort(), 
 MyApplication.get().getHttpsPort());
return new HttpsRequestCycleProcessor(config) {
@Override
protected IRequestCodingStrategy newRequestCodingStrategy() {
return new CryptedUrlWebRequestCodingStrategy(new 
 WebRequestCodingStrategy());
}
};
}
 
 
 The initial redirection to SignInOrRegisterPage does not go to https, only 
 when I submit the form on the http SignInOrRegisterPage does it then redirect 
 to https.
 Any ideas why it's not going immediately to https?
 Thanks
 Gianni
 -
 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



HttpsRequestCycleProcessor not immediately redirecting to https

2010-03-17 Thread Gianni
As part of a product purchase workflow I require users to sign-in or register a 
new account in order to continue.
In my purchase page I'm checking if the user is already signed-in and if not I 
send them to a SignInOrRegisterPage which has the @RequireHttps annotation.

BookingPage dest = new BookingPage(product);
if (signedIn) {
setResponsePage(dest);
} else {
session.getDefaultPageMap().put(dest);
PageReference destPageRef = dest.getPageReference();
setResponsePage(new SignInOrRegisterPage(destPageRef));
}

@RequireHttps
public class SignInOrRegisterPage extends StandardBasePage {
private PageReference destination;

public SignInOrRegisterPage(PageReference finalDest) {
..

In MyApplication:
@Override
protected IRequestCycleProcessor newRequestCycleProcessor() {
HttpsConfig config = new HttpsConfig(MyApplication.get().getHttpPort(), 
MyApplication.get().getHttpsPort());
return new HttpsRequestCycleProcessor(config) {
@Override
protected IRequestCodingStrategy newRequestCodingStrategy() {
return new CryptedUrlWebRequestCodingStrategy(new 
WebRequestCodingStrategy());
}
};
}


The initial redirection to SignInOrRegisterPage does not go to https, only when 
I submit the form on the http SignInOrRegisterPage does it then redirect to 
https.
Any ideas why it's not going immediately to https?
Thanks
Gianni
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Redirect to bookmarkable page from self - broken in 1.4.6?

2010-02-25 Thread Gianni
I've mounted a bookmarkable page as follows:

mount(new IndexedParamUrlCodingStrategy(destinations, 
DestinationGuidePage.class));

Then I've got a drop-down menu with an ajax behaviour to redirect to the same 
page with different parameters:

destinationChoice.add(new AjaxFormComponentUpdatingBehavior(onchange) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
onUpdateSelection(target);
}
});

protected void onUpdateSelection(AjaxRequestTarget target) {
PageParameters params = new PageParameters(0= + 
selectedCountry.getId());
setResponsePage(DestinationGuidePage.class, params);
}

In 1.4.5 this works fine and the relative redirect is ../destinations/my 
parameter

DEBUG org.apache.wicket.Page - ending request for page [Page class = 
com.myapp.webapp.destguide.DestinationGuidePage, id = 3, version = 0], request 
[method = POST, protocol = HTTP/1.1, requestURL = 
http://local.mydomain.com:8180/myapp/URC107/, contentType = 
application/x-www-form-urlencoded, contentLength = 35, contextPath = 
/myapp/URC107, pathInfo = null, requestURI = /myapp/URC107/, servletPath = 
/URC107/, pathTranslated = null]
DEBUG org.apache.wicket.protocol.http.WebResponse - Redirecting to 
../destinations/AN

This no longer works in 1.4.6 as it redirects to destinations/my parameter 
which results in the full URL /myapp/URC107/destinations/destinations/my 
parameter

DEBUG org.apache.wicket.Page - ending request for page [Page class = 
com.myapp.webapp.destguide.DestinationGuidePage, id = 6, version = 0], request 
[method = POST, protocol = HTTP/1.1, requestURL = 
http://local.mydomain.com:8180/myapp/URC107/, contentType = 
application/x-www-form-urlencoded, contentLength = 35, contextPath = 
/myapp/URC107, pathInfo = null, requestURI = /myapp/URC107/, servletPath = 
/URC107/, pathTranslated = null]
DEBUG org.apache.wicket.protocol.http.WebResponse - Redirecting to 
destinations/AT

I can't see any indications in the 1.4.6 release notes to say this behaviour 
may have changed, is this a bug?
-Gianni


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



IndexedSharedResourceCodingStrategy - shared resource not found

2009-09-25 Thread Gianni
I'm mounting a shared resource with  
IndexedSharedResourceCodingStrategy and in my Application class I've  
got:


init() {
  ...
  // DynamicCss extends DynamicWebResource
  Resource dynamicCssResource = new DynamicCss();
  getSharedResources().add(dynCss, dynamicCssResource);
  mount(new IndexedSharedResourceCodingStrategy(style, dynCss));
  ...
}

I can access the shared resource fine if I obtain it via the  
ResourceReference constructor e.g. in Page -
add(CSSPackageResource.getHeaderContribution(new  
ResourceReference(dynCss), screen));


But if I try to access the resource via the mount point I get the  
following error in the logs:

http://my host/context path/style
o.a.wicket.request.target.resource.SharedResourceRequestTarget -  
shared resource dynCss not found or not allowed access


Is this a bug in IndexedSharedResourceCodingStrategy or am I missing  
something?

Any suggestions much appreciated.
-Gianni

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



Prefix URL for skinnable site

2009-08-20 Thread Gianni
I have an app which needs to be skinnable, I know this can be done  
with Session styles but I need the correct skin to display when there  
is no session available e.g. on app entry or page expired ..


I thought the best way to do this would be to prefix every url with  
the skin ID

/context/skin identifier/wicket path, bookmarkable or otherwise
I could then user the skin ID to set the session style and the rest of  
the path would pass through the usual wicket decoding, minus the skin  
id.


Where would be the right place to implement this functionality?
I saw some old posts using WebRequestCodingStrategy urlPrefix() but  
this is no longer present in the api.

http://article.gmane.org/gmane.comp.java.wicket.user/20294

Or maybe I'm better off doing this in a servlet filter before it gets  
to Wicket?

-Gianni

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



Re: Prefix URL for skinnable site

2009-08-20 Thread Gianni

On 20/ago/09, at 14:47, Michael Mosmann wrote:




Where would be the right place to implement this functionality?


I think, you should use MixedParamUrlCodingStrategy

mm:)


That's only going to work with  bookmarkable pages though.

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



Re: Prefix URL for skinnable site

2009-08-20 Thread Gianni
problem is all skins need to be under the same fqdn so I can't look up  
a skin based on the domain name when no other clues are available,  
which is why I was thinking the only way to do this is a prefix  
parameter before the wicket part of the url.. which I imagine Wicket  
needs to see as part of the servlet context in order for it to work.

-Gianni

On 20/ago/09, at 16:55, Igor Vaynberg wrote:


as long as you always set the right skin based on whatever it is
(domain name, etc) it will always be used. wicket always creates an
instance of Session object and uses that even if it does not persist
that into http session.

-igor

On Thu, Aug 20, 2009 at 5:25 AM, Giannigdoe6...@yahoo.it wrote:
I have an app which needs to be skinnable, I know this can be done  
with
Session styles but I need the correct skin to display when there is  
no

session available e.g. on app entry or page expired ..

I thought the best way to do this would be to prefix every url with  
the skin

ID
/context/skin identifier/wicket path, bookmarkable or otherwise
I could then user the skin ID to set the session style and the rest  
of the

path would pass through the usual wicket decoding, minus the skin id.

Where would be the right place to implement this functionality?
I saw some old posts using WebRequestCodingStrategy urlPrefix() but  
this is

no longer present in the api.
http://article.gmane.org/gmane.comp.java.wicket.user/20294

Or maybe I'm better off doing this in a servlet filter before it  
gets to

Wicket?
-Gianni

-
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-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]



Re: LoadableDetachableModel for drop-down menu selection

2008-10-28 Thread Gianni
Thanks Igor, I've already got my entity model LoadableRefDataModel  
which is similar to your example and I can see how to make use of this  
when I've actually got the entity object or id. My problem is I'm not  
clear on how I go about creating the entity model when a value is  
selected from my drop-down menu.



  private Country selectedCountry;



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



In the above example selectedCountry is populated when a value is  
selected from the drop-down, what I'd like to do is replace  
selectedCountry with a LoadableDetachableModel.

i.e.
private LoadableRefDataModel Country country;

But I can't work out where to put the instantiation code. Is there  
some method of DropDownChoice I can override to do this or would I  
wrap my entity model in another model, overriding setObject() to  
instantiate my entity model.

What would be the recommended way?
-Gianni



On 28/ott/08, at 21:06, Igor Vaynberg wrote:


this should give you an idea

http://wicketinaction.com/2008/09/building-a-smart-entitymodel/

-igor

On Tue, Oct 28, 2008 at 12:27 PM, Gianni Doe [EMAIL PROTECTED]  
wrote:
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]




-
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]



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]