Read only text box size increased size automatically - html

I have the two text box(Using JSJ).
I have given txt box size as 50. It is working fine. Based on logic I have make one of the text to readonly disabled = true or disable = disabled. The read only text width is increasing its size.
When I inspect through f12,the size are showing 50 only,In inspect mode when i remove the
disable = disabled,it is reducing to actual size
I checked by the sample.
<h:inputText value="test" type="text" size="50">
</h:inputText>
<br/><br/>
<h:inputText value="tes1t" type="text" size="50" disabled="true">
</h:inputText>
I have pass the param to form as below :
Param
<ui:param name="validationMessageOnTheSameLine" value="true" />
<ui:param name="rowWidth" value="650px" />
<ui:param name="helpTextPaddingLeft" value="130px" />
<ui:param name="showAsterik" value="false" />
<ui:param name="showAsterikForUsername" value="false" />
<ui:param name="inputTextSize" value="50" />
<h:panelGrid columns="2" style="width: #{rowWidth}" id="emailValidated"
columnClasses="#{columnClass1}, #{columnClass2}">
<h:outputLabel value="#{uit.emailAddress}:" for="email">
<h:outputLabel styleClass="asterik" value="*"
rendered="#{showAsterik}" />
</h:outputLabel>
<h:panelGrid columns="2" styleClass="tableNoPadding">
<h:inputText value="#{userBean.emailAddress}" id="email"
styleClass="ux-margin-right-1t" size="#{inputTextSize}"
required="true" disabled="#{disableEmailInput}"
requiredMessage="#{uitkem.valueRequired}"
validatorMessage="#{uitkem.emailValidator}">
<f:validator validatorId="emailValidator" />
</h:inputText>
<rich:message for="email" />
</h:panelGrid>
</h:panelGrid>

Check that these <h:inputText> are enclosed in <h:form>.
Also, you don't need to add type="text" in <h:inputText>.
From my test environment (JSF 2.2), both these inputs have the same size when rendered.

Related

JSF Validation message not displaying in template's content part

I got problem with non displaying validation error message on my form, when I'm using templates.
It does validation ok, as I can see I am not forwarded to next page, but I dont see error message.
When I try same code without defining layout template parts it prints message.
This is my form code:
<h:form>
<h:panelGrid columns="2">
<h:outputLabel for="mname">Username </h:outputLabel>
<h:inputText required="true" requiredMessage="Username is required.">
</h:inputText>
<h:commandButton value="Submit"></h:commandButton>
</h:panelGrid>
</h:form>
And this is my code when I'm defining content part:
<!-- Content -->
<ui:define name="content">
<h:form>
<h:panelGrid columns="2">
<h:outputLabel for="mname">Username </h:outputLabel>
<h:inputText required="true" requiredMessage="Username is required.">
</h:inputText>
<h:commandButton value="Submit"></h:commandButton>
</h:panelGrid>
</h:form>
</ui:define>
Anyone got reason why wouldn't I see error message when I'm defining my layout page.
This is my layout.xhtml content part.
<div id="content">
<ui:insert name="content">
<ui:include src="/template/content.xhtml" />
</ui:insert>
</div>
Eventually you will need a h:message tag.. the requiredMessage is a tip for the framework on what to print in the message tag.
So you should have a set up like:
<h:form>
<h:message showSummary="true" showDetail="false"
id="errorsMessages"
for="txt"/>
<h:panelGrid columns="2">
<h:outputLabel for="mname">Username </h:outputLabel>
<h:inputText id="txt" required="true" requiredMessage="Username is required.">
</h:inputText>
<h:commandButton value="Submit"></h:commandButton>
</h:panelGrid>
</h:form>

Control on Calendar Primefaces component

I am using p:calendar Primefaces component for specifying 2 dates : start and end.
An evident control is to verify if end date is not before start date.
Is there a way to do it ?
I found the solution :
<p:outputLabel for="startDate" value="#{msg.StartDate}" />
<p:calendar id="startDate" value="#{employeeBean.employee.startDate}" required="true" pattern="dd-MM-yyyy" language="#{msg.CalendarLanguage}" mask="true"
requiredMessage="#{msg.required}">
<p:ajax event="dateSelect" update="endDate" />
</p:calendar>
<p:message for="startDate" />
<p:outputLabel for="endDate" value="#{msg.EndDate}" />
<p:calendar id="endDate" mindate="#{employeeBean.employee.startDate}" value="#{employeeBean.employee.endDate}" required="false" pattern="dd-MM-yyyy"
language="#{msg.CalendarLanguage}" mask="true">
</p:calendar>
<p:message for="endDate" />

commandButton action method not executed

i'm working in a web application with jsf and primefaces.
My code for the navBar looks as follow:
<p:layoutUnit position="north" >
<h:form>
<img src="resources/images/logo.png" alt="" />
<p:outputLabel value="Rechercher " style="font-size: large"/>
<p:inputText value="#{acount.searchWord}" required="true" requiredMessage="Le titre est requit"/>
<p:commandButton value="Go" action="#{acount.rechercherLivre(acount.searchWord)}" styleClass="btngo" />
<h:link outcome="main.xhtml" value="Accueil" style="margin-left: 400px;font-size: medium"/>
<h:link outcome="Contact.xhtml" value="Contact" style="font-size: medium"/>
<h:link outcome="Info.xhtml" value="Info" style="font-size: medium"/>
<h:link outcome="Login.xhtml" value="Login" style="font-size: medium" rendered="#{!acount.connected}" />
<h:link outcome="exe.xhtml" value="S'enregistrer" style="font-size: medium" rendered="#{!acount.connected}" />
<p:menuButton value="Panier #{shopingCart.produits.size()}" style="color: #045491;background: greenyellow;background-color: yellowgreen;font-size: medium">
<p:menuitem value="Afficher" action="#{shopingCart.afficherPanier()}"/>
<p:separator />
<p:menuitem value="Homepage" url="http://www.primefaces.org" />
</p:menuButton>
<p:menuButton value="Options" rendered="#{acount.connected}" style="color: #045491;background: greenyellow;background-color: yellowgreen;font-size: medium">
<p:menuitem value="Compte" />
<p:menuitem value="Mes Commandes " />
<p:menuitem value="Se deconnecter" action="#{acount.doLogout()}" />
<p:separator />
<p:menuitem value="Homepage" url="http://www.primefaces.org" />
</p:menuButton>
</h:form>
</p:layoutUnit>
And the image for this code is:
The problem is if i don't put anything in the imput text the action for the commandButton is not executed, also the action method in the menuButton are not executed if i don't put something in the inputText.
I can solve this problem with putting a form for each action method but my navbar got larger and it looks worth.
how can i solve this issues?
If you do not need to post any value to your bean by your commandButton then add process attribute to the commandButton. I think you are trying to leave some of the inputs blank and still send the request, but the problem is that one of them has the required attribute set to 'true'. Remove required attribute form your inputs and add process="#this" to your commandButton. I hope I am right.

Make the outline of a input "red" if field is empty

I use primefaces 4, template : cupertino.
I want to make the outline of a input "red" if field is empty.
I upgraded to type field required = "true", but the outline remain in their original state if they are empty.
But for fields of type HTML 5 all goes well.
Thank you.
<form id="form_inscri_pp" name="form_inscri_pp">
<h:panelGrid columns="2" cellpadding="5" >
<h:outputText value="Nom:" styleClass="label_inscri_pp"/>
<input id="nom_pp" class='inscription_candidat'
placeholder='Saisissez votre nom' type='text' name="nom_pp"
pattern="^[A-Za-z ]+$" maxlength="25" required="required"
autocomplete="on"/>
<h:outputText value="Date de naissance: " styleClass="label_inscri_pp"/>
<p:calendar name="DN_pp" id="DN_pp" value="#{calendrier.date}"
locale="fr" showOn="button" navigator="true"
pattern="dd/MM/yyyy" mindate="1/1/1950" maxdate="31/12/1993"
mask="true" required="true" readonly="true" size="20" />
</h:panelGrid>
<input class='button_inscri' type='submit' value="S'inscrire" />
<input class='button_inscri' type='button' value='RĂ©initialiser' />
</form>
According the code you post, the input text with id nom_pp get red-outlined when I input nothing. The only thing that won't work is p:calendar, which is because you put a readonly attribute in it.
So the solution is simply remove the readonly attribute of the p:calendar.
And BTW, there is no name attribute in p:calendar, so remove it, too.
What's more, you need to use <h:form> instead of <form>. And there is also no name parameter in <h:form>.
So you code should looks like:
<h:form id="form_inscri_pp" >
<h:panelGrid columns="2" cellpadding="5" >
<h:outputText value="Nom:" styleClass="label_inscri_pp"/>
<input id="nom_pp" class='inscription_candidat'
placeholder='Saisissez votre nom' type='text' name="nom_pp"
pattern="^[A-Za-z ]+$" maxlength="25" required="required"
autocomplete="on"/>
<h:outputText value="Date de naissance: " styleClass="label_inscri_pp"/>
<p:calendar id="DN_pp" value="#{inputValidateBean.date}"
locale="fr" showOn="button" navigator="true"
pattern="dd/MM/yyyy" mindate="1/1/1950" maxdate="31/12/1993"
mask="true" required="true" size="20" />
</h:panelGrid>
<input class='button_inscri' type='submit' value="S'inscrire" />
<input class='button_inscri' type='button' value='RĂ©initialiser' />
</h:form>
UPDATE
Since the solution above doesn't work in your environment, try to replace all HTML5 components to primeface/jsf components.
I tried that and it also works in my environment.
Take a look at this:
<h:form id="form_inscri_pp" >
<h:panelGrid columns="2" cellpadding="5" >
<h:outputText value="Nom:" styleClass="label_inscri_pp"/>
<p:inputText id="nom_pp" styleClass="inscription_candidat"
placeholder="Saisissez votre nom" maxlength="25"
required="true" autocomplete="on" value="#{inputValidateBean.nom}">
<f:validateRegex pattern="^[a-zA-Z]+$" />
</p:inputText>
<h:outputText value="Date de naissance: " styleClass="label_inscri_pp"/>
<p:calendar id="DN_pp" value="#{inputValidateBean.date}"
locale="fr" showOn="button" navigator="true"
pattern="dd/MM/yyyy" mindate="1/1/1950" maxdate="31/12/1993"
mask="true" required="true" size="20" />
</h:panelGrid>
<p:commandButton styleClass="button_inscri" value="S'inscrire"
validateClient="true" update="form_inscri_pp"
action="#{inputValidateBean.doSubmit()}"/>
</h:form>
In the backing bean:
#ManagedBean
#ViewScoped
public class InputValidateBean implements Serializable{
private Date date;
private String nom;
public void doSubmit(){
System.out.println("Do something!");
}
//getters and setters below...

Accordion panel appears open, but doesn't show content

I want to show the first tab, and by default (I mean, without activeIndex) it shows me that tab, but it doesn't show the content.
<p:accordionPanel id="acordeon" value="#{editarReporteExcelBean.reporteOperacionDtoList}" var="reporteOperacion" activeIndex="0" >
<p:tab id="areaTab" >
<f:facet name="title">Area #{reporteOperacion.area.nombre}</f:facet>
<anglosgi:reporteOperacion id="reporteOperacion1"
reporteOperacionDto="#{reporteOperacion}"
formId="reporteForm"
contenedorId="reporteForm:acordeon"/>
</p:tab>
</p:accordionPanel>
and there's the first lines of {#reporteOperacion}:
<composite:interface>
<composite:attribute name="reporteOperacionDto" required="true" />
<composite:attribute name="contenedorId" required="true" />
<composite:attribute name="formId" required="true" />
</composite:interface>
<composite:implementation>
<p:outputPanel id="panelGeneral" >
<fieldset>
<legend>Reporte
<h:outputText value="#{cc.attrs.reporteOperacionDto.metaArchivoReporte.fecha}" >
<f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT-4" />
</h:outputText>
</legend>