Re: Wicket And GAE

2010-04-10 Thread Juha Palomäki
I think the main issue is that for the development mode you need to
disable resource polling, since that is using threads (which are not
supported in GAE). This is described here:
http://stronglytypedblog.blogspot.com/2009/04/wicket-on-google-app-engine.html

One problem with this is that this obviously disables the resource
reloading, which might be slightly annoying when developing. There
might be more elegant solutions to this, but in order to overcome this
I wrote my own ModificationWatcher implementation (see code below). My
own modificationwatcher does not use threads, instead you must
manually call it every now and then so that it will see if the
resources have been changed.

In order to use my StaticModificationWatcher, you need to include the
following stuff in your Wicket Application class.

@Override
protected void init() {
super.init();
// your standard init stuff goes here
if(development.equalsIgnoreCase(getConfigurationType())) {
staticModificationWatcher = new 
StaticModificationWatcher();

getResourceSettings().setResourceWatcher(staticModificationWatcher);

getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND);

getResourceSettings().setAddLastModifiedTimeToResourceReferenceUrl(true);
} else {

getResourceSettings().setAddLastModifiedTimeToResourceReferenceUrl(false);
getResourceSettings().setResourcePollFrequency(null);
}

@Override
public RequestCycle newRequestCycle(Request request, Response response) {
// In deploymentmode we are not using the 
staticModificationWatcher
if(staticModificationWatcher != null) {
staticModificationWatcher.RunCheck();
}
return super.newRequestCycle(request, response);
}   


And the  StaticModicationWatcher.java


import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.apache.wicket.util.listener.ChangeListenerSet;
import org.apache.wicket.util.listener.IChangeListener;
import org.apache.wicket.util.time.Duration;
import org.apache.wicket.util.time.Time;
import org.apache.wicket.util.watch.IModifiable;
import org.apache.wicket.util.watch.IModificationWatcher;

public class StaticModificationWatcher implements IModificationWatcher {

private static StaticModificationWatcher instance;

private static final class Entry {
// The most recent lastModificationTime polled on the object
Time lastModifiedTime;

// The set of listeners to call when the modifiable changes
final ChangeListenerSet listeners = new ChangeListenerSet();

// The modifiable thing
IModifiable modifiable;
}

private MapIModifiable, Entry listeners;

/**
 * Call this method regularly
 */
public void RunCheck() {
// Use a separate list to avoid concurrent modification 
exceptions (notifying
// the listener might cause a call to the add -method of this 
class)
CollectionChangeListenerSet toBeNotified = new
ArrayListChangeListenerSet();
for(Entry entry : listeners.values()) {

if(entry.modifiable.lastModifiedTime().equals(entry.lastModifiedTime)
== false) {
toBeNotified.add(entry.listeners);
//  entry.listeners.notifyListeners();  

}
entry.lastModifiedTime = 
entry.modifiable.lastModifiedTime();
}
for(ChangeListenerSet changeListenerSet : toBeNotified) {
changeListenerSet.notifyListeners();
}
}

public StaticModificationWatcher() {
listeners = Collections.synchronizedMap(
new HashMapIModifiable, Entry());
}

@Override
public boolean add(IModifiable modifiable, IChangeListener listener) {
boolean contains = listeners.containsKey(modifiable);
if(contains == false) {
Entry entry = new Entry();
entry.modifiable = modifiable;
entry.lastModifiedTime = modifiable.lastModifiedTime();
listeners.put(modifiable, entry);
}
listeners.get(modifiable).listeners.add(listener);

return contains;
}

@Override
public void destroy() {
// nothing to do

}

@Override

Re: JavaOne in San Francisco

2010-04-10 Thread Martijn Dashorst
On Sat, Apr 10, 2010 at 12:07 AM, Eelco Hillenius
eelco.hillen...@gmail.com wrote:
 And i to the N900..
 I want freedom, dont want to be controlled by fruit

 That's because you're enough of a fruity yourself. For most people
 though, an Apple a day is very healthy.

Though I don't find Apple's to be too expensive, such a move would
bankrupt me faster than wiring all my money to Bernie Madoff.

Martijn

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



Re: Any mature work on integrating Hibernate Validator with Wicket?

2010-04-10 Thread Uwe Schäfer

Carlos Vara schrieb:


Seeing as it is only 2 simple classes, and that the external dependencies
can be reduced to a minimum (just javax-validation-api)


i think message resolution is flawed (i18n) and making wicket directly 
dependent from javax.validation might be a bad thing.


cu uwe

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



Re: JavaOne in San Francisco

2010-04-10 Thread Marek Šabo
Yeah, same here :(

On 04/09/2010 08:21 PM, James Carman wrote:
 I've got a G1.  Unfortunately T-Mobile won't give me the new OS update yet. :(

 On Fri, Apr 9, 2010 at 11:12 AM, Igor Vaynberg igor.vaynb...@gmail.com 
 wrote:
   
 but i just switched to htc hero :|

 -igor

 On Fri, Apr 9, 2010 at 7:10 AM, James Carman
 jcar...@carmanconsulting.com wrote:
 
 There's an app for that:

 http://www.gadgettastic.com/2008/07/07/iphone-beer-app/

 On Fri, Apr 9, 2010 at 9:25 AM, nino martinez wael
 nino.martinez.w...@gmail.com wrote:
   
 I'd like to have a beer too, but I fear it has to be viirtual. Budget
 this year are only for geeCon and Devoxx. Maybe overseas next year...

 regards Nino

 2010/4/9 shetc sh...@bellsouth.net:
 
 Sounds great!
 --
 View this message in context: 
 http://old.nabble.com/JavaOne-in-San-Francisco-tp28180298p28190645.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


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


   


-- 
Marek Šabo
Server Manager
Club SU CVUT Buben
Bubenečská Kolej (421)
XMPP: zeratul...@gmail.com


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



Re: JavaOne in San Francisco

2010-04-10 Thread nino martinez wael
Heh and Im stuck with the htc diamond. At least it sort of runs
android, half of hardware unsupported..



2010/4/9 James Carman jcar...@carmanconsulting.com:
 There's an app for that:

 http://www.gadgettastic.com/2008/07/07/iphone-beer-app/

 On Fri, Apr 9, 2010 at 9:25 AM, nino martinez wael
 nino.martinez.w...@gmail.com wrote:
 I'd like to have a beer too, but I fear it has to be viirtual. Budget
 this year are only for geeCon and Devoxx. Maybe overseas next year...

 regards Nino

 2010/4/9 shetc sh...@bellsouth.net:

 Sounds great!
 --
 View this message in context: 
 http://old.nabble.com/JavaOne-in-San-Francisco-tp28180298p28190645.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: Any mature work on integrating Hibernate Validator with Wicket?

2010-04-10 Thread David Chang
hi, did you get the jsr 303 validation code released? where can i find it? i am 
really excited looking forward to it. 

all the best,
david



--- On Mon, 4/5/10, Uwe Schäfer u...@thomas-daily.de wrote:

 From: Uwe Schäfer u...@thomas-daily.de
 Subject: Re: Any mature work on integrating Hibernate Validator with Wicket?
 To: users@wicket.apache.org
 Date: Monday, April 5, 2010, 11:08 AM
 David Chang schrieb:
 
  Any comment or pointers regarding relatively mature
 work in this regard?
 
 we did something that does not need spring, though it need
 some polishing and is not yet released.
 i´ll contact you later this week.
 
 cu uwe
 
 -
 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



http://cwiki.apache.org/WICKET is down

2010-04-10 Thread Carlos Chávez
Hello everyone.

I just want to let all know that the wiki is seems down,
can anyone confirm this ?

I understand the wiki is on http://cwiki.apache.org/WICKET

--
Cheers.
Carlos Chávez.


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



Re: http://cwiki.apache.org/WICKET is down

2010-04-10 Thread Brian Topping
Yes, I saw that too.  Apache infrastructure was attacked this week, I presume 
they are working on repairing things right now.

On Apr 10, 2010, at 2:00 PM, Carlos Chávez wrote:

 Hello everyone.
 
 I just want to let all know that the wiki is seems down,
 can anyone confirm this ?
 
 I understand the wiki is on http://cwiki.apache.org/WICKET
 
 --
 Cheers.
 Carlos Chávez.
 
 
 -
 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



Trying to do something complicated with ListMultipleChoice model

2010-04-10 Thread Ray Weidner
Hi,

I'm pretty new to Wicket and trying to get a better understanding of how
models work.  That's probably why this is such a tricky problem for me.

On my site, users are submitting a form for a new Issue to be created.  One
of the fields of this Issue is affectedParties; in the data model, this is
represented by a collection of PartyIssue objects, which associate a Party
with an Issue.  Here's the simplified code:

public class Issue {
...
private Set PartyIssue affectedParties;

public Set PartyIssue getAffectedParties () { ... }
public void setAffectedParties (Set PartyIssue affectedParties) { ...
}
...
}

public class Party {
...
}

public class PartyIssue {
private Issue issue;
private Party party;
...
}

The new Issue Form uses a new Issue object as the argument for the
CompoundPropertyModel.  What I want to do is allow users to specify the
affected parties by multi-selecting from a list of Parties.  Then, at the
time of submission, we should iterate through this list and construct
corresponding PartyIssues, which are associated with the Issue and then
created by the service layer (with validation etc.).

So, how would I do this?  This is how I've been trying to construct the
ListMultipleChoice:

private Set Party affectedParties = new HashSet Party ();

private ListMultipleChoice Party buildPartyDropdown (String property) {
IModel Collection Party affectedPartyModel = new IModel Collection
Party () {
@Override
public Collection Party getObject () {
return affectedParties;
}

@Override
public void setObject (Collection Party arg0) {
affectedParties.clear ();
affectedParties.addAll (arg0);
}

@Override
public void detach () {
// Nothing to do here
}
};

IChoiceRenderer Party partyListRenderer = new IChoiceRenderer Party
() {
private static final long serialVersionUID = -1588547331340300417L;

@Override
public Object getDisplayValue (Party arg0) {
return arg0.getFullName ();
}

@Override
public String getIdValue (Party arg0, int arg1) {
return Long.toString (arg0.getRecordId ());
}
};

ListMultipleChoice Party choice = new ListMultipleChoice Party
(property,
affectedPartyModel,
new Vector Party (getAllParties ()),
partyListRenderer);

return choice;
}

In my onSubmit() code for the Form, I attempt to iterate through the
affectedParties Set to create the Set of PartyIssues.  However, this is
always turning out to be empty no matter what is selected on the form.  The
problem isn't in the onSubmit() code because the rest of the form is
processed and persisted properly, and log messages show that affectedParties
is empty at that point.  Note that the list choices are being rendered
properly.  I'm sure I'm doing something very wrong so I'd appreciate any
guidance.


Re: Trying to do something complicated with ListMultipleChoice model

2010-04-10 Thread Sven Meier

Hi,

ListMultipleChoice puts all selected parties into the model object 
you're returning in #getObject().


Either you should return a copy of your collection in #getObject() or 
just do nothing in #setObject(). Your current call to #clear() is 
effectively clearing the new selection (i.e. affectedParties and arg0 
are identical).


Regards

Sven

Ray Weidner wrote:

Hi,

I'm pretty new to Wicket and trying to get a better understanding of how
models work.  That's probably why this is such a tricky problem for me.

On my site, users are submitting a form for a new Issue to be created.  One
of the fields of this Issue is affectedParties; in the data model, this is
represented by a collection of PartyIssue objects, which associate a Party
with an Issue.  Here's the simplified code:

public class Issue {
...
private Set PartyIssue affectedParties;

public Set PartyIssue getAffectedParties () { ... }
public void setAffectedParties (Set PartyIssue affectedParties) { ...
}
...
}

public class Party {
...
}

public class PartyIssue {
private Issue issue;
private Party party;
...
}

The new Issue Form uses a new Issue object as the argument for the
CompoundPropertyModel.  What I want to do is allow users to specify the
affected parties by multi-selecting from a list of Parties.  Then, at the
time of submission, we should iterate through this list and construct
corresponding PartyIssues, which are associated with the Issue and then
created by the service layer (with validation etc.).

So, how would I do this?  This is how I've been trying to construct the
ListMultipleChoice:

private Set Party affectedParties = new HashSet Party ();

private ListMultipleChoice Party buildPartyDropdown (String property) {
IModel Collection Party affectedPartyModel = new IModel Collection
Party () {
@Override
public Collection Party getObject () {
return affectedParties;
}

@Override
public void setObject (Collection Party arg0) {
affectedParties.clear ();
affectedParties.addAll (arg0);
}

@Override
public void detach () {
// Nothing to do here
}
};

IChoiceRenderer Party partyListRenderer = new IChoiceRenderer Party
() {
private static final long serialVersionUID = -1588547331340300417L;

@Override
public Object getDisplayValue (Party arg0) {
return arg0.getFullName ();
}

@Override
public String getIdValue (Party arg0, int arg1) {
return Long.toString (arg0.getRecordId ());
}
};

ListMultipleChoice Party choice = new ListMultipleChoice Party
(property,
affectedPartyModel,
new Vector Party (getAllParties ()),
partyListRenderer);

return choice;
}

In my onSubmit() code for the Form, I attempt to iterate through the
affectedParties Set to create the Set of PartyIssues.  However, this is
always turning out to be empty no matter what is selected on the form.  The
problem isn't in the onSubmit() code because the rest of the form is
processed and persisted properly, and log messages show that affectedParties
is empty at that point.  Note that the list choices are being rendered
properly.  I'm sure I'm doing something very wrong so I'd appreciate any
guidance.




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



Re: Wicket and JEE6

2010-04-10 Thread Erik Brakkee
On Mon, Apr 5, 2010 at 11:58 PM, James Carman
jcar...@carmanconsulting.comwrote:


 What I'll do is set it up in wicketstuff.  That way others can
 contribute/maintain it too.  I've got permission already, so I can put
 it up there sometime this evening.


Do you have a location already for the source? I still think that wicket
core would be a better place since wicket-spring and wicket-guice are also
already there.

Meanwhile I also did some refactoring already and implemented caching Not
much is left of the original code, but I think it is simpler the way I have
it now.  A side effect is that I also have a simple Injector class that can
be used to perform injection into any class. Almost all code I have a is
wicket-independent and the ComponentInstantiationListener is basically a
one-liner now.


Re: Trying to do something complicated with ListMultipleChoice model

2010-04-10 Thread Ray Weidner
Hi Sven,

Thanks, that did the trick.  I thought that the Collection argument was
being generated by the framework, but now I understand what's happening.

On Sat, Apr 10, 2010 at 4:00 PM, Sven Meier s...@meiers.net wrote:

 Hi,

 ListMultipleChoice puts all selected parties into the model object you're
 returning in #getObject().

 Either you should return a copy of your collection in #getObject() or just
 do nothing in #setObject(). Your current call to #clear() is effectively
 clearing the new selection (i.e. affectedParties and arg0 are identical).

 Regards

 Sven


 Ray Weidner wrote:

 Hi,

 I'm pretty new to Wicket and trying to get a better understanding of how
 models work.  That's probably why this is such a tricky problem for me.

 On my site, users are submitting a form for a new Issue to be created.
  One
 of the fields of this Issue is affectedParties; in the data model, this is
 represented by a collection of PartyIssue objects, which associate a Party
 with an Issue.  Here's the simplified code:

 public class Issue {
 ...
private Set PartyIssue affectedParties;

public Set PartyIssue getAffectedParties () { ... }
public void setAffectedParties (Set PartyIssue affectedParties) { ...
 }
 ...
 }

 public class Party {
 ...
 }

 public class PartyIssue {
private Issue issue;
private Party party;
 ...
 }

 The new Issue Form uses a new Issue object as the argument for the
 CompoundPropertyModel.  What I want to do is allow users to specify the
 affected parties by multi-selecting from a list of Parties.  Then, at the
 time of submission, we should iterate through this list and construct
 corresponding PartyIssues, which are associated with the Issue and then
 created by the service layer (with validation etc.).

 So, how would I do this?  This is how I've been trying to construct the
 ListMultipleChoice:

 private Set Party affectedParties = new HashSet Party ();

 private ListMultipleChoice Party buildPartyDropdown (String property) {
IModel Collection Party affectedPartyModel = new IModel Collection
 Party () {
@Override
public Collection Party getObject () {
return affectedParties;
}

@Override
public void setObject (Collection Party arg0) {
affectedParties.clear ();
affectedParties.addAll (arg0);
}

@Override
public void detach () {
// Nothing to do here
}
};

IChoiceRenderer Party partyListRenderer = new IChoiceRenderer Party
 () {
private static final long serialVersionUID = -1588547331340300417L;

@Override
public Object getDisplayValue (Party arg0) {
return arg0.getFullName ();
}

@Override
public String getIdValue (Party arg0, int arg1) {
return Long.toString (arg0.getRecordId ());
}
};

ListMultipleChoice Party choice = new ListMultipleChoice Party
 (property,
affectedPartyModel,
new Vector Party (getAllParties ()),
partyListRenderer);

return choice;
 }

 In my onSubmit() code for the Form, I attempt to iterate through the
 affectedParties Set to create the Set of PartyIssues.  However, this is
 always turning out to be empty no matter what is selected on the form.
  The
 problem isn't in the onSubmit() code because the rest of the form is
 processed and persisted properly, and log messages show that
 affectedParties
 is empty at that point.  Note that the list choices are being rendered
 properly.  I'm sure I'm doing something very wrong so I'd appreciate any
 guidance.



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




GAE loses shared resources

2010-04-10 Thread Jacob Brookover
Hello all,

I¹m running Wicket on Google App Engine.  Things have been going fairly
well, but I¹ve encountered a new issue.  GAE, at any moment, can wipe and
restart your application.  In doing so, you lose everything including
anything you¹ve added to SharedResources.  Unfortunately, this can happen in
the middle of a page load as illustrated here:

-Page request comes in
-Nifty MarkupFilter reads initial markup and creates some SharedResources
(for a variety of image states based on the filename in the markup)
-MarkupFilter sets the URL in the markup based on the URL provided by the
mounted SharedResource (e.g. ³img/logo.png² becomes
³/resources/INDIRA/img/logo_d.png² because I wanted the disabled version).
-Markup is returned to the browser
-GAE restarts the application, losing the added SharedResource mapping
-Browser requests the resource according to the mounted URL
-Wicket cannot find resource, missing image

My current hack idea is to add any shared resource to the GAE MemCache (URL
maps to File).  That works, but now, I just need to know where Wicket
actually looks up the file so I can add a fallback to check the GAE MemCache
if the file is not found.  My understanding is that the mounted
SharedResource path resolves to an actual path in the ServletContext, but I
can¹t figure out where that is happening.

I initially thought that I would just override SharedResources.get(), but I
don¹t think that is called when simply handling requests.  I also found
references to WebRequestCodingStrategy.RESOURCES_PATH_PREFIX, but none of
that seemed to help.  Finally, I dove deep into WicketFilter,
WebRequest/Response, SharedResourceRequestTarget etc but got completely
lost.  I assume it¹s in there someplace, though.

Any help would be appreciated.

Thanks!

Jake


Re: Any mature work on integrating Hibernate Validator with Wicket?

2010-04-10 Thread Uwe Schäfer

David Chang schrieb:
hi, did you get the jsr 303 validation code released? where can i find it? i am really excited looking forward to it. 


about to. just finishing examples tomorrow. stay tuned.

cu uwe

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



Re: Wicket and JEE6

2010-04-10 Thread James Carman
My implementation is available at:

http://svn.carmanconsulting.com/public/wicket-cdi/trunk/

The CdiPlugin class has an inject() method that can be used to inject
anything, also.

On Sat, Apr 10, 2010 at 5:11 PM, Erik Brakkee erik.brak...@gmail.com wrote:
 On Mon, Apr 5, 2010 at 11:58 PM, James Carman
 jcar...@carmanconsulting.comwrote:


 What I'll do is set it up in wicketstuff.  That way others can
 contribute/maintain it too.  I've got permission already, so I can put
 it up there sometime this evening.


 Do you have a location already for the source? I still think that wicket
 core would be a better place since wicket-spring and wicket-guice are also
 already there.

 Meanwhile I also did some refactoring already and implemented caching Not
 much is left of the original code, but I think it is simpler the way I have
 it now.  A side effect is that I also have a simple Injector class that can
 be used to perform injection into any class. Almost all code I have a is
 wicket-independent and the ComponentInstantiationListener is basically a
 one-liner now.


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



Re: resource (css) loading

2010-04-10 Thread sahar rostami
thank you Apple Grew
I can't receive your attachments. Are you sure they have been attached ?

On Thu, Apr 8, 2010 at 6:34 AM, Apple Grew appleg...@gmail.com wrote:

 Maybe u can try writing a stream locator as I did. I am attaching my stream
 locator with this mail.

 The necessary plumbing required with this is:-

 resourceSettings.addResourceFolder(WEB-INF/res);
 resourceSettings.setResourceStreamLocator(new AppStreamLocator());
 getSharedResources().putClassAlias(ApplicationCore.class, global);

 The above needs to be put in your Application class.

 Regards,
 Apple Grew
 my blog @ http://blog.applegrew.com/



 On Wed, Apr 7, 2010 at 10:19 PM, Stefan Lindner lind...@visionet.dewrote:

 You could e.g. write your own page class

class MyCustomersPage extens Page {
@Override
public void renderHead(HtmlHeaderContainer container) {
super.renderHead(container);
cssResourceReference =
 Session.get().getCssResourceReferenceForcustomer()

  container.getHeaderResponse().renderCSSReference(cssResourceReference);
}
}

 And then let each of your pages be a child of MyCustomersPage

 Stefan
 -Ursprüngliche Nachricht-
 Von: sahar rostami [mailto:sahar.rost...@gmail.com]
 Gesendet: Mittwoch, 7. April 2010 18:42
 An: users@wicket.apache.org
 Betreff: Re: resource (css) loading

 thank you moèz
 but i want to set the location for whole application not a specific file.

 On Wed, Apr 7, 2010 at 8:53 PM, moèz ben rhouma benrhouma.m...@gmail.com
 wrote:

  In java
 
  add(new StyleSheetReference(stylesheet, BasePage.class,
 *style.css*));
 
  style.css is the path of the file style.css (i.e you can write
  /stylesheets/style.css  ...)
 
  2010/4/7 sahar rostami sahar.rost...@gmail.com
 
   No , i want to know how wicket knows where is style.css?
  
   On Wed, Apr 7, 2010 at 8:24 PM, moèz ben rhouma 
  benrhouma.m...@gmail.com
   wrote:
  
If I understand , you can use in constructor of class java the
  following
code:
add(new StyleSheetReference(stylesheet, BasePage.class,
  style.css));
   
and in the html page you add:
link wicket:id=stylesheet 
   
2010/4/7 sahar rostami sahar.rost...@gmail.com
   
 Thanks MZemeck
 But my question in another form is Where wicket load css (which
   class)?
 how wicket knows where look up a css file?

 i'm trying to override default location of css file and read them
  from
 path(s) specified in application start up ,but i can't because i
  don't
know
 how wicket loads them.

 any idea would help me!
 thanks





 On Wed, Apr 7, 2010 at 7:50 PM, mzem...@osc.state.ny.us wrote:

  One difference I am aware of (and community correct me if I am
   wrong),
  Wicket GZIPs resources.  So if you directly link to the css
 using
  an
  href you will not have that feature.
 
 
 
 
  sahar rostami sahar.rost...@gmail.com
  04/07/2010 11:16 AM
  Please respond to
  users@wicket.apache.org
 
 
  To
  Wicket User Mailing List users@wicket.apache.org
  cc
 
  Subject
  resource (css) loading
 
 
 
 
 
 
  Hi all,
  I want to know how wicket loads css files from location
 specified
  in
  HeaderContributer or using href in  header?
 
  Thanks in advanced!
 
 
 
 
 
  Notice: This communication, including any attachments, is
 intended
solely
  for the use of the individual or entity to which it is
 addressed.
   This
  communication may contain information that is protected from
   disclosure
  under State and/or Federal law. Please notify the sender
  immediately
   if
  you have received this communication in error and delete this
 email
from
  your system. If you are not the intended recipient, you are
  requested
not
  to disclose, copy, distribute or take any action in reliance on
 the
  contents of this information.

   
  
 

 -
 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: resource (css) loading

2010-04-10 Thread Apple Grew
Maybe it was stripped by Wicket Mailing list. Anyway I will paste the code
in the mail itself.

Regards,
Apple Grew
my blog @ http://blog.applegrew.com/

--Code Starts--

/**
 * Web based application for e-shopping.
 * Copyright (C) 2010  Nirupam Biswas (AppleGrew)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see http://www.gnu.org/licenses/.
 */
package com.sym.core;

import java.util.Arrays;
import java.util.List;

import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.resource.locator.ResourceStreamLocator;

import com.sym.core.utils.MiscUtils;
import com.sym.html.pages.BaseLayoutPage;

public class AppStreamLocator extends ResourceStreamLocator {
private static final String HTML_EXT = .html;
private static final String CSS_EXT = .css;
private static final String JS_PATH = /js/;
private static final String CSS_PATH = /css/;
private static final String IMG_PATH = /img/;
private static final ListString IMG_EXTS = Arrays.asList(new String[]{
.png, .jpg, .gif, .svg });

private static final String PAGES_PACKAGE =
BaseLayoutPage.class.getPackage().getName();
private static final int PG_PACKAGE_NAME_LEN = PAGES_PACKAGE.length();
private static final int GLOBAL_PACKAGE_NAME_LEN =
ApplicationCore.class.getPackage().getName().length();

@Override
public IResourceStream locate(final Class? clazz, String path) {
//Only pages' (not components or panel etc.s') HTMLs and CSS will be
fetched from 'res' directory.
if(clazz.getName().startsWith(PAGES_PACKAGE)){
IResourceStream located = null;

if (path.endsWith(HTML_EXT) || path.endsWith(CSS_EXT)) {
located = super.locate(clazz, html/ +
ApplicationCore.getThemeName() + trimFolders(path, false));
}else if (IMG_EXTS.contains(MiscUtils.getExt(path))) {
located = super.locate(clazz, /img + trimFolders(path,
false));
}

if (located != null) {
return located;
}
}else if(clazz.equals(ApplicationCore.class)){
//Global shared resources have been requested.
IResourceStream located = null;
path = trimFolders(path, true);

if (path.startsWith(CSS_PATH) || path.startsWith(JS_PATH) ||
path.startsWith(IMG_PATH)) {
located = super.locateByResourceFinder(clazz, path);
if(located == null  path.startsWith(CSS_PATH)) {
located = super.locateByResourceFinder(clazz,
CSS_PATH + ApplicationCore.getThemeName()
+ path.substring(path.indexOf(CSS_PATH) +
CSS_PATH.length() - 1));
}
}
return located;
}
return super.locate(clazz, path);
}

private String trimFolders(final String path, final boolean
isGlobalPath) {
return isGlobalPath? path.substring(GLOBAL_PACKAGE_NAME_LEN)
: path.substring(PG_PACKAGE_NAME_LEN);
}

}


--Code Ends--

On Sun, Apr 11, 2010 at 9:18 AM, sahar rostami sahar.rost...@gmail.comwrote:

 thank you Apple Grew
 I can't receive your attachments. Are you sure they have been attached ?

 On Thu, Apr 8, 2010 at 6:34 AM, Apple Grew appleg...@gmail.com wrote:

  Maybe u can try writing a stream locator as I did. I am attaching my
 stream
  locator with this mail.
 
  The necessary plumbing required with this is:-
 
  resourceSettings.addResourceFolder(WEB-INF/res);
  resourceSettings.setResourceStreamLocator(new AppStreamLocator());
  getSharedResources().putClassAlias(ApplicationCore.class, global);
 
  The above needs to be put in your Application class.
 
  Regards,
  Apple Grew
  my blog @ http://blog.applegrew.com/
 
 
 
  On Wed, Apr 7, 2010 at 10:19 PM, Stefan Lindner lind...@visionet.de
 wrote:
 
  You could e.g. write your own page class
 
 class MyCustomersPage extens Page {
 @Override
 public void renderHead(HtmlHeaderContainer container) {
 super.renderHead(container);
 cssResourceReference =
  Session.get().getCssResourceReferenceForcustomer()
 
   container.getHeaderResponse().renderCSSReference(cssResourceReference);
 }
 }
 
  And then let each of your pages be a child of MyCustomersPage
 
  Stefan
  -Ursprüngliche Nachricht-
  Von: