Re: Apache Wicket releases Wicket 1.5

2011-09-07 Thread Bernhard Schauer

w00t, Wicket FTW!

On 2011-09-08 05:31, Duy Do wrote:

Big news! You made my day. Thanks a lot for your great working.


On 9/8/11 5:17 AM, Martijn Dashorst wrote:
The Apache Wicket team is proud to announce the immediate 
availability of the
newest release of their component oriented open source Java web 
framework.
Apache Wicket 1.5 has been in development for the last two years and 
brings

many improvements over previous versions.

Downloading Apache Wicket 1.5
-

You can download the release here:
http://www.apache.org/dyn/closer.cgi/wicket/1.5.0

Or use this in your Maven POM to upgrade to the new version:

dependency
groupIdorg.apache.wicket/groupId
artifactIdwicket-core/artifactId
version1.5.0/version
/dependency

Please note that Wicket’s main artifact ID has been renamed to 
wicket-core.


You will need to upgrade all modules (i.e. wicket, wicket-extensions,
wicket-ioc, wicket-spring, etc) to 1.5.0. It is not possible to mix 
previous

versions of Wicket with modules of this release.

Most notable changes


With this release the Wicket team has revised many of its internals. A
short list:

  - HTML5 components added: EmailTextField, NumberTextField, 
UrlTextField and

RangeTextField

  - New inter-component events (explained below)

  - Minimum required servlet API is servlet-api 2.5

  - All standard validators now extend Behavior to allow for client side
validations

  - IBehavior has been removed and AbstractBehavior has been 
deprecated, you

should now extend Behavior instead

  - Simplified the request cycle processing and made it more extensible

  - URL handling is now in one place

  - Wicket’s rendering code has been greatly simplified

  - Improved browser caching support

  - ClientSideImageMap replaces old ImageMap

  - Better support for running behind proxies with x-forwarded-for 
header


  - Request cycle listeners make it easier to integrate frameworks in 
your

Wicket application

  - Consistent naming: methods with Javascript in the name have been 
renamed to

use proper capitalization: JavaScript

  - Switching to HTTPS is as simple as configuring a new root mapper 
to make

Wicket HTTPS aware and annotating a page with @RequireHttps

A longer list of changes and improvements can be found in our migration
guide.

Inter-component events
--

Wicket 1.5 offers a simple, yet flexible, way for component to 
communicate

with each other in a decoupled manner. The two major interfaces that
facilitate this are:

/**
 * Objects that can send events
 */
public interface IEventSource {
T  void send(IEventSink sink, Broadcast broadcast, T payload);
}

and

/**
 * Objects that can receive events
 */
public interface IEventSink
{
/**
 * Called when an event is sent to this sink
 */
void onEvent(IEvent?  event);
}

The classes that implement these interfaces, and can thus participate 
in the

event mechanism are: Component, RequestCycle, Session, and Application.

The mechanism allows for different event broadcast methods defined here:

/**
 * Defines the event broadcast type.
 */
public enum Broadcast {
BREADTH,
DEPTH,
BUBBLE,
EXACT;
}

There is an example in wicket-examples which demonstrates the usage 
of this.


Applications can register custom event dispatchers in 
FrameworkSettings; the
dispatchers can be used to build custom event delivery mechanisms. 
For example
a custom IEventDispatcher mechanism can route events to annotated 
methods, for

example:

public class MyComponent extends Component {
@OnEvent
private void onUserAdded(UserAddedEvent event) {...}
}

where UserAddedEvent is the event payload object.

The default Component#onEvent method will be called even if custom 
dispatchers

are registered.

A default event is raised whenever Wicket begins to create an AJAX 
response.

The payload of the event is the AjaxRequestTarget used for event. Sample
implementation:

// component that always adds itself to the ajax response
public class MyComponent extends Component {
public void onEvent(IEvent event) {
if (event.getPayload() instanceof AjaxRequestTarget) {
((AjaxRequestTarget)event.getPayload()).add(this);
 }
}
}

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

Re: How to run some JS only once after Ajax rendering is done ?

2010-09-07 Thread Bernhard Schauer
I think you could do it as follows. The js function 'bindYourEvent()' is 
called after the the components that are added to the AjaxRequestTarget 
are 're-painted'.


   form.add(new AjaxButton(set) {
   @Override
   protected void onSubmit(final AjaxRequestTarget target, 
final Form? form) {

   target.appendJavascript(bindYourEvent(););
   }

   });

mfg Bernhard

Joseph Pachod schrieb:

hi

I've some components which require some client side javascript which 
require one init call (for all) to be initialized. In fact, this init 
call uses selectors to get at the components to work one.


My issues is with Ajax. It happens that, during it, some new 
components required this init call are added.


As such, how could I trigger it only once per Ajax request ?

The pattern I'm targeting is for each component to initialize this way 
to have a behavior in which something would be added only in Ajax 
request cycle. For non ajax request cycle, I use jquery to do the 
init, through:

 $(document).ready(function(){
   $.initEdit();
   });

When trying to reach this goal, I tried to run the init call through 
an header contributor, but the call is then done before my content is 
put on the page, making it useless:

public abstract class AbstractEditBehavior extends AbstractBehavior
{
   public AbstractEditBehavior(final AbstractTextComponent? component)
   {
   component.add(JQueryDependency.CORE);
   component.add(new HeaderContributor(new IHeaderContributor()
   {
   public void renderHead(final IHeaderResponse response)
   {
   if ((AjaxRequestTarget.get() != null))
   {
   response.renderJavascript(jQuery.initEdit();, ID
   + response.hashCode());
   }
   }
   }));

   }
(...)

thanks in advance
best



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



WicketRuntimeException when injecting into hidden form field

2010-09-06 Thread Bernhard Schauer

Hello,

in wicket forms get a hidden field. I found on the web, that this hidden 
field is needed for some kind of event handling. (Anyone knows more 
details?)


I played around with XSS-Me 
(https://addons.mozilla.org/de/firefox/addon/7598/) a firefox plugin, 
that tries to find XSS vulnerabilities.
What the addon does, is that it injects some values into that hidden 
field, and then wicket throws :
   WicketRuntimeException: Attempt to access unknown request listener 
interface null


Has anyone an idea, how this exception could be prevented? or caught?

mfg bernhard

the full trace is:

ERROR - RequestCycle   - Attempt to access unknown request 
listener interface null
org.apache.wicket.WicketRuntimeException: Attempt to access unknown 
request listener interface null

   at org.apache.wicket.markup.html.form.Form.dispatchEvent(Form.java:1327)
   at 
org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:874)

   at sun.reflect.GeneratedMethodAccessor41.invoke(Unknown Source)
   at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

   at java.lang.reflect.Method.invoke(Method.java:597)
   at 
org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:182)
   at 
org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73)
   at 
org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
   at 
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250)

   at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
   at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
   at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
   at 
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479)
   at 
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312)
   at 
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1089)
   at 
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:365)
   at 
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
   at 
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
   at 
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)

   at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
   at 
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)

   at org.mortbay.jetty.Server.handle(Server.java:295)
   at 
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:503)
   at 
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:841)

   at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:639)
   at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:210)
   at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:379)
   at 
org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:226)
   at 
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
** 
http://dict.leo.org/ende?lp=endep=Ci4HO3kMAAsearch=vulnerabilitytrestr=0x8001 



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