I want to clear the inputText when user select "select country admin" in selecOneMenu, I am able to do this by changing itemValue=" " but it fails for rquired="true" condition on submit
<h:selectOneMenu id="eidx" value="#{countryBean.selectedEid}" required="#{!countryBean.isEditMode}"
requiredMessage="#{msg['country.label.validation.select.countryadmin']}" >
<f:selectItem itemLabel="Select Country Admin" itemValue="#{null}"/>
<f:selectItem itemLabel="Add New User" itemValue="1"/>
<f:selectItems value="#{countryBean.allUserDetails}" var="user" itemLabel="#{user.lastName}, #{user.firstName} | (#{user.eid})" itemValue="#{user.eid}"/>
<p:ajax listener="#{countryBean.getUserDetail}" process="#this" update="userDetailPanel" onstart="statusDialog.show();" oncomplete="statusDialog.hide();"/>
</h:selectOneMenu>
</div>
<h:panelGroup id="userDetailPanel">
<div class="clear"> </div>
<div class="form-label">
<label title="EID" for="EID">#{msg['country.label.EID']}</label>
</div>
<div class="form-field" >
<h:inputText id="eidPX" value="#{countryBean.usersDetailsDTO.eid}" disabled="#{not(countryBean.selectedEid eq '1')}" resetValues="true">
<f:validator validatorId="regexVal"/>
</h:inputText>
</div>
<div class="clear"> </div>
<div class="form-label">
<label title="EID" for="EID">#{msg['country.label.FirstName']}</label>
</div>
<div class="form-field" >
<h:inputText validatorMessage="#{msg['country.label.validation.select.first.name']}" required="#{(countryBean.selectedEid eq '1')}" requiredMessage="Enter first Name" value="#{countryBean.usersDetailsDTO.firstName}" id="empFName" disabled="#{not(countryBean.selectedEid eq '1')}">
<f:validator validatorId="nameValidation" />
</h:inputText>
</div>
<div class="clear"> </div>
<div class="form-label">
<label title="EID" for="EID">#{msg['country.label.lastname']}</label>
</div>
I have done this by using javascript
document.getElementById("eidx").value="";
Related
enter image description here
My code:
<div style="margin-bottom:3px">
<input type="hidden" id="CollectorID" name="CollectorID" value="">
<input class="easyui-textbox" id="ManageUnit" name="ManageUnit" style="width:100%" labelPosition="left" data-options="label:'Đơn vị:', readonly:true, multiline: true"> #*Đơn vị quản lí*#
</div>
<div style="margin-bottom:3px">
<input type="hidden" id="CollectorID" name="CollectorID" value="">
<input class="easyui-textbox" id="CarPlate" name="CarPlate" style="width:100%" labelPosition="left" data-options="label:'Số hiệu:', readonly:true, multiline: true">
</div>
<div style="margin-bottom:3px">
<input class="easyui-textbox" id="Speed" name="Speed" style="width:100%" labelPosition="left" data-options="label:'Tốc độ:', readonly:true, multiline: true">
</div>
<div style="margin-bottom:3px">
<input class="easyui-textbox" id="Lat" name="Lat" style="width:100%" labelPosition="left" data-options="label:'Vĩ độ:', readonly:true, multiline: true">
</div>
<div style="margin-bottom:3px">
<input class="easyui-textbox" id="Lng" name="Lng" style="width:100%" labelPosition="left" data-options="label:'Kinh độ:', readonly:true, multiline: true">
</div>
<div style="margin-bottom:3px">
<input class="easyui-textbox" id="Address" name="Address" style="width:100%" labelPosition="left" data-options="label:'Địa chỉ:', readonly:true, multiline: true">
</div>
<hr />
<div class="clearfix" style="margin-bottom:20px">
Đóng
</div>
Can anyone show me how to modify (shorten) the distance between Easyui-textbox and its label?
I am trying show within the p:dialog-element the p:fileUpload- Element.
Without the p:fileUpload -Element the p:dialog is showing up. Then I add the fileUpload-Tag
and it does nothing. I am using Tomcat 7, mojorra 2.1.28, primefaces 5.0.
<ui:composition
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
template="WEB-INF/templates/template.xhtml"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
<!--Zusätzliches Stylesheet-->
<ui:define name="additionalCSS"> <link rel="stylesheet" type="text/css" href="resources/style/benutzer.css" /> </ui:define>
<!--Titel-->
<ui:define name="title">Ticket schreiben</ui:define>
<!--Hier beginnt der Content-Bereich, der je nach Client variiert-->
<ui:define name="content">
<div id="content">
<div id="verlauf">
<h:form>
<h:commandLink value="Home" action="#{linkController.goHome}"> </h:commandLink> /
<h:commandLink value="Tickets" action="#{linkController.goTicketindex}"></h:commandLink> /
<h:commandLink value="Neues Ticket erstellen" action="#{linkController.goTicketcreate}"></h:commandLink>
</h:form>
</div>
<div id="headline">Neues Ticket erstellen</div>
<h:form>
<div id="stats">
<div id="title">Empfänger</div>
<div class="inputName">An:</div>
<div class="inputContent"> <h:inputText id="user" styleClass="inputText" value="#{ticketController.adress}" >
<!-- validatorMessage="Bitte geben Sie den Empfänger an." >
<f:validateRequired/>-->
</h:inputText> </div>
<div class="inputName">Betreff:</div>
<div class="inputContent"> <h:inputText id="topic" styleClass="inputText" value="#{ticketController.topic}"
></h:inputText> </div>
</div>
<div id="rechte">
<div id="title">Nachricht</div>
<div class="column">
<div class="inputArea"> <h:inputTextarea id="message" styleClass="inputField" value="#{ticketController.message}" >
<!-- validatorMessage="Bitte geben Sie eine Nachricht ein." >
<f:validateRequired/>-->
</h:inputTextarea> </div>
</div>
<br/>
<p:dialog widgetVar="dialogVar" modal="true" minHeight="100" draggable="true" >
<p:fileUpload fileLimit="20000" fileLimitMessage="File ist zu groß" fileUploadListener="#{ticketController.fileUploadHandler}"></p:fileUpload>
</p:dialog>
<h:commandButton value="Datei Uploaden" type="button" styleClass="submitButton" onclick="dialogVar.show()"></h:commandButton>
<h:commandButton value="Anlegen" type="submit" styleClass ="submitButton"
action="#{ticketController.createNewTicket}"></h:commandButton>
</div>
</h:form>
</div>
</ui:define>
</ui:composition>
I tried PF('dialogVar').show and dialogVar.show(), but it is not showing up.
I think you must add inside your dialog. After generating code,despite what you see in your xhtml page, the dialog will be outside of your form,therefore you need to add it yourself.
try the following code:
<ui:define name="content">
<div id="content">
<div id="verlauf">
<h:form>
<h:commandLink value="Home" action="#{linkController.goHome}"/>
<h:commandLink value="Tickets" action="#{linkController.goTicketindex}"/>
<h:commandLink value="Neues Ticket erstellen" action="#{linkController.goTicketcreate}"/>
</h:form>
</div>
<div id="headline">Neues Ticket erstellen</div>
<h:form>
<div id="stats">
<div id="title">Empfänger</div>
<div class="inputName">An:</div>
<div class="inputContent">
<h:inputText id="user" styleClass="inputText" value="#{ticketController.adress}" />
</div>
<div class="inputName">Betreff:</div>
<div class="inputContent">
<h:inputText id="topic" styleClass="inputText" value="#{ticketController.topic}"
></h:inputText> </div>
</div>
<div id="rechte">
<div id="title">Nachricht</div>
<div class="column">
<div class="inputArea"> <h:inputTextarea id="message" styleClass="inputField" value="#{ticketController.message}" >
<!-- validatorMessage="Bitte geben Sie eine Nachricht ein." >
<f:validateRequired/>-->
</h:inputTextarea> </div>
</div>
<br/>
<h:commandButton value="Datei Uploaden" type="button" styleClass="submitButton" onclick="dialogVar.show()"></h:commandButton>
<h:commandButton value="Anlegen" type="submit" styleClass ="submitButton"
action="#{ticketController.createNewTicket}"></h:commandButton>
</div>
</h:form>
<p:dialog widgetVar="dialogVar" modal="true" minHeight="100" draggable="true" >
<h:form>
<p:fileUpload fileLimit="20000" appendToBody="false" fileLimitMessage="File ist zu groß" fileUploadListener="#{ticketController.fileUploadHandler}"/>
</h:form>
</p:dialog>
</div>
Tabindex attribute is not working on p:selectOneMenu that I am using in my page. I also have h:inputtext on the same page for which tabindex works fine.
I am using primefaces 4.0. Please help. After the 2nd tabindex it gets lost.
<!-- This Dialog page is being used for both ADD & EDIT APPLICANT functionality -->
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:form id="addApplicantForm">
<div class="panel" style="width: 540px;">
<p:outputPanel id="critTabPanel" >
<div class="dlgHeader">#{applicantForITCController.action} Applicant</div>
<table width="100%" border="0" cellspacing="5px" style="font-size: 12px">
<tr>
<td style="width:30%">First Name:</td>
<td style="width:65%;padding-right: 5px" align="right">
<h:inputText id="firstName-input" styleClass="suburbinput round5 applyInput" value="#{applicantForITCController.applicantForITCInfo.firstName}"
required="true" requiredMessage="First Name required" onkeypress="return fnb.pl.events.KeyEvents.isStringKey(event)" maxlength="50" tabindex="1"/>
<p:watermark for="firstName-input" value="Enter First Name" />
</td>
<td style="width:5%">
<p:message for="firstName-input" id="msg-firstName-input" display="icon" />
</td>
</tr>
<tr>
<td style="width:30%">Last Name:</td>
<td style="width:65%;padding-right: 5px" align="right">
<h:inputText id="lastName-input" styleClass="suburbinput round5 applyInput" value="#{applicantForITCController.applicantForITCInfo.lastName}"
onkeypress="return fnb.pl.events.KeyEvents.isStringKey(event)" maxlength="50" required="true" requiredMessage="Last Name required" tabindex="2"/>
<p:watermark for="lastName-input" value="Enter Last Name" />
</td>
<td style="width:5%">
<p:message for="lastName-input" id="msg-lastName-input" display="icon" />
</td>
</tr>
<tr>
<td style="width:30%">Identity Type:</td>
<td style="width:65%;">
<div class="contGeneric">
<div class="colRight">
<div class="fnbDropMenu">
<p:selectOneMenu id="cri-idType" value="#{applicantForITCController.applicantForITCInfo.idType}"
required="true" requiredMessage="Please select an Identity Type" styleClass="selectOnDialog" tabindex="3">
<f:selectItem itemLabel="Please select" itemValue=" " noSelectionOption="true" />
<f:selectItems value="#{applicantForITCController.idTypes}" var="idTy" itemLabel="#{idTy.desc}" itemValue="#{idTy}"/>
<f:validator for="idTypeValidator"
binding="#{za.co.fnb.propertyleader.interfaces.ui.web.validator.IDTypeValidator}"/>
<f:attribute name="idNum" value="#{idNum}" />
</p:selectOneMenu>
</div>
</div>
</div>
</td>
<td style="width:5%">
<p:message for="cri-idType" id="msg-idType" display="icon" />
</td>
</tr>
<tr>
<td style="width:30%">ID/Passport No:</td>
<td style="width:65%;padding-right: 5px" align="right">
<h:inputText id="idNumber" binding="#{idNum}" styleClass="suburbinput round5 applyInput" value="#{applicantForITCController.applicantForITCInfo.idNumber}"
required="true" requiredMessage="ID/Passport Number required" maxlength="30" tabindex="4"/>
<p:watermark for="idNumber" value="Enter ID/Passport Number" />
</td>
<td style="width:5%">
<p:message for="idNumber" id="msg-idNumber" display="icon" />
</td>
</tr>
<tr>
<td style="width:30%">Cell Number:</td>
<td style="width:65%;padding-right: 5px" align="right">
<h:inputText id="cellNo" styleClass="suburbinput round5 applyInput" value="#{applicantForITCController.applicantForITCInfo.cellNo}"
required="true" requiredMessage="Cell Number required" onkeydown="return fnb.pl.events.KeyEvents.isNumericKey(event)" maxlength="10" tabindex="5"/>
<p:watermark for="cellNo" value="Enter Cell Number" />
</td>
<td style="width:5%">
<p:message for="cellNo" id="msg-cellNo" display="icon" />
</td>
</tr>
</table>
</p:outputPanel>
<div class="btnHolder dblExtraForgotPass" align="center" style="padding-top: 15px;">
<a id="colorboxCloseBtn2" class="btn InActive"
href="javascript:addApplicantDialog.hide();"><span>Cancel</span></a>
<p:commandLink process="#this #parent" update=":#{p:component('applicantForITCTbl')} :#{p:component('confirmAppPanel')}
:#{p:component('critTabPanel')} :#{p:component('msgPnl1')}"
action="#{applicantForITCController.updateApplicantForItcList}" styleClass="btn InActive"
oncomplete="fnb.pl.property.handleAddApplicantComplete(xhr, status, args)">
<span>Save</span>
</p:commandLink>
</div>
</div>
</h:form>
</ui:composition>
i am trying to display the message of the outcome of a validation done in managed bean in the dialog but it is not getting displayed in the dialog on submit of the form.
Please help me in fixing this
My JSF page snippet with dialog
<p:dialog header="Add LPC" id="lpcDlg" widgetVar="dlg" rendered="true"
appendToBody="true" resizable="true" modal="true" height="320px"
width="38%">
<h:form id="addLpc">
<div align="center" style="margin-bottom: 1px; padding-bottom: 1px;">
<h:outputLabel value="Add New LPC"
style="font-color:#000000;font-weight:bold;font-size:24px;padding-bottom:1px;"></h:outputLabel>
</div>
<div align="center">
<p:messages id="lpcDlgMsg" showDetail="false" autoUpdate="true"
closable="true" />
<p:messages id="lpcDlgMsg2" for="lpcDlgMessage" showDetail="false"
autoUpdate="true" closable="true" />
<h:panelGrid id="addLpcForm" columns="2" appendToBody="true">
<h:outputText value="LPC ID" />
<p:inputText id="lpcId" value="#{lpcBean.lpcId}" required="true"
requiredMessage="LPC ID is required">
<f:ajax event="blur" render="lpcDlgMsg" />
</p:inputText>
<h:outputText value="First Name" />
<p:inputText id="firstName" value="#{lpcBean.firstName}" />
.
.
.
.
</h:panelGrid>
</div>
<div align="center">
<p:commandButton id="submitButton" value="Submit" ajax="true"
update=":lpcForm:lpcDataTable,addLpc"
action="#{lpcBean.formSubmit}" oncomplete="dlg.hide()" />
<p:commandButton id="cancelButton" value="Cancel"
onclick="dlg.hide()" />
</div>
</h:form>
</p:dialog>
message with id lpcDlgMsg2 is the message i am trying to display on submit.The other message is getting displayed correct on blur.
Snippet of the method that is called on submit
public void formSubmit()
{
if(resultSet.next())
{
int lpcIdCount=rs.getInt("lpcCount");
if(lpcIdCount!=0)
{
FacesContext.getCurrentInstance().addMessage("lpcDlgMessage", new FacesMessage(FacesMessage.SEVERITY_ERROR," ", "Duplicate LPCID"));
System.out.println("after display");
}
else
{
.
.
.
.
}
}
}
}
Here is my suggestion:
<p:dialog header="Add LPC" id="lpcDlg" widgetVar="dlg" rendered="true"
appendToBody="true" resizable="true" modal="true" height="320px"
width="38%">
<h:form id="addLpc">
<div align="center">
<p:messages id="lpcDlgMsg" showDetail="false" autoUpdate="true"
closable="true" />
<h:panelGrid id="addLpcForm" columns="2" >
<h:outputText value="LPC ID" />
<p:inputText id="lpcId" required="true" />
<h:outputText value="First Name" />
<p:inputText id="firstName" required="true" />
</h:panelGrid>
</div>
<div align="center">
<p:commandButton id="submitButton" value="Submit"
oncomplete="if (!args.validationFailed){dlg.hide();}" />
<p:commandButton id="cancelButton" value="Cancel"
onclick="dlg.hide()" />
</div>
</h:form>
</p:dialog>
Note that I've simplified your code in order to avoid using a managedbean.
If you want your managed bean to perform the validation, use RequestContext to conditionally execute the code that will close the dialog and remove the oncomplete from Submit button.
if (success) {
RequestContext.getCurrentInstance().execute("dlg.hide()");
}else{
//show all the messages you need here
}
You have to add this javascript first inside head tag
function handleComplete(xhr, status, args) {
if (!args.validationFailed) {
dlg.hide();
} else {
}
}
More changes are
<p:commandButton id="submitButton" value="Submit" ajax="true"
update=":lpcForm:lpcDataTable,addLpc :lpcDlgMsg2"
actionListener="#{lpcBean.formSubmit}" oncomplete="handleComplete(xhr, status, args)" />
action to actionListener because action has String return type.
This will work fine.
I have two in one xhtml. But both of them are not working properly.
When I click the Save button, the confirmDialog of the Import button came up.
When I click the Import button, nothing came up.
Is there anything that I have missed out?
<td><p:commandButton type="button"
value="Save" id="cr1002_command_save"
onclick="confirmation.show()" ajax="false"
style="width: 80px;height: 24px">
</p:commandButton> <p:confirmDialog id="confirmDialog"
message="#{msg.cr1002_prompt_confirm_save}" severity="alert"
widgetVar="confirmation" style="width: 70px;height: 27px">
<p:commandButton id="confirm" value="OK"
oncomplete="confirmation.hide()"
action="#{pc_Cr1002.doCr1002_command_saveAction}" ajax="false"
style="width: 80px;height: 24px" />
<p:commandButton id="decline" value="Cancel"
onclick="confirmation.hide()" type="button"
style="width: 80px;height: 24px" />
</p:confirmDialog></td>
<td></td>
<td><p:commandButton type="button"
value="Import"
onclick="gowait('form1:cr1002_command_import')"
id="cr1002_command_import" ajax="false"
style="width: 80px;height: 24px"></p:commandButton>
<p:confirmDialog id="confirmDialog2"
message="Importing... Importing..." severity="alert"
widgetVar="confirmation" style="width: 70px;height: 27px">
<p:commandButton id="confirm2" value="OK"
oncomplete="confirmation.hide()"
action="#{pc_Cr1002.doCr1002_command_importAction}" ajax="false"
style="width: 80px;height: 24px" />
<p:commandButton id="decline2" value="Cancel"
onclick="confirmation.hide()" type="button"
style="width: 80px;height: 24px" />
</p:confirmDialog>
</td>
The problem come from the same widgetVar attribute, this attribute use in client side, it cause conflict in client side, you should code like as:
<td><p:commandButton type="button"
value="Save" id="cr1002_command_save"
onclick="confirmation.show()" ajax="false"
style="width: 80px;height: 24px">
</p:commandButton> <p:confirmDialog id="confirmDialog"
message="#{msg.cr1002_prompt_confirm_save}" severity="alert"
widgetVar="confirmation" style="width: 70px;height: 27px">
<p:commandButton id="confirm" value="OK"
oncomplete="confirmation.hide()"
action="#{pc_Cr1002.doCr1002_command_saveAction}" ajax="false"
style="width: 80px;height: 24px" />
<p:commandButton id="decline" value="Cancel"
onclick="confirmation.hide()" type="button"
style="width: 80px;height: 24px" />
</p:confirmDialog></td>
<td></td>
<td><p:commandButton type="button"
value="Import"
onclick="confirmation2.show()"
id="cr1002_command_import" ajax="false"
style="width: 80px;height: 24px"></p:commandButton>
<p:confirmDialog id="confirmDialog2"
message="Importing... Importing..." severity="alert"
widgetVar="confirmation2" style="width: 70px;height: 27px">
<p:commandButton id="confirm2" value="OK"
oncomplete="confirmation.hide()"
action="#{pc_Cr1002.doCr1002_command_importAction}" ajax="false"
style="width: 80px;height: 24px" />
<p:commandButton id="decline2" value="Cancel"
onclick="confirmation.hide()" type="button"
style="width: 80px;height: 24px" />
</p:confirmDialog>
</td>