Quantcast
Channel: Windows Explorer utilities for easy life
Viewing all articles
Browse latest Browse all 28

SEO friendly URLs in Wicket

$
0
0

One of the drawbacks Wicket today are unreadable URL-addresses. This article discusses ways to circumvent this shortcoming found Enterra developers. The ultimate goal – to get the URL-addresses such as REST.

When using the described methods it is important to take into account the difference between the versions of the Wicket. Read more about it here: http://cwiki.apache.org/WICKET/migrate-13.html

Generally REST address type can be obtained for pages assembled using the method

WebApplication.mount ().

To do this in the constructor org.apache.wicket.protocol.http.WebApplication perform the following:

mount ( "/ pages", PackageName.forPackage (HomePage.class.getPackage ()));
mount ( "/ pages / user", PackageName.forPackage (ProfilePage.class.getPackage ()));
mount ( "/ pages / user / personal", PackageName.forPackage (MyAccountPage.class.getPackage ()));

arguments about the mount () can be found in the documentation.

English via Skype

In this case, the pages of URL-addresses located in the installed packages are as follows:

http: // localhost: 9090 / wicket_res / app / pages / HomePage
http: // localhost: 9090 / wicket_res / app / pages / user / personal / MyProfilePage

parameters for those pages look like this:
http: // localhost: 9090 / wicket_res / app / pages / user / personal / MyProfilePage / tab / Basic used option: tab = Basic.

How convenient this method?
1. all of the pages can be mounted at the same time as they are created in the package
2. by adding BookmarkablePageLink, binding to this page of the desired view is acquired immediately.

shape
Create an address of this type for the forms (org.apache.wicket.markup.html.form.Form heirs) have much more complicated, because Wicket after form processing proceeds to the address specified in the attribute “action” tag forms onComponentTag method.

tag.put ( "action", Strings.replaceAll (urlFor (IFormSubmitListener.INTERFACE), "& amp;", "& amp;"));

When searching for possible expansion of the form 2 results form processing:
1. The form is filled out correctly and onSubmit () works;
2. The form contains errors (seen validators) and triggered onError ();
This article offers the following solution algorithm:

Easy Way:
In the first case, the onSubmit () method to set up the transmission to the correct page:

setResponsePage (YouPage.class, [parameters]);

If we set mounted (see. Above) page, the URL would be what is required.

But Wicket 1.3 Stateless form with this installation will not work because Wicket 1.3, as opposed to 1.2 in the method of class org.apache.wicket.RequestCycle

public final CharSequence urlFor (final Component component, final RequestListenerInterface listener)

following the appropriate forms condition

(Listener! = IRedirectListener.INTERFACE && component.isStateless () && page.isBookmarkable ())

and generates a URL in the action attribute of the form, using BookmarkableListenerInterfaceRequestTarget.

If the URL looks like this:

http://localhost:9090/wicket_res/app/pages/FormPage/wicket:interface/%3A0%3Aform%3A%3AIFormSubmitListener%3A%3A

With regard to the problem:
“But now Wicket does not retain the mount in the way we would like to dwell on this before, but have not found the time to add 1.4 rfe and we will see later,” -

http://www.nabble.com/Can-I-get-a-%27Nice-URL%27-when-form-validation-fails–tf4020865.html#a11420378

Note:
To make the page available to add to your favorites, it must have a designer YouPage (final PageParameters) apart from all others.
To form processed as Stateless, getStatelessHint method should return true.

In the second case, we can use onError () in shape. But FeedbackMessages will be lost at this. Because Starting with version 1.3, these messages are stored in the session (design available through Session.get (). getFeedbackMessages (). hasErrorMessageFor (component)), surely there must be a way to get them out and install it manually. So far, this method is not found.

It is hoped that in future versions Wicket developers add functionality eliminates the problem of unreadable URL-addresses.

The hard way:
By changing the implementation Application.newRequestCycleProcessor on can achieve the desired strategy (selling org.apache.wicket.request.IRequestCodingStrategy) much.

About:
“If you’re really set on this behavior, then, as I said, use the stateless-pages and forms; if does not work – connect its strategy of coding, but I absolutely can not imagine that you may require, and how easy it is to write “-

http://www.nabble.com/Can-I-get-a-%27Nice-URL%27-when-form-validation-fails–tf4020865.html#a11420378

An alternative method.
Just use AJAX instead of forms. The problem is the readability of URL-addresses will disappear by itself.

This entry was posted on Monday, August 27th, 2007 at 3:26 am and is filed under Wicket.

“Support for custom fields in HibernateChego better to avoid the development of architecture? “


Viewing all articles
Browse latest Browse all 28

Trending Articles