I have a page hierarchy as shown below where everything starts with showing items in a primefaces datatable. For each item a <p:link> or <p:commandlink> is generated.
Click on an item's link should do a redirect to the editItem page with the item's id shown in the query string.
The edit page has a save and cancel button which should redirect back to the listItems page.
The edit page has also a list of subItems, which are shown the same way as in the itemList.
Click on a subItem's link should do a redirect to the editSubSubItem page with the item's id shown in the query string and click on save/cancel should redirect back to the origin editItem page.
Same behavior should be possible for the edit pages editSubItem, editSubSubItem, and so on... Means save/cancel should always redirect back one level in the hierarchy.
http://localhost:8080/myWebApp/listItems.xhtml
http://localhost:8080/myWebApp/editItem&id=123
-> save/cancel - back to listItems
http://localhost:8080/myWebApp/editSubItem&id=456
-> save/cancel - back to editItem&id=123
http://localhost:8080/myWebApp/editSubSubItem&id=789
-> save/cancel - back to editSubItem&id=456
Is there an easy way to achive this kind of hierarchical navigation?
I'am using Primefaces 6.0 and JSF-2.2 on Wildfly-10.0.0.Final
I fixed it by using a Stack<String> object in the SessionMap, where i push the current page url before redirect to another page and pop the origin page on close of the page.
Related
I have an Xpage that I want to put in a panel in the sidebar.
I only want the entry part to be in the panel, so I made a ccEntry Custom Control and I put it into an Xpage for the main app and into an Xpage that is for the widget and ONLY contains the ccEntry form.
When I run the widget in the sidebar and hit submit, the code in the submit (which says previous) goes to the entire page. I want to put something in the button to like if I am in a sidebar then do this else do this. So if I could grab the name of the Xpage in a field that would do, but I cannot figure out how to do this.
Try view.getPageName(). That will give you a string of the current XPage's name in the format "/somepage.xsp".
#Jesse's solution makes something nasty: the control gets tightly coupled to its surroundings. You have two options:
Redirect
Define custom control's parameter with page name or URL to redirect to. Your submit button then redirects to that URL (accessed by compositeData.param). Your pages define different parameter value.
Navigation (preferred)
Your submit button's last command is simple line of code:
return "submitted";
Your pages for app/sidebar define different navigation rule target for the same rule: "submitted".
I'm using Primfaces Layout component in my pages and I'm not using Redirection in navigation when user clicks on the Menu links.
i.e.,I'm NOT using faces-redirect?true and URL doesn't change when user navigates.
I want to display a Confirmation Dialog before user navigates away from current view, like
“Are you sure you want to navigate away from this page?”
So once user clicks on the OK then it should forward to other page or else it should stay in same page if user clicks on CANCEL.
One more constraint is I want this functionality for only few selected pages not all of them.
What is the best approach to deal with this problem?
Primefaces Version: 3.5
JSF Version: 2.1.13
All my ManagedBeans are in #ViewScoped
If you want to try solving this problem from javascript-side, either go with
window.onbeforeunload = function(e) {
return 'Dialog text here.';
};
and see the dialog independent from the link being clicked (see https://stackoverflow.com/a/12132076/1269441). or try adding
onclick="if (!confirm('Your dialog-text here')) {return false;}"
to a selection of links you would like to have the dialog shown.
I am a newbie with JSF. Currently I have the problem with keeping the state of data-table list pagination.
The problem is when a user edits a row of a list which is not in the first page of data-table, after completing his action, page navigation returns to the first initial page of the list while we need to return to the previous page that user has been editing.
A complete Scenario:
In the list page there are 100 rows of records, and each page shows 20 rows,
User navigates to the 3th page, and selects one of the rows in order to edit the record.
Backing ListBean calls the EditBean that navigate the page to edit page.
User update the record information and backing Editbean calls back the ListBean.
ListBean refresh the Datamodel and navigate back to the list page, but the state of the pagination that user initially had edited is lost.
What is the best approach to return back the page to the previous page that user has been editing?
Myface 1.2.7 and Tomahawk taglib 1.0 has been used in the project. Pages consist of t:dataTable.
Thanks.
I have two web parts in my sharepoint aspx web page. One is Content editor web part and the other is data form web part.
In data form web part, I have a data view and I need to pass a parameter "id" to this dataview which will show the project details in the data view. I tried to use a value from a control as a parameter and never had a success. I did googled a lot last few days and haven't found any solution. It would be great, if someone show me a way to use the text from a control (may be a text box or select control). if someone have a working sample, please share. Alternatively I have used a query string as a parameter (eventhough I prefer to use text from a control). We need to pass a query string called id. For example, I am navigating to http://localhost/pages/1.aspx?id=7. This will show the project details of project id 7 in data form web part. this works fine.
I need to provide an option to user to enter the project id instead of modifying the query string in url. To achieve that I used content editor web part and I have a text box text1 and a submit button (html controls). The user will enter project id in the text box provided and will click the submit button to view the project details in dataview. The submit button javascript code has the following code:
url = 'http://localhost/pages/1.aspx?id=7';
alert (url); //alerts as http://localhost/pages/1.aspx?id=7
window.location = url;
For testing purpose, I just hardcoded the url. However, clicking the submit button is not redirecting to http://localhost/pages/1.aspx?id=7 or something happens during redirect. The page just reloads once. i.e., if I am in http://localhost/pages/1.aspx?id=12 and clicking the submit button reloads the page http://localhost/pages/1.aspx?id=12 instead of navigating to http://localhost/pages/1.aspx?id=7.
Without data form web part, the redirect works fine. Kindly help.
Thank you
I have a website having frames. Clicking on button in one frame updates the pages to be loaded in other frames. Now when user press the back button few of the frames load previous pages. i want user not to move back to previous page.
I used the code history.forward() on onload event of all my pages.
This works fine when back is pressed. User got navigated to most recent page always.
But the case is suppose user navigate to number of pages by clicking on button in first frame which updates the pages to be loaded in other frames. After navigation user select a page from the list of browsing history, then it is move forward to only one page, not the last page he was viewing.
This Happens in IE.
In firefox it works fine. User can select any page from the browsing history, he is relocated to most recent page
My opinion is, you should review your concept, because you want to "reconfigure" the browser's navigation buttons. Disabling browser features is in my eyes old fashioned.
I used the code history.forward() on onload event
Try following this way:
In the head section, insert the javascript:
var historySize = history.length;
Then replace in onload event: history.forward() by history.go(historySize - 1). A positive value means move forward to a particular position in browser's history object (array).
I cannot guarantee that it will work, but it is worth to try out.
write this code between script tags
history.pushState(null, null, location.href);
window.onpopstate = function () {
history.go(1);
};