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?
Related
I'm currently working on a client-server project where the client sends a request to the server and the server runs a database statement based on the information from the client. As there's no static length for the output I add all the data to a ArrayList<String> and send it back to the client.
The data that the client requests has a certain hierarchy so that one could also display it using an XML file (however the output to a GUI is wanted here instead of file creation). There's several ways of displaying I came up with. One would be using a simple text area, however using this, I need to do applying the layout myself and the option of folding where I can expand and collapse certain items is not possible.
Another possibility of course would be using a simple JList, however I read on Stackoverflow that using a JList to display hierarchical things is way easier done using a JTree.
When I decided trying to implement JTree I also found the Genealogy.java file provided by Oracle in their documentation of JTree. As to be seen in the first examples of this documentation there is always a filestructure being displayed and hence also a filestructure kind of representation (using folder- and file-symbols) is shown. In contrast to this Genealogy.java only shows the names of the persons so I tried to adapt the implementation from Genealogy.java to my case however I'm completely clueless of how to do this as I don't even know where these symbols come from and where I could possibly disable them and also don't really get what some of the methods I need to implement do.
As I'm currently really clueless of how to possibly accomplish that I really need some detailed help (only telling me to come up with my own implementation of JTree or TreeNode doesn't really help me at this point). Is there any simpler way or is the need to implement any of the before mentioned interfaces inevitable and if so, how would it be done?
EDIT:
This is how it currently would be displayed (example taken from the Oracle documentation, showing folder- and file-symbols in front of the string):
And this is how I want it to be displayed (also from the documentation, this time only displaying a string as node):
The answer almost certainly will be found via the (icon of the) TreeCellRenderer used for the tree nodes. See the File Browser GUI for tips. It shows how to set the icons in the FileTreeCellRenderer. Admittedly the point here is almost exactly opposite what it was there, but it still comes down to the same thing - the icons.
The section of the tutorial that covers it is How to Use Trees: Customizing a Tree's Display.
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.
This question already has answers here:
Design Patterns web based applications [closed]
(5 answers)
Closed 6 years ago.
EDIT: I have posted a somewhat shorter and revised question here: Java web development: transfer control from one servlet to another while passing the request object (Version 2)
As more or less a beginner at Java web development, I’m unsure about how I should structure the flow between servlets/pages when a form is submitted (POST). It’s an elementary issue, I suspect this may be an easy question to answer for the experts. (Still, my book and some googling didn’t deliver a clear answer.) My question is a bit long, and that's because I want to make it clear where I'm coming from. Thanks for you patience.
Let’s say we have two servlets A en B, with each having its ‘own’ .jsp-page; let’s call those pages a.jsp and b.jsp respectively. Now as long as there are no forms on either page (i.e., no POST method used), it’s clear how things should go. That is, before any .jsp-page is shown, the corresponding servlet is activated, doing some preparation for the .jsp-page by setting the relevant data elements (most notably, as attributes of the request object) that the .jsp-page needs, then forwarding the request object (etc.) to the .jsp-page, which then actually displays the page with the data. So for example, a link on page a.jsp may link to the servlet B, and on clicking that link a GET-request for servlet B is triggered, which then does some preparation (setting some request attributes), before forwarding to its ‘own’ .jsp-page (i.e. b.jsp).
But now let’s assume that page a.jsp displays a form with a submit button, method=”POST” and action=”B”. Then yes, servlet B is activated, and this servlet has to determine whether the data entered by the user is valid. If the data is in fact valid, we can simply forward to b.jsp, no problem there. But what if the data is NOT valid?
In that case, we obviously want to show a.jsp (the form page) again, with the data that the user entered the first time still present. One way to achieve this, is to simply have servlet B forward to a.jsp (thus bypassing servlet A). However, there is a big problem with that: the URL shown to the user, in the address bar, will still read “……/B”. So the user will see the correct page (i.e., a.jsp, containing the form), but with the wrong URL (/B). So for example, if we take “Register” and “ThanksForRegistering” instead of “A” and “B”, the user will see register.jsp – but with URL “……/ThanksForRegistering”! Not good.
And calling ‘include()’ instead of ‘forward()’ on the request-dispatcher doesn’t seem to work either. If we do that, not only does it result in a GET-request (as opposed to the POST-request we want), but we actually lose the whole (original) request-object with its attributes (which we need, after all, to re-populate the form). At least, that’s what my own experimentation seems to show. So using ‘include()’ doesn’t seem like a viable option at all.
Another obvious idea is to have "action=A" (instead of "action=B") for the submit. Then the servlet A itself can handle the validation, and if validation fails it can simply forward to a.jsp again, no problem. BUT then what if validation succeeds? Then we want to show the follow-up page b.jsp, but that page may well need the attributes from the original request-object (from the form-submit) again; for example, to have the user check that his entered data was in fact all correct. So basically we have the same problem as before, but with the roles of A and B (and their respective .jsp-pages) reversed. So this doesn't seem like a real solution either.
And I don’t see any other alternatives.
So basically, I’d simply like to be able have one servlet give control back to another servlet, but with the request object being passed from the former to the latter servlet. Or, if that’s not possible, I’d want to be able to forward from servlet B to a.jsp directly, but with the correct URL shown to the user. Or any other way to accomplish what I want.
Many thanks.
I think that the assumption that there has to be one page per servlet is causing the problem here....have one servlet which based on input redirects,forwards or includes a particular page....you dont really need to always invoke a different servlet for a page.....you can have a single front controller with a view resolver the combination of which will redirect or forward to a page.
You can use filters to achieve the same thing or think of setting attributes in HttpSession if validation is successful and retrieve the data in all the pages whenever it is required.
session.setAttribute("object", object);
I hope this is what you are looking for.
I don't know if "cutting" is the right term...
I've got to finish doing a large and complex report based on an Applet legacy system, a fellow and I decided trying reuse all the logic in the applet to avoid the complexity of doing a lot of sub-reports. What we did was copy all the logic in the applet that include a lot of condictionals/SQL and make a huge and properly formated String, so that in our Jasper file it would just have a method called "myVo.getBody()" besides the header and footer stuff.
Unfortunately we found out a problem that some part of text get lost between pages. I think that as the text get bigger and reach Jasper page limit for some reason it keeps being writed in a "no visible area" and when the next page content starts some part was lost.
For example, there is a list of 19 items and what happens is:
End of 2nd page
1 - item
2 - item
beggining of 3rd page
18th - item
19th - item
Items from 3 to 17 are not being showed.
Is there any Jasper configuration for this situation?
We tried:
Position type: Fix Relative to the Top and Float
Stretch Type: Relative to the Tallers Object and Relative to Band Height
Stretch With Overflot: true or false
I don't think showing Java code would be useful as it just use a StringBuffer to build the String, put it on body property in a PreparedDocumentVO so that Jasper model can consumes it. It seems to be some Jasper setting, or the idea of creating a huge String is not so good as we thought.
I would consider breaking the result up.
Jasper formats information based on a relative page size. This means that at some point in time, when dealing with information that is not likely to fit on a page, Jasper will probably make an assumption that doesn't hold (and your data will likely not be formatted into the page).
If you have an exceptionally long string, consider splitting it up. Besides, people scroll web pages down, not the side, so a heavy side-scrolling document is likely to cause user issues unless every record scrolls to the side just as heavily.
There is this site wich in the address bar only shows like "http://example.com/examplepage.aspx".
Normally if it would have parameters behind it you probably could just copy that one.
But since it doesn't, how do i bookmark this page.
It doesn't necessarily have to be a bookmark, but at least an easy way to access the page.
(fyi I know basic HTML and Java, maybe it's only possible programmatically).
thnx
Generally dynamic pages (taking in context with the question) are not book mark friendly.
You could probably sniff the incoming request, and create a fake form which you can then submit later.
However there may be situations where there are parameters such as session id which are valid for only small periods of time.
You should read up on sessions. In really simple terms, a session is assigned to users accessing a website. They have an expiry period. IF you stay idle beyond set time (determined by the developer) you will not be able to get in. And every time you log back in, you may be assign a new session.
You would have noticed, that some websites automatically log you in, this is mostly done with the help of cookies. Cookies work in tandem with sessions, they store very basic information, so the next time you come back to a website, it will be able to identify you as a returning user and provide you with access.
Then again, some pages don't use sessions, they might have their own custom way of identifying users.
Bookmarks can be used in dynamic pages, if the code allows you to send GET requests, if they don't have any other extra parameters which will block you.
To Summarize:
Dynamic page not very bookmark friendly.
There may be parameters used to access a webpage which change constantly, which you cannot really save.
You may be able to get into dynamic pages using bookmarks, if they don't use any of the dynamically changing parameters.
Since you know Java, you should probably read up on JSPs/servlets to get an understanding of what happens behind the scenes in dynamic pages.
Hope this answers your questions.