I would like to align all the input fields. I used JSF panelGrid. See in the attached image, when the last 3 fields are aligned correctly, but the first one moved slightly left. I did all possible attempts I could, but failed to align the first input field. Please, help me out.
JSF Problem marked image
My Code:
<h:form id="MF">
<%--Form container Start--%>
<div align="center" class="form-align">
<div align="left" class="block-align use-border" style="width:80%">
<div align="left" class="block-align" style="width:100%">
<h:panelGrid columns="2" frame="none" cellspacing="2" cellpadding="2">
<h:column>
<h:outputText id="lbl1" styleClass="lbltxt" value="#{---}" style="width:200px;" />
</h:column>
<h:column>
<h:panelGrid columns="2" frame="none" cellspacing="2" cellpadding="2">
<h:column>
<h:inputText id="txt1" value="#{---}" styleClass="inputfld" size="10" maxlength="6" onfocus="gotFocusEvents(this)" onkeydown="keyDownEvents(this)" onkeypress="keyPressEvents(this)" onkeyup="keyUpEvents(this)"/>
</h:column>
<h:column>
<h:outputLabel id="outlbl1" for="txt1" styleClass="lbltxt" />
</h:column>
</h:panelGrid>
</h:column>
</h:panelGrid>
</div>
</div>
<br>
<%---------------------------------------------------------------------------------------------------------%>
<div align="left" class="block-align use-border" style="width:80%">
<div align="left" class="block-align" style="width:100%">
<h:panelGrid columns="2" frame="none" cellspacing="2" cellpadding="2">
<h:column>
<h:outputText id="lbl2" value="#{---}" styleClass="lbltxt" style="width:200px;" />
</h:column>
<h:column>
<h:inputText id="txt2" value="#{---}" styleClass="inputfld" size="10" readonly="true"/>
</h:column>
<h:column>
<h:outputText style="text-align:left;" id="lbl3" styleClass="lbltxt" value="#{---}" />
</h:column>
<h:column>
<h:inputTextarea id="txt3" value="#{---}"
styleClass="inputfld" rows="10" cols="65"
onfocus="gotFocusEvents(this)" onkeydown="keyDownEvents(this)" onkeypress="keyPressEvents(this)">
</h:inputTextarea>
</h:column>
<h:column>
<h:outputText id="lbl4" value="#{---}" styleClass="lbltxt" style="width:200px;" />
</h:column>
<h:column>
<h:inputTextarea id="txt4" value="#{---}"
styleClass="inputfld" rows="10" cols="65"
onfocus="gotFocusEvents(this)" onkeydown="keyDownEvents(this)" onkeypress="keyPressEvents(this)">
</h:inputTextarea>
</h:column>
</h:panelGrid>
</div>
</div>
<%--Non Container End--%>
</div>
</h:form>
My guess is your labels exeed the width of 200px in the lower table.
You should add another styleclass to all labels (h:outputText) defining the width and also the min-width. set the value as big as the widest label in your tables you want to align.
You should also avoid styling elements directly, if possible, to save yourself and others working on this code from unnessesary messy and inconsistent style.
Related
I am using primefaces calendar in my project and i placed p:spinner
under calendar component.When ever i click the calendar component it
will pop up and shows date that time P:spinner component also appears
inside the calendar.
i am using primefaces 5.1 version.
This is the Calendar and p:spinner source code,
<h:panelGrid columns="3">
<p:calendar id="locoutPeriodStartDateCalendarId"
yearRange="c-70:" showButtonPanel="true"
mindate="#{User.accountValidityStartDate}"
value="#{User.lockoutPeriodStartDate}"
pattern="dd/MM/yyyy HH:mm" navigator="true"
showOn="button" mode="popup">
<p:ajax update="panelId"/>
</p:calendar>
<h:outputLabel value="TO:" />
<p:calendar id="lockoutPeriodEndDateCalendarId"
value="#{User.lockoutPeriodEndDate}"
mindate="#{User.accountValidityStartDate}"
pattern="dd/MM/yyyy HH:mm"
yearRange="c-70:"
showButtonPanel="true"
showOn="button"
navigator="true"
mode="popup">
<p:ajax update="panelId"/>
</p:calendar>
</h:panelGrid>
spinner,
<h:outputLabel value="workHoursLabel:"/>
<h:panelGrid columns="4">
<h:panelGrid columns="3">
<p:spinner id="workingHourStartField"
value="#{User.workingHourStartHour}"
max="23"
min="0"
size="2"
disabled="#{User.fieldsDisabled}" />
<p:spinner id="workingHourStartMinute"
value="#{User.workingHourStartMinute}"
max="59"
min="0"
size="2"
disabled="#{User.fieldsDisabled}"/>
<p:spinner id="workingHourStartSecond"
value="#{User.workingHourStartSecond}"
max="59"
min="0"
size="2"
disabled="#{User.fieldsDisabled}"/>
<h:outputText value="(HH)" />
<h:outputText value="(MM)" >
<h:outputText value="(SS)" />
</h:panelGrid>
<h:outputLabel value="To:"/>
<h:panelGrid columns="3">
<p:spinner id="workingHourEndHour"
value="#{User.workingHourEndHour}"
max="23" min="0" size="2"
disabled="#{User.fieldsDisabled}"/>
<p:spinner id="workingHourEndMinute"
value="#{User.workingHourEndMinute}"
max="59"
min="0"
size="2"
disabled="#{User.fieldsDisabled}"/>
<p:spinner id="workingHourEndSecond"
value="#{User.workingHourEndSecond}"
max="59"
min='0'
size="2"
disabled="#{User.fieldsDisabled}"/>
<h:outputText value="(HH)"/>
<h:outputText value="(MM)"/>
<h:outputText value="(SS)"/>
</h:panelGrid>
<p:commandLink id="clearButtonId"
styleClass="ui-icon ui-icon-closethick"
action="#{User.clearWorkHourAction}"
disabled="#{User.fieldsDisabled}"
update="panelId"
title="Click to clear">
</p:commandLink>
</h:panelGrid>
The following image will show the issue.
after click calendar it will look like this,
Please help me how to fix this problem.Thanks in advance.
My problem is kinda tricky, I hope u get my explanation, I'll be as clear as I can with this.
I have a DataTable that displays a button to see the activities related with the selected item. this opens a little panel with a menu, that at the moment has only one option. This opens yet another panel with 2 forms, in with I do what I need to.
My problem comes when I use the update parameters to add the info I need into the DB.
this is the code for the button I'm using.
<p:commandLink action="#{reporteConsultorBean.verActividades(lead)}" update=":formMain:panelViewNotas" title="Ver actividades asociadas al Expediente">
<center>
<p:graphicImage value="/images/actividad32.png" />
</center>
</p:commandLink>
this is the dialog that pops out once you clicked the button.
<p:dialog id="idDialogActitividades" header="Actividades del Expediente"
widgetVar="dialogActividades" resizable="true"
showEffect="slide" hideEffect="fade">
<center>
<p:panel header="Actividades del Expediente" >
<p:panelGrid columns="1">
<p:commandLink title="Notas" onclick="dialogNotaView.show(); return false;" style="margin:0 auto">
<center>
<p:graphicImage value="/images/nota.png"/>
</center>
</p:commandLink>
</p:panelGrid>
<br/>
<p:panelGrid columns="1" >
<p:commandLink title="Cerrar" onclick="dialogActividades.hide(); return false;" style="margin:0 auto">
<p:graphicImage value="/images/cerrarBoton.png"/>
</p:commandLink>
</p:panelGrid>
</p:panel>
<br />
</center>
</p:dialog>
and this is the form in which you save the data to de DB.
<p:dialog header="Notas del Expediente" width="950"
widgetVar="dialogNotaView" resizable="true" minWidth="950"
showEffect="slide" hideEffect="fade">
<p:panelGrid columns="2" width="930">
<p:panelGrid columns="1" width="75">
<p:commandLink title="Notas" onclick="return false;" style="margin:0 auto">
<center>
<p:graphicImage value="/images/nota.png"/>
</center>
</p:commandLink>
</p:panelGrid>
<p:panel id="panelViewNotas" header="Notas del Expediente" width="830">
<center>
<h:form id="formNotas">
<p:messages id="messagesNotas" showDetail="true" autoUpdate="true" />
<p:panelGrid id="panelTabNotas" columns="2" width="800">
<f:facet name="header">
Nota
</f:facet>
<p:graphicImage value="/images/nota.png" />
<h:outputText value="Nota" />
<h:outputText value="" />
<h:outputText value="" />
<h:outputText value="Nombre/Tema *" />
<p:inputText value="#{reporteConsultorBean.notaView.nombre}" required="false" requiredMessage="Es necesario que ingrese el asunto"
size="50" maxlength="49" />
<h:outputText value="Descripción *" />
<p:inputTextarea value="#{reporteConsultorBean.notaView.descripcion}" rows="4" cols="65" maxlength="270"
required="false" requiredMessage="Es necesario que ingrese la descripción de la nota." />
</p:panelGrid>
<br/>
<p:panelGrid columns="2" >
<p:commandLink actionListener="#{reporteConsultorBean.saveNota}"
update=":formMain:growl,:formMain:formNotasResult:panelResultadoNotas,:formMain:formNotas:panelTabNotas,:formMain:formNotas:messagesNotas" title="Guardar Nota" style="margin:0 auto" >
<center>
<p:graphicImage value="/images/guardarBoton.png"/>
</center>
</p:commandLink>
<p:commandLink title="Cerrar" onclick="dialogNotaView.hide(); return false;" style="margin:0 auto">
<center>
<p:graphicImage value="/images/cerrarBoton.png"/>
</center>
</p:commandLink>
</p:panelGrid>
</h:form>
<br/>
<p:separator style="width:700px;height:10px" />
<br/>
<h:form id="formNotasResult">
<p:panel id="panelResultadoNotas" header="Notas del Expediente" width="830">
<p:dataTable id="tablaNotasResumen" var="notaResumen"
value="#{reporteConsultorBean.notasExp}" rowKey="#{notaResumen.idNota}"
paginator="true" rows="4" emptyMessage="No hay registros"
selectionMode="single" selection="#{reporteConsultorBean.notaSelected}">
<p:column headerText="Nombre/Asunto">
#{notaResumen.nombre}
</p:column>
<p:column headerText="Descripción"> #{notaResumen.descripcion}
</p:column>
<p:column headerText="Creador">
#{notaResumen.actividad.creador}
</p:column>
<p:column headerText="Fecha Creación">
<h:outputText value="#{notaResumen.actividad.fechaCreacion}">
<f:convertDateTime type="date" pattern="dd-MM-yyyy"/>
</h:outputText>
</p:column>
<p:column>
<p:commandLink title="Editar Nota"
update=":formMain:formNotas:panelTabNotas"
action="#{reporteConsultorBean.editarNota(notaResumen)}">
<p:graphicImage value="/images/editarBoton.png" />
</p:commandLink>
</p:column>
</p:dataTable>
</p:panel>
</h:form>
</center>
<br/>
</p:panel>
my problem comes when I use "panelViewNotas" in the button above. When I use it everything is displayed as it should, but when I hit the "Save" button on the last form, nothing happens (not even a nullPointerException in the Log or Tomcat).
and when I use:
update=":formMain:formNotasResult:panelResultadoNotas,:formMain:formNotas:panelTabNotas"
the data gets stored in the DB with no problem, but the View of the whole thing gets messed up "DialogNotaView" it shows one form in top of the other.
I hope you understand this problem and that u can help me.
How can I fix this problem?
I was trying to center the component in jsf page, it looks sth like this:
<p:panel header="Enter your credentials:" style="vertical-align:middle;">
<h:panelGrid columns="2" styleClass="panelGridCenter">
<h:outputText value="Login: " />
<p:inplace id="Login">
<p:inputText value="Enter login" />
</p:inplace>
</h:panelGrid>
</p:panel>
I've tried to enter sth like this:
style="vertical-align:middle;"
I've tried to use a css class (I've had almost no experience with css):
.panelGridCenter {
margin: 0 auto;
vertical-align:middle;
}
But it doesn't work.
Can you give me any examples or hints how to position this component (panel) in the center of the jsf page?
p - primefaces
thx in advance
Try below code I will hope this answer be your question
<h:form>
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" class="outer_table">
<tr>
<td>
<table width="500" height="300" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
<td align="center">
<p:panel header="Login">
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="username" value="username" />
<p:inputText id="username" value="#{loginBean.uname}" required="true" label="username"/>
<h:outputLabel for="password" value="password" />
<p:password id="password" value="#{loginBean.password}" required="true" label="password" />
<p:commandButton value="Login" action="#{loginBean.loginProject}" update=":growl"/>
</h:panelGrid>
</p:panel>
</td>
</tr>
</table>
</td>
</tr>
</table>
</h:form>
css
<script type="text/css">
html, body
{
margin:0px;
padding:0px;
width:100%;
min-height:100%;
height:100%;
}
.outer_table
{
width:100%;
height:100%;
}
</script>
This may be irrelevant as I cannot answer your question, but a dialog (centered by default) looks pretty cool for a login-page:
<h:body>
<p:growl id="growl" life="5000" autoUpdate="true" showDetail="true" escape="false"/>
<h:form>
<p:dialog id="dialog" header="Login" footer="..." width="400" widgetVar="dlg" visible="true" closable="false" showEffect="clip" draggable="false" resizable="false" style="box-shadow: 7px 10px 5px #303030;">
<p:panelGrid columns="2" style="margin: 0 auto">
<h:outputText value="username:"/>
<h:inputText value="#{loginBean.username}" id="username"/>
<h:outputText value="password:"/>
<h:inputSecret value="#{loginBean.password}" id="password"/>
</p:panelGrid>
<p:commandButton id="button" value="Login" action="#{loginBean.doLogin}" style="float:right"/>
</p:dialog>
</h:form>
</h:body>
visible="true" makes the dialog show automatically after load.
Inspired by this article, also showing how to secure parts of the application.
I am not an expert but sharing my own experience. After putting the panel into form, try putting the form into div with style as below:
<div style="width:360px; margin: 10% auto 10% auto;">
<h:form>
....
</h:form>
</div>
I have a problem on a page with primefaces framwork, this is my fragment code:
<p:rowExpansion rendered="#{riepilogoExtra.approvato == '0'}" >
<p:panelGrid columns="3" style="width:50px; border: 0px" >
<h:outputText value="Ore" />
<h:outputText value="Minuti" />
<h:outputText value="Note" />
<p:inputText id="QTA_MASSIMAHH" value="#{riepilogoExtra.qtaMassimaHH}" size="1" />
<p:inputText id="QTA_MASSIMAMM" value="#{riepilogoExtra.qtaMassimaMM}" size="1" />
<p:inputTextarea id="NOTE" rows="2" cols="20" value="#{riepilogoExtra.note}" />
</p:panelGrid>
<p:commandButton
ajax="true"
id="update"
value="Salva"
update="#form"
action="#{riepilogoExtraResponsabileManagedBean.update(riepilogoExtra)}"
icon="ui-icon-check"
styleClass="ui-priority-primary" />
</p:rowExpansion>
hy,
if you have the problem for button don't work in the first click you must verify your console javascript you have error, resolve the problem and all is ok :)
I have an issue with primefaces datagrid.I am trying to update the dialog box with the selected values on click of p:commandLink.
The Dialog doesnt display any values initially but it gets updated with the previously selected values when i refresh the page and click on commandLink.
I am using primefaces-2.2.1 on JBoss 4.3.0.Any help would be appreciated.
<p:column>
<p:panel header="#{loc.loc_details}" style="text-align:center">
<h:panelGrid columns="1" style="width:100%">
<p:graphicImage value="/user/xyz/resources/images/#{loc.loc_details}.jpg"/>
<h:outputText value="#{loc.locality}" />
<h:outputText value="#{loc.city}" />
<h:outputText value="#{loc.state}" />
<p:commandLink update="locDetail,locDetailGrid" oncomplete="locDialog.show()" title="View Detail" border="0" >
<p:graphicImage value="/user/xyz/resources/images/imagesCA6ETPOM.jpg" />
<f:setPropertyActionListener value="#{loc}"
target="#{tutorialsBean.selectedLocality}" />
</p:commandLink>
</h:panelGrid>
</p:panel>
</p:column>
<p:dialog header="Loc Detail" widgetVar="locDialog" modal="true">
<p:outputPanel id="locDetail" style="text-align:center;" layout="block">
<h:panelGrid id="locDetailGrid" columns="2" cellpadding="5">
<h:outputLabel for="loc_details" value="Locality Details :" />
<h:outputText id="loc_details" value="#{tutorialsBean.selectedLocality.loc_details}" />
<h:outputLabel for="city" value="City: " />
<h:outputText id="city" value="#{tutorialsBean.selectedLocality.city}" />
<h:outputLabel for="state" value="State: " />
<h:outputText id="state" value="#{tutorialsBean.selectedLocality.state}" />
<h:outputText styleClass="text_normal" value="First Name" />
<p:inputText id="fnameText" value="#{tutorialsBean.firstName}" />
<h:outputText styleClass="text_normal" value="Last Name" />
<p:inputText id="lnameText" value="#{tutorialsBean.lastName}" />
<h:outputText styleClass="text_normal" value="Email" />
<p:inputText id="emailText" value="#{tutorialsBean.email}" />
<p:commandButton id="searchButton"
value="Submit" action="#{tutorialsBean.submitValues}"
styleClass="button" />
</h:panelGrid>
</p:outputPanel>
in you commandLink add the update and process attributes in your dialog to refresh the information.
like this:
Put the ID in dialog:
<p:dialog header="Loc Detail" id="locDialog" widgetVar="locDialog" modal="true">
Put the Update to dialog:
<p:commandLink update="locDetail,locDetailGrid" oncomplete="locDialog.show()" title="View Detail" border="0" update="locDialog" process="#this" ajax="true" partialSubmit="true" >
<p:graphicImage value="/user/xyz/resources/images/imagesCA6ETPOM.jpg" />
<f:setPropertyActionListener value="#{loc}" target="#{tutorialsBean.selectedLocality}" />
</p:commandLink>