How to call wicket page from servlet - wicket

My application is mixed of wicket and jsp page . In my case i have to call wicket page from servlet with some value in request object . could someone please explain as how to achieve this. Thanks

What do you mean 'call a wicket page'? Do you mean load a wicket page to the user after he performs some action on the servlet-loaded page?
What exactly is your use case for this?
I think it would be better NOT to mix jsp and wicket, but given that you did:
BookmarkablePages provide a way to directly address a wicket page as it has a bookmarkable url (for instance, /home instead of /page?13). We use those to load a certain page with certain request parameters (ie, /student/1234/results shows the resultpage for student 1234).
Also, you could implement some kind of listener service that, based upon a certain call/payload, constructs a wicket page and returns the url for that page but that seems a bit overkill. In most cases I think bookmarkable pages a should suffice.
Have a look at http://wicket.apache.org/apidocs/1.5/org/apache/wicket/protocol/http/WebApplication.html#mountPage(java.lang.String, java.lang.Class)
or
http://wicketinaction.com/2011/07/wicket-1-5-mounting-pages/

Related

How to secure querystring/POST details to a third party

I'm basically looking at a security problem between a parent page and an iframe with links to a third party.
I want to send a POST or a GET (doesn't matter which as I can control the other side) to the third party, but not expose any details within it (say a SID or a user token) and have it's HTML content (JS/HTML/Images) loaded into the iframe.
I've looked at server-side redirects, creating a proxy using webclinet/webresponse and am curious to whether there is a good way to do it.
Has anyone ever done this before, or think that the secrity is not possible? Hell, even if I'm barking up the wrong tree on how to solve this.
If anybody has any examples on this it would be greatly appreciated.
Cheers,
Jamie
[Edit] Was thinking I might need to add some more details.
Say I have a parent page: https://mycompany.com/ShowThirdParty.
This has an iframe in it at the moment which will have the content of another component (also owned by me, or another team more specifically)
Basically I'd like to send some credentials to content in the iframe in such a way that the external pages can't read it, the iframe is put into a modal (I've done that) and the iframe has the restricted content with the auhtentication almost seamless and invisible.
I currently have it working as a GET url generated dynamically via JS and then passed into the iframe src parameter, obviously that isn't secure.
I kind of want some kind of server side redirect across a full url, but I don't even think that's possible.
You could try using AJAX and load a PHP script (with any parameters to the script encoded/encrypted) to query the 3rd party page and load the response into the iframe. Not really sure how your code is setup but there should be a way.
It can also be done by POST Method (submit the data to iFrame using POST) as it is HTTPS so the data you send to iFrame is encryped.

How to intercept error request and redirect to a custom page?

Here is one of the use-case as to what I want to do:
A User clicks on a blog-link or directly pastes the blog-link in the URL
The blog portlet is on the private-page of a Community (Site).
Since the user is not a member of the Community (Site) he would be taken to the error page.
He is shown, either a 404 page or a No-access error page.
My requirement starts: Now instead of showing the above pages or a customized version of the above pages.
I want to Intercept the request for 404 or other such requests.
And redirect to a portal page (not a static error page) based on some parameters of the User and the initial request parameters.
In this case I would want the user to be redirect to any public page of the same Community (Site) and ask him to Join or request membership for that Community (Site).
So in short I would want a way to intercept the request which generates the error and then redirect to where ever I want.
Is this available in liferay? If not can I get some idea as to how can I achieve this?
Environment: Liferay 6.1 GA2
Thanks for your valuable time.
Add a JSP page to manage 404 errors as described here in that Liferay's forum post.
In that JSP you can put your custom logic based on whatever param (the user, the community, etc..) that you can access from inside the JSP using, for example, the themeDisplay object.
An alternative way (and the way I have redirect 404 errors to a specific page in the community) is to override the 404.jsp with a Hook. Then add your custom logic to the overridden JSP.
I'm assuming something similar could be done for no-access.

check user availability in forms in jsp

I have a jsp form which takes in user details. On submit button it goes to a jsp page where the details are entered into the database. But before that I would like to check if the username is available as soon as the user clicks the check availability button. How can this be done?
2 ways:
Just redisplay the same page after submitting the form wherein you conditionally display the validation message. This is rather trivial and already covered in the Hello World example in our Servlets wiki page.
Use Ajax to send an asynchronous HTTP request and manipulate the HTML DOM based on the response of the request. This requires a bit more in depth understanding of how websites really work and what JavaScript is. You can find some concrete examples in How to use Servlets and Ajax?
Use AJAX(Asynchronous Javascript and Xml). Its the best web2.0 technology. You can manipulate DOM based on the answer from server

Include/mashup a dynamic wicket page in a static webpage

we have a "static", non-wicket CMS website and we want to include a dynamic wicket page/component in one of the static pages. Our idea was to use jQuery's load() method to load the content. And include wickets ajax js files in the header.
This worked more or less. But to make it work, the base-url of the page had to be redirected to the ajax endpoint of the wicket server.
Our latest and best solution is to include the page in an iFrame.
Is there any more elegant way to do this?
We have a similar thing, but we have made it by using the exact opposite of you. We include html fragment of the static content via Wicket and render our component inside.
I think, including (rich dynamic) Wicket content via ajax call, from static page, can break native Wicket power, action flow in statefull pages.
Opposite strategy (from cedric.gatay) seems better.

ASP Classic - Passing form data to Iframe

I'm looking to pass data from a form into an iFrame, but I have a slight problem.
The form page I can edit with no restrictions
The page I send the data to I cannot edit unless its html or JavaScript
The data needs to end up in an iframe within this page, which I can edit with no restrictions
I'm incorporating a search function into a CMS system which is why I cannot edit the iframe's parent page, and why I am using iframes at all.
At the moment the data sends to the parent page but is not picked up within the iframe, I am sending via the POST method.
I got it..
Added and extra page which converted the post data into session data,
if anyone knows a better way i would like to hear it though.
And they are the same domain, but editing the CMS system would have taken ages to look through as its not mainstream or developed by me.
Maybe I'm oversimplifying the problem, but can't you use the "target" attribute of the form tag to post to the Iframe?