Jsf form Print preview - java

I have a JSF form of view *.jspx page. The form has around 20 fields. I have a print preview button, that would open a new browser window and show print preview of this form, making all the form content as read only.
I have done a bit of workaround like setting a boolean flag in Managed bean as showprintPreview. This approach has almost done the job by showing all the fields in readonly and buttons as disabled mode.
But, I don't want to change the backing bean object.
I'd like to show the print preview with css or javascript for a jsf form.
UPDATE:
I have tried another way by using onclick on print preview button that would call predefined, window.print() js function. But its displaying all the buttons as well. I would like to hide buttons like submit, back etc in print preview and show all the input fields like text, textarea etc.

I would reuse part of page wich you want to print. Create new page only with this reusable part. then on button action open this new page in new window (target="_blank") in print preview you mentioned.

Related

Saving multiple pages simultaneously in htmlunit

I am currently working on creating functional tests using htmlunit.
On the webpage I am testing, there is an anchor which opens a page in a new tab when clicked. This anchor needs to be clicked to reveal additional check boxes and buttons.
If I wanted to save the page after clicking the anchor it would look something like this:
HtmlAnchor terms = tb.getFirstByXPath("//*[#id=\"terms_link\"]");
tb = terms.click();
However, the above code saves the webpage which is opened in the new tab as opposed to the web page in which the anchor was clicked.
Is there any way for me to save the page in which the anchor was clicked, or possibly save both html pages?
So after a bit of messing around I discovered that any actions which change the page are registered in the browser window regardless of whether or not you save them after an action.
In order to save the popup which occurs after clicking the an action just assign the resulting page to an HtmlPage object.
HtmlPage page = button.click
You can fetch the previous window and save it's modified contents with the following code. If you want to save the popup and the original page just save them to different object names.
page2 =(HtmlPage)(webClient.getWebWindows().get(0).getEnclosedPage());

JavaFX: how to disable drag and drop and pasting from external sources on WebView?

I am working on a chat application where I am using a webView to show the conversation between sender and receiver and another webView to write the message which will contain text and emoticons (the reason for using webView is that it is capable to show emoticons along text using html), the 2nd webView is editable by setting its contenteditable property to true in html, now the problem is that when I drag and drop text or copy text from somewhere which contains formatting, links and images it will be shown with all the formatting that is why I want to disable dragAndDrop and pasting text from external sources such as browsers, if the text contains links then by clicking that link it will direct you to that page and the webView will become a web browser.
Tricky (i think). One way to do it is by providing your own EventDispatcher instance and intercept the actions you want to prevent, e.g. intercepting the DragEvent to prevent drops and the key events for the paste action. The downsides to this approach are, of course:
1) You'd have to code platform specific for the paste shortcut (CTRL+V vs. META+V)
2) If you want to disable pasting via the context menu this way, you'd have to prevent it from appearing at all. However I think in your case that would be intended.
So, pending a better a better solution I'd go with the dispatcher. Determine which events you want to be processed and forward those to the dispatcher chain. Consume the events you want to prevent.

HTML gallery page in Swing with drag-drop functionality

I was asked to write a JDialog separated into left and right panel. The left panel shows a demo HTML template gallery (small sized), and right panel shows series or list of images. I want to make it such that I can drag image on the list and place it on the gallery (or maybe drag out some image from the gallery). The problem is I don't know where to start with this, can anybody give me some idea?
An HTML gallery typically uses JS to do the 'heavy lifting' (I'm guessing it will require a slideshow as well). While Swing components support HTML (to an extent) they do not support JS.
I recommend not trying to render the HTML/JS in the GUI, instead, provide a JList in the GUI of the image+name objects chosen by the user (using JFileChooser). When each image is selected, you can show the 'preferred name' in a JTextField that allows the user to edit it.
Image order can be shown by the order in the list. To change the order, implement Drag'n'Drop. See the Drag and Drop and Data Transfer lesson for more details.
You will probably need a JLabel in the CENTER of the GUI to display the (full size) selected image, and show the order & timing of the slideshow.
Once the user is happy with the image selections, the order, the names & timing. Offer them a button to write all the details to a single directory including the HTML, script & images (easier). Once the HTML is written, invoke Desktop.open(File) to display the finished product to the user.
As to how you do all that, it is really beyond the scope of an answer on SO. You would need to do the tutorial on each part, and come back with more specific questions.

JSF component doesn't update if changes came from grid click

I have a JSF/IceFaces application where there is a screen divided into 3 sections. Search fields, a grid and some details fields below. Currently if I enter some data into the search fields and click on a Search button (!) the grid shows the results and a certain method is called that puts the first result record's details into the backing beans of the details fields below the grid. This shows that there is no problem with the way I put data into the details fields.
However I have a gridclicklistener method as well that would like to change the detail fields according to the selection. After the click the same method gets called with the correct parameters that works well if invoked after the click on the Search button. The data is updated in the backing beans but the changes are not rendered even if I click the refresh button in the browser.
I found that if I click on the search button, the data-updating-method gets called from InvokeApplicationPhase.execute. When I get to this line after the grid click then it is from the ApplyRequestValuesPhase.
Do you have any ideas what could make this difference and how to get this work?
Update:
I can clearly see the updated value in the backing bean but it is not reflected on screen at all, even after F5.
I don't know what is causing your original problem.
With the icefaces push renderer however you could force an update:
http://wiki.icefaces.org/display/ICE/Getting+Started+with+ICEfaces+2#GettingStartedwithICEfaces2-icepush

Multiple actions on Form Submit

I have a .jsp page with 3 frames. The first frame contains a form which takes in a user ID. This form links to another .jsp which creates a token for the user and displays his information in the 2nd frame. The 3rd frame is supposed to take the token from the 2nd jsp which is passed to the 3rd jsp which returns an XML file of the user's access. How would I get the Submit button to open both of these frames? or should I have two separate buttons?
Take a look at this previous question it may be able to help. It focuses on using the onClick function within jQuery.
jqueryui frame dialog and multiple buttons

Categories

Resources