positionning a command button on the right - css

I'm using jsf2.2 primefaces 6.0 and i already implemented a graphical solution to view, download and print pictures through galleria component of primefaces.
The issue is that I need help positioning the print commandButton on the right for best ergonomic result.
Here's the wanted result:
Here the XHTML code:
<p:dialog header="Documents numérisés" widgetVar="diag" modal="true"
dynamic="true" showEffect="fade" hideEffect="fade" resizable="true"
position="center" id="diagImages" onShow="download()">
<p:outputPanel id="gal" style="text-align:center;">
<p:galleria value="#{demandeBean.demandeSelectionnee.images}"
panelWidth="500" panelHeight="313" showCaption="false"
autoPlay="false" var="image">
<p:graphicImage id="image"
value="http://localhost:18080/openCars/images/#{image}"
width="500" height="313" />
</p:galleria>
</p:outputPanel>
<p:commandButton value="Print" type="button" icon="ui-icon-print"
style="display:block;margin-bottom: 20px">
<p:printer target="image" />
</p:commandButton>
</p:dialog>

Well, this may not be a perfect solution but it worked for me.
<p:panelGrid>
<p:commandButton value="Print" type="button" icon="ui-icon-print"
style="float:right;">
<p:printer target="image" />
</p:commandButton>
<p:panelGrid>

Related

how to make richfaces popup the popuppanel upwards

The link contains an example of richfaces 4 popuppanel:
richfaces popuppanel example
Here is the code:
<rich:toolbar height="26px" id="tb">
<rich:toolbarGroup location="right">
<h:outputLink value="#">
<rich:componentControl event="click" operation="show" target="ls">
<a4j:param name="event" value="event" noEscape="true" />
<rich:hashParam>
<a4j:param noEscape="true" name="top"
value="jQuery(#{rich:element('tb')}).offset().top + jQuery(#{rich:element('tb')}).height()" />
<a4j:param noEscape="true" name="left"
value="jQuery(#{rich:element('tb')}).offset().left + jQuery(#{rich:element('tb')}).width() - p_width" />
</rich:hashParam>
</rich:componentControl>
Search
</h:outputLink>
</rich:toolbarGroup>
</rich:toolbar>
<rich:popupPanel header="Enter Search Terms" id="ls" autosized="true" modal="false" moveable="false" resizeable="false" followByScroll="false" >
<h:panelGrid columns="3">
<h:outputText value="Search:" />
<h:inputText />
<h:outputLink onclick="#{rich:component('ls')}.hide(event); return false;" value="#">Search
</h:outputLink>
</h:panelGrid>
</rich:popupPanel>
<h:outputScript type="text/javascript" target="body">
p_width = #{rich:component('ls')}.width();
</h:outputScript>
But the popup is appearing in random places, i.e. sometimes under the bar, and then have to scroll and sometimes above. Is it possible to make sure it always appears right above the bar while being attached to it?
The top and left parameters set the position of the panel, change them to where you want the panel to be, or call the method directly:
RichFaces.component('panelId').show(null, {top: "800px", left: "500px"})
You're using the part of the example that specifically sets the panel under the bar so it shouldn't be surprising when the panel appears there.

Same space between 2 inputText boxes using JSF and CSS

I want to create a JSF form where users can write their name and surname and validate them using JSF validators. The problem is that I would like to set the same space between the 2 inputText boxes in the form, in both cases, when the typed data is correct according to the validator, and when it is not correct. So if between the 2 inputText boxes there are X pixels if the user has not typed anything, when typed name is not correct, the error showing message should be displayed between the 2 inputText boxes and the pixels between them should be also X px. I suppose this is a CSS issue, but I am unable to get it, so any help would be appreciated.
Here is my code
<h:form>
<p:panel id="panelregister">
<h:panelGrid columns="1">
<!--Name-->
<p:inputText id="name" label="name" size="32" maxlength="9"
value="#{mManagedBean.name}">
<f:validator validatorId="packagevalidators.NameValidator"/>
</p:inputText>
<p:watermark for="name" value="Name (*)" />
<p:message for="name"/>
<!--Surname-->
<p:inputText id="surname" label="surname" required="true" size="32" maxlength="9"
value="#{mManagedBean.surname}"
requiredMessage="Must enter a surname">
<f:validator validatorId="packagevalidators.SurnameValidator"/>
</p:inputText>
<p:watermark for="surname" value="Surname (*)" />
<p:message for="surname" />
<p:commandButton value="Submit" action="#{mManagedBean.save}" ajax="false" />
</h:panelGrid>
</p:panel>
</h:form>
You are using h:panelGrid which renders as HTML <table>.
p:message will be rendered as div and by default that div won't have any content so it won't take any space you provide.
One way to do this is to use a h:panelGroup around it and give pre defined height of p:message
Example:
<h:panelGroup layout="block" style="height:27px">
<p:message for="name" />
</h:panelGroup>

Scrollbar for outputLabel

I want to implment a scrollbar for a outputLabel but if i use scrollbar component it put every list elment in a new row. The whole output should be disyplayed in one row and the list should be scrollable. Can i fix this problem with a CSS attribute?
i use primefaces 4.0 and jsf 2.1
here is my code
<p:commandButton id="newMessage" update=":contentForm"
actionListener="#{taskboxBean.newMessage}" value="New Message" />
<p:commandButton id="trash"
update=":contentForm, :postForm:tabViewPosts:trashTable, :postForm:tabViewPosts:inboxTable, :postForm:tabViewPosts:sentTable"
actionListener="#{taskboxBean.deleteSelectedTaskbox}" icon="ui-icon-trash" title="Trash" />
<p:scrollPanel>
<ui:repeat var="task_to_user" value="#{taskboxBean.selectedTaskbox.TASKBOX_TO_USERS}">
<p:outputLabel
value="#{task_to_user.USER.EMAIL} #{task_to_user.USER.FIRST_NAME} #{task_to_user.USER.LAST_NAME} #{task_to_user.USER.FIRST_NAME}" />
</ui:repeat>
</p:scrollPanel>
<h:outputText value="#{taskboxBean.selectedTaskbox.TASKTYPE.NAME} " />
<h:outputText value="#{taskboxBean.selectedTaskbox.CREATE_TIMESTAMP} " />

Get src value from bean class in iframe (Dialog not being updated)

My code is below:
<p:commandButton value="test" action="#{myProgram1.test1}" oncomplete="ex2.show()"/>
<p:dialog id="dialog2" widgetVar="ex2" onShow="jQuery('#someId').show();">
<iframe frameborder="0" align="left"
src="#{myProgram1.url}"
name="someName" id="someId" scrolling="auto" width="750"
height="500">
</iframe>
</p:dialog>
I have set the value of url in test1 method. But it's not loading the url from bean class. But if I specify particular url then it is opening.
Add update="dialog2" to your <p:commandButton
So it will look like this :
<p:commandButton value="test" update="dialog2"
action="#{myProgram1.test1}" oncomplete="ex2.show()"/>

How to replace h:commandButton with a div

I want to replace all kind of buttons on my page with div as bellow:
<div class="button">
<div class="button_left"></div>
<div class="button_center">save</div>
<div class="button_right"></div>
</div>
I replace components onto h:commandLink and it work with most of them,
except those like this:
<h:form>
<h:commandButton value="do it" action="#{myBean.myFirstAction()}" />
<h:commandButton value="do that" action="#{myBean.mySecondAction()}" />
</h:form>
How to deal with it?
[edit]: a4j:commandButton is an example of component that work fine. The difference between those component is that h:commandButton ganerate input type="submit" and the rest generate input type="button".

Resources