How to remove "Submit Query" during printing prime faces component - jsf

I must print some component from html page. I used from Prime Faces, but I have some problem.
Internet Explorer 11 add some text to printed images ("Submit Query").
Problem occur in h:commandButton which have empty value.
How I may resolve this problem??

You can achieve by using css background-image with image in order to present a background image.
<h:commandButton value=" " style="background-image: url(your-image.png)" />
If you do not want to have the appearance of a button, you can nest <h:graphicImage> inside
<h:commandLink> and instead.
<h:commandLink ...>
<h:graphicImage value="your-image.png" />
</h:commandLink>

Related

Context path generated twice when using #{resource} value expression within facelet page

I'm using the expression #{resource['library:file']} within a facelets page to generate an ajaxified button with an image within an RichFaces (4.2.2.Final) toolbar.
<h:form>
<rich:toolbar height="40px">
<rich:toolbarGroup>
<a4j:commandButton value="my label" image="#{resource['icons:icon32.gif']}"/>
</rich:toolbarGroup>
</rich:toolbar>
</h:form>
generates the following code for the a4j:commandButton where the context path is generated twice.
<input type="image" alt="my label"
src="/com.test.my.context/com.test.my.context/faces/javax.faces.resource/icon32.gif?ln=icons"
value="my label"
onclick="RichFaces.ajax("j_idt73:j_idt76",event,{"incId":"1"} );return false;"
name="j_idt73:j_idt76" id="j_idt73:j_idt76">
If I use <h:graphicImage library="icons" name="icon32.gif"/> within rich:toolbarGroup the generated URL is right.
Furthermore I've include the image by css using background: url(#{resource['library:file']}) which doesn't gives the result I've searched for, but it works!
Is the expression #{resource['library:file']} only allowed within css files?
Where is the problem within my code?
According to JIRA Issue RF-12523 it's fixed in 4.3.1.Final.

render of a4j commandButton doesnt work; page not rendering

when i click the button handler.toggleCreatingTheme() is called, but the outputPanel is not rendering. When i refresh the page(f5) the content of the panel is showed.
<a4j:commandButton styleClass="simple-submit-button"
action="#{handler.toggleCreatingTheme()}"
rendered="#{!handler.creatingTheme}"
value="txt"
immediate="true"
render="newThemeForm" oncomplete="initEditor()" status="statusWait" />
<a4j:outputPanel id="newThemeForm" ajaxRendered="true" rendered="#{handler.creatingTheme}">
this tags are both in a h:form tag, there is just that one h:form.
How do I let the page refreshing on his own, so rendering the panel at the moment when i click the button?
Embed newThemeForm within another a4j:outputPanel and render it instead of reRendering newThemeForm.This is because newThemeForm will not be in DOM when trying to render it as it's rendered attribute will still be false.
Like:
<a4j:outputPanel id="outerPanel>
<a4j:outputPanel id="newThemeForm" rendered="#{bean.booleanvalue}">
</a4j:outputPanel>
</a4j:outputPanel>
Render outerPanel and not the newThemeForm.
i have tried the way that AhamedMustafaM mentioned but it didnt work with me , so i searched and tried for a little while so finally i got to make it work with a workaround, here is how
<a4j:commandButton id="clear" value="Clear" action="#{handler.clearData}" immediate="true" >
<!-- dummy call just to make it work -->
<a4j:actionListener listener="#{ViewerController.test}"/>
<f:ajax render="dataGroupPanel"/>
</a4j:commandButton>

Length of h:outputLabel changes after RichFaces AJAX call

I have been trying to incorporate RichFaces into one of our more complicated pages to make it run a bit more smoothly via AJAX. Everything is working fine and it has solved a few problems I was having using regular form posts so I'd really like to keep it. The only problem in my way is that after pressing an a4j:commandButton most of my h:outputLabels are shortened by 3 pixels (these pixels were to the left of the text, which is unusual since the left padding, margin and border width are all 0px). This causes lots of my controls to shift slightly and looks very unprofessional. It looks to me like the re-rendering has done a more accurate job than the initial render. Here are the relevant parts of my page:
<a4j:form id="mainForm">
...
<fieldset id="illustrationDetails">
<h:outputLabel for="product" value="Product" />
<h:selectOneMenu id="product" value="#{illustrationManager.illustration.product}" valueChangeListener="#{illustrationManager.illustration.setProduct}" onchange="submit()">
<f:selectItems value="#{illustrationManager.illustration.products}" />
</h:selectOneMenu>
<h:outputLabel for="paymentFrequency" value="Payment" />
<h:selectOneMenu id="paymentFrequency" value="#{illustrationManager.illustration.paymentFrequency}">
<f:selectItems value="#{illustrationManager.illustration.paymentFrequencies}" />
</h:selectOneMenu>
<h:outputLabel for="expenseGroup" value="Expense Group" />
<h:selectOneMenu id="expenseGroup" value="#{illustrationManager.illustration.expenseGroupId}">
<f:selectItems value="#{illustrationManager.illustration.expenseGroups}" />
</h:selectOneMenu>
</fieldset>
...
<a4j:commandButton id="calculateButton" value="Calculate" action="#{illustrationManager.calculatePremium()}" ajaxSingle="true" reRender="mainForm" />
...
</a4j:form>
In the fieldset above, all but the first label exhibit this problem. The first label is rendered what I would consider to be correctly (with no pixels to the left) by the initial render and as a result is not changed by the re-render.
Any suggestions would be welcome! Also, if you want more info like the css for the relevant controls let me know and I'll post it.
Well, this is a partial answer anyway. The 3 pixels to the left of the h:outputLabels was due to the fact that the Mojarra JSF implementation adds a \n character to the beginning of the label tag body it creates. I'm as baffled as the guy who submitted this bug about it as to why this is done. The \n is converted to a space when displayed and that's what my 3 pixels were.
I do not know why, but the re-render triggered by my RichFaces AJAX call removes these \n characters and so the space is no longer displayed.
As a workaround, I have explicitly put spaces at the front of all my labels so that a space is always displayed. I'm surprised this is not a common problem.

JSF and links: the target property doesn't work?

I need to render a simple link in a page that open a pdf file in a new browser window.
I wrote the following tag:
<h:commandLink target="_blank"
action="showPDF"
title="Show attached PDF"
actionListener="#{bean.doShowPDF}"
value="Show PDF">
<f:attribute name="path" value="#{bean.pdfPath}" />
</h:commandLink>
The target attribute seems to be ignored. The destination page appear over the current.
I tried with h:outputLink:
<h:outputLink target="_blank"
title="Show attached PDF"
value="/visAttached.jspx">
<f:param name="path" value="#{bean.pdfPath}" />
Show PDF
</h:outputLink>
but with the same result. The generated html , in both cases, has not the target attribute.
Where's my fault?
There is a better strategy in JSF to show a file in a new browser window?
Try the ice: versions of them: ice:outputLink, or ice:commandLink. The component showcase shows a working example (layout panels/collapsible panels has a lot of links, check the source):
<ice:outputLink target="_blank" styleClass="navPnlClpsblLnks"
value="http://icefaces.org/main/home/index.jsp">
<ice:outputText id="icefacesOrgLink" value="ICEfaces.org"/>
</ice:outputLink>

Primefaces lightBox problem

I have created a page with primefaces where I use the Lightbox component.
I use it in a dynamic matter as I create tumbnails on the fly with a servlet call.
The first page shows up nice and the lightbox works as expected but when I load a new set of pictures for the next page the pictures are shown but when you click on it, it just shows the original picture in a new page, when I then return with the previous button and click on a a thumbnail it works as expected.
This is the jsf code:
<h:outputLabel id="curpage" value="#{pictureBean.currentPage}" />
<h:commandButton value="next" action="#{pictureBean.nextPage}" id="next">
<f:ajax render="lightBox curpage" />
</h:commandButton>
<br/>
<p:lightBox height="500px" id="lightBox">
<ui:repeat value="#{pictureBean.pictures}" var="pic">
<h:outputLink value="#{pic.url}" title="#{pic.description}">
<h:graphicImage value="#{pic.urlThumb}" style="width:100px;height:75px;"/>
</h:outputLink>
</ui:repeat>
</p:lightBox>
I fixed it myself :-) I was forgotten to add the tags between form tags.

Resources