Problem in Wicket - java

I have a page by name BranchMap that uses GoogleMap to show some building to user after he has logged in.
the data was at first in protected(password required) situation (in CategoiresXML which extends ProtectedPage) but i found that google can't log in the system and make the page extended from WebPage.
But now when I go to BranchMap page and Press CTRL+F5 the page expires and i refered to HomePage.
Does anyone know the reason? if you want more info tell me to put them.

Not entirely sure what you're describing - it's not quite clear, but see if this helps:
This can happen when some Ajax call causes the page to change, but refreshing the page (which isn't bookmarkable) who's urls refers to the expired version causes this exception. I had this problem at one point when we had multiple iframes calling into our wicket app (sorry for the fuzzy explanation - it was a while ago).
In the end, for our application, we had to split the different iframe sources into different servlets within web.xml - in order to completely isolate the sessions of the different pages - but that's another story.
Try adding this to your wicket application init method.
// debug code for fixing session issue (multiple ajax using pages inside
// one browser)
get().getPageSettings().setAutomaticMultiWindowSupport(true);
And check out the documentation here: https://ci.apache.org/projects/wicket/apidocs/1.4.x/org/apache/wicket/jmx/PageSettings.html#getAutomaticMultiWindowSupport()
Can you show the stack trace?
What version of Wicket are you using?
There was a bit of a miss-communication in the javadoc prior to 1.4-rc3 as well, patched here:
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/settings/IPageSettings.java?r1=647167&r2=768578&pathrev=768578&diff_format=h
The issue here: https://issues.apache.org/jira/browse/WICKET-2233
Here is the updated comment in the javadoc from IPageSettings:
/**
* Gets whether Wicket should try to support opening multiple windows for the same session
* transparently. If this is true - the default setting -, Wicket tries to detect whether a new
* window was opened by a user (e.g. in Internet Explorer by pressing ctrl+n or ctrl+click on a
* link), and if it detects that, it creates a new page map for that window on the fly. As a
* page map represents the 'history' of one window, each window will then have their own
* history. If two windows would share the same page map, the non-bookmarkable links on one
* window could refer to stale state after working a while in the other window.
* <p>
* <strong> Currently, Wicket trying to do this is a best effort that is not completely fail
* safe. When the client does not support cookies, support gets tricky and incomplete. See
* {#link WebPage}'s internals for the implementation. </strong>
* </p>
*
* #return Whether Wicket should try to support multiple windows transparently
*/
boolean getAutomaticMultiWindowSupport();

Related

Should we write separate page-object for pop-up with a selection drop-down?

I am new to Page-Object model automation using selenium and java. I am using the Page Object model and have each page as a single class and the actions in that page as methods.
Should we write separate page-object for a simple pop-up which appears when submitting a form. This pop up is used to select service types and based on the selection correct form will be opened next. I have 'page objects' for the pages before and after this pop up. But for this one I just inserted a direct code to select an option and click next button. Should I create a separate page-object class for this pop-up?(as this is not a Page). Pop-up has 3 options and a Next button to proceed.
Please read this Martin Follower's article - Page Object.
A quotation:
Despite the term "page" object, these objects shouldn't usually be
built for each page, but rather for the significant elements on a page
Imagine a page which has over of dozen tabs, panels etc, and each one have a few fields, buttons etc. It would be impractical to create a huge class for such a page, it would certainly have 300-500 or more lines of code. Such a class would be very hard to maintain.
It's better (in my opinion) to create several small classes (page objects), each for a specific section of the page, each one containing only a few elements, each no more than 50-100 lines of code. We call these classes page fragments instead of page objects, but the concept is the same.
But it will vary from person to person and everyone may have a different opinion on this topic.
I agree with Bill, however I handle my popups a bit differently. I have it as it's own page object within the same class if it is a page specific popup.
For instance, if you have a popup on your dashboard page that is page specific to the dashboard page but not found anywhere else in the web application, I make it it's own class within the dashboard page object.
The reason I do this is I find the tests far more readable when the specific areas of the application are "containerized" within their own objects. Then when you open the popup and do operations on it, they would look like "popup.SetValue" versus "dashboard.SetValue" or something similar to that. Doing it this way you know that you are doing operations on the popup versus testing the dashboard.
If the popups are widespread throughout your application and can be reused easiliy I would suggest making it into it's own Page Object.
There's not really a hard and fast rule. As others have stated, the page object doesn't have to be a page. It really should be any piece of reusable functionality such as a dialog or header or footer, etc. For automation that I have written, I decided to follow the rule that any dialog is a separate page object (actual separate file). I find that it helps me keep track of pages/dialogs, etc.
To further help with this, I name my classes *Page for pages (e.g. LoginPage.cs), *Dialog for dialogs (e.g. AddImageDialog.cs), *Panel for panels (e.g. HeaderPanel.cs), and so on.
If a dialog only exists on a particular page, I named it based on the base page name, e.g. ProductDetailsPage_AddImageDialog.cs. What that does is when I look at the list of files, they will sort in alphabetical order so all the page objects related to the product details page will sort together so I can quickly see how many page objects are associated with that page and what they are. Some examples are below. You can look through the list and quickly determine which page objects are associated with a particular page and which ones aren't.
HeaderPanel.cs
LoginDialog.cs
ProductDetailsPage.cs
ProductDetailsPage_AddImageDialog.cs
ProductDetailsPage_AddTextDialog.cs
ProductDetailsPage_SaveCompleteDialog.cs
ProductDetailsPage_SaveYourProjectDialog.cs
If a dialog occurs multiple times throughout the site (not associated with a single page), I name it as a standalone page object, e.g. LoginDialog.
I used to just name the page object after the dialog, panel, etc. but after you get 50 page objects, it's hard to remember where certain dialogs occur so I came up with the _ naming scheme and it has helped significantly.
I also considered creating the AddImageDialog page class inside of the ProductDetailsPage page class but when you get larger pages with lots of dialogs, it just makes the file bigger and bigger. I prefer to keep the file size as small as is reasonably possible while keeping all the important bits in there. Breaking the files down into pages and dialogs and having them separate maintains the page object model principles while keeping things cleaner... at least in my opinion.
If the pop-up has an ID locator, and is likely to happen on other web pages, I would put it in its own page object, but often the pop-up is tied directly to the current page and would therefore be better included in that page's object definition.
The only reason I would consider putting it in a separate page object is if it did get used in other pages AND used the same ID locator, as if and when that locator changed, you'd only have to edit the one page object instead of locating and fixing all other page objects that also refer to that pop-up.

GWT multiple Paging (Best / easiest way)

So far I've done some tests (e.g RPC)
Next I come to the Part Multiple Paging, in what I've read so far there are so many options for this:
MVP, Layout, UIbind.
Now I really don't know which I should choose, which is easy and good.
I tried clearing my Rootpanel and placing another Widget(composite):
RootPanel.get().clear();
Place:
LoginComp login = new LoginComp();
rootPanel.add(login, 127, 125);
I don't know if this is the most professional approach. What is the best way to include my widgets as composites?
First of all, GWT is a single page application. After you have requested the application, you'll only go to the server to recieve data.
I would use a struts or SpringMVC application for the logon and request the GWT application after a successfull login. Your GWT application should have a shell. This shell has an area where you can change your views. Changing a view is initiated via a place controller.
Take a look at the mobileWebApp example contained in the GWT SDK examples.
Also, you will find a good documentation here:
MVP and Places Documentation
In my oppinion, the best way is when you add a element in your main HTML file which acts like a content wrapper e.g.
<div id="content"></div>
Each of your page can be represented as extended Panel, simultaneously as a singleton. The page that should be display will be set into that wrapper:
RootPanel.get("content").set(pagePanelX);

Action class called twice from IE and not firefox

I have an application where an absolutely normal link (like below).. when clicked, calls the action class twice. And this behaviour happens only in IE. In Firefox, when i click on the same link, it calls the action class only once.
Load
This is an older application and im using Struts 1.3 and Tiles.
Any idea why this is happening and/or how it can be troubleshooted?
It could be that IE is preloading prefetching the link.
To verify this, log the time when the request is received. Load the page, wait ~10 seconds, and click the link. If the difference between the log entries is ~10 seconds, it's a prefetch.
The idea is the browser preloads links the user is likely to click, so the result can be server immediately form the browser cache.
HTML5 makes this explicit by defining rel="prefetch". This attribute and value can be set on a, area, and link tags.
Check your page for <link rel="prefetch" href="url" /> or <link rel="next" href="url" /> in the HEAD element. Also, check your A tags for rel attributed as well.
MicroSoft claims to officially support this in IE 11.
All of this is intended to make pages appear more responsive to the user. Where this can fall apart is when the page being retrieved is not cacheable. This will cause the page to be fetched again when the user clicks it. This can be improved by taking steps to make sure the result cacheable. Set appropriate cache headers. There is a Private cache control for content that is intended for a single recipient. It's only stored in private caches, typically the user's browser.
Additionally, your page may not be considered cacheable if it does not provide a Content-length header.

how to let servlet know which link has been accessed

I have a code here that opens a new window when i click the hyperlink.
Chapter 1<br/>
Chapter 2<br/>
How can we return a value to the servlet so that it knows which link has been accessed??
Ive made the pages for the two links i've made here. But i need the servlet to know which page has been accessed. Inside the servlet a function is calling a jexcel app. The return value is different for both pages. That is why i need a UNIQUE return value for each link.
The link visited state is stored in the browser, it is not a really good idea to rely on that! It will be gone after a cache clear for instance. You should maintain a DB of user activity, if you need this info on a user level.

View Expired issues on mojarra

I have a large richfaces tree and each element in the tree can be selected which loads the content via AJAX and edited which redirects you to a new page. This was working great until I had a particularly large document I was working on and saving no longer worked. You got redirected to the edit page which showed the right content, but trying to "save" any edits resulted in a ViewExpiredException.
I tried tweaking a lot of parameters and eventually arrived at two parameters that fixed it:
com.sun.faces.numberOfViewsInSession
com.sun.faces.numberOfLogicalViews
As far as I can see, the default for each is 15, I set them to a ridiculous 500 and the application works again. Unfortunately because I don't know where the problem is situated and it's a large application I can't show you any relevant code.
But the questions are: what exactly do these parameters do, what could cause me to bump into these exceptions and what are acceptable values?
UPDATE
I'm not entirely sure why the question got downvoted but if it is with regards to the supposed duplicate: I had found that post through google but the link it provides is dead. Except for the bog standard (and vague) definition of the parameters, there does not seem to be much information on them.
When server side state saving is used (which is default) than those two parameters can be used to configure maximum number of logical and actual views.
Logical view is top level view which is created on every GET request (for example when you open page in new browser window or tab, entering address in address bar of browser, iframes...). Each logical view can have some number of associated actual views. Actual views are created as user navigate through your pages with standard JSF mechanisms (for example if you navigate to page returned from action methods in commandButton). Both queues of views use LRU algorithm to decide when view will be removed, and maximum number of those queues are limited by values of these two parameters.
So, com.sun.faces.numberOfViewsInSession defines the maximum number of JSF views stored in the session for per logical view, and com.sun.faces.numberOfLogicalViews defines the maximum number of logical views to store per session.
According to information you provided a suspect that configuration of com.sun.faces.numberOfViewsInSession solved your problem, but you must further investigate why is created so many views.
Additional link:
What are the differences between Server and Client side state saving and what are the benefits/drawbacks of each?

Categories

Resources