How to disable autocomplete in <h:inputText>? - jsf

I'm making my term paper using JSF 2.0, Java 6 and Tomcat 7, but I'm having some doubts in the development.
In my project I have a <h:inputText> tag
<h:inputText value="#{turmaMBean.nome}">
<f:ajax event="keyup" render=":meuForm:minhaTabela" />
</h:inputText>
I want to disable autocomplete. I already tried:
<h:inputText value="#{turmaMBean.nome}" autocomplete="false">
<f:ajax event="keyup" render=":meuForm:minhaTabela" />
</h:inputText>
However, it didn't work. What can I do to solve this problem?

I found the answer. I searched a lot about this issue and I discover this isn't an issue. When I try to do the following:
<h:inputText value="#{turmaMBean.nome}" autocomplete="off">
<f:ajax event="keyup" render=":meuForm:minhaTabela" />
</h:inputText>
I didn't restart my Tomcat Server, and by some strange way Tomcat doesn't updated my view properly. When I tried to restart the server, this attribute start work.
So, if you need to turn the autocomplete off, use:
autocomplete="off"
This probably will work - don't forget to restart the server, sometimes Tomcat like play with us :p.

Related

synchronize E mail automatically with database

I wanted to know from you whether it is possible to check an email entry, if it exists already in the database and to display a message .
This validation should work dynamically without a button.
I work with jsf 2.1 and prime faces 3.5
I hope you understand what I mean and thank you for your help.
You need to implement a custom validator. Full explanation in this guide
Snippet code:
<h:inputText id="email" value="#{bean.email}">
<f:validator validatorId="myEmailValidator" />
<f:ajax event="keyup" render="emailError" />
</h:inputText>
<h:message id="emailError" for="email" />

imagecropper with atribute image in primefaces doesn't crop although image is loaded

if I change
image="#{pageContext.servletContext.contextPath}/upload
/#{fileUploadController.imagemTemporaria}"
and put
image="/imagens/#{fileUploadController.imagemTemporaria}"
the image is loaded. on the other hand, the method crop stops to work.
my images are in F:\imagens-retaguarda\imagens
my descriptor contains the following
<property name="alternatedocroot_1" value="from=/imagens/*
dir=F:\imagens-retaguarda\" />
do you know why that happens?
below is my code.
<h:form>
<p:outputPanel id="outputPanelUpload">
<h:panelGrid columns="2">
<h:outputText value="Imagem" rendered="#{fileUploadController.exibeBotao}"/>
<h:outputText value="Pré-visualização" rendered="#{fileUploadController.exibeBotao}"/>
<p:imageCropper id="imageCropperImagemTemporaria"
value="#{fileUploadController.croppedImage}"
image="#{pageContext.servletContext.contextPath}/upload/#{fileUploadController.imagemTemporaria}"
initialCoords="0,0,50,50"
maxSize="250,163"
minSize="30,30" />
<h:panelGroup rendered="#{fileUploadController.exibirPreVisualizacao}">
<p:graphicImage value="#{fileUploadController.imagemEnviada}" cache="false"/>
</h:panelGroup>
</h:panelGrid>
<br/>
<p:commandLink action="#{fileUploadController.crop}" update="outputPanelUpload" rendered="#{fileUploadController.exibeBotao}" value="Pré-visualizar" id="preVisualizar"/>
</p:outputPanel>
<br/>
<br/>
<p:fileUpload fileUploadListener="#{fileUploadController.enviarImagem}" sizeLimit="1000000" auto="true" update="outputPanelUpload" label="Escolher"/>
</h:form>
There is a restriction on p:imageCropper that it doesnt work with alternate docroot in glassfish
from primefaces forum
ImageCropper can crop local images in webroot and external images
located with http://. I don't think it is a bug but more like a
limitation as it doesn't support glassfish specific stuff like this.
link to above quoute by optimus.
Some friendly forum user has put together a codesnippet on how to construct the complete url. Havnt tested it myself, but conceptually it should work.
<p:imageCropper id="croppedImg"
value="#{controller.croppedImage}"
image="#{request.requestURL.substring(0, request.requestURL.length() - request.requestURI.length())}#{request.contextPath}/Screens/Image.png"
initialCoords="10,10,200,200" />
link

Command buttons invokes actions on second push (jsf)

I came to strange behaviour of my application. Command buttons start to invoke actions on second hit. On first - nothing happens. It takes effect on firefox and chromium, but in epiphany works as usual.
My environment:
- ubuntu 11.04
- glassfish 3.1.1
- jsf 2.X
- primefaces 3.2
- firefox 12.0
- epiphany 2.30.6
Code example:
<ui:define name="content">
<h:form id="form">
<h:panelGrid id="panelGrid" columns="3">
<h:outputText value="#{msg.fieUserName}:"/>
<h:inputText id="name" value="#{userBb.editedUser.username}" />
<h:message for="name" styleClass="error_msg"/>
<h:outputText value="#{msg.fieUserDescription}:"/>
<h:inputText id="description" value="#{userBb.editedUser.description}" />
<h:message for="description" styleClass="error_msg"/>
<h:outputText value="#{msg.fieUserPassword}:"/>
<h:inputSecret id="password" value="#{userBb.editedUser.password}" redisplay="true"/>
<h:message for="password" styleClass="error_msg"/>
<h:outputText value="#{msg.fieUserRights}:"/>
<p:selectOneMenu id= "rights"
value= "#{userBb.editedUserGroup}"
converter="#{pGroupOfUsersConverter}">
<f:selectItems
value ="#{groupDao.findAll()}"
var ="row"
itemLabel="#{groupDao.rightsDescription(row.id)}"
itemValue="#{row.groupname}"
>
</f:selectItems>
</p:selectOneMenu>
<h:message for="rights" styleClass="error_msg"/>
<h:outputText value="#{msg.fiePorofolioName}:" rendered="#{userBb.chosenNew}"/>
<h:inputText id="portName" value="#{userBb.portfelForNewUser.nazwa}" rendered="#{userBb.chosenNew}">
<f:validateBean disabled="true" />
</h:inputText>
<h:message for="portName" styleClass="error_msg" rendered="#{userBb.chosenNew}"/>
<h:outputText value="#{msg.fiePotofolioCurrency}:" rendered="#{userBb.chosenNew}"/>
<p:selectOneMenu id= "waldep"
value= "#{userBb.portfelForNewUser.walutaDepozytowa}"
converter="#{igConverter}"
rendered= "#{userBb.chosenNew}"
>
<f:selectItems value= "#{igDao.waluty}"
var= "row"
itemLabel="#{row.nazwa}"/>
</p:selectOneMenu>
<h:message for="waldep" styleClass="error_msg" rendered="#{userBb.chosenNew}"/>
</h:panelGrid>
<h:panelGrid columns="2">
<h:commandButton value="#{msg.butCreate}" action="#{userBb.formCreate()}" rendered="#{userBb.chosenNew}" />
<h:commandButton value="#{msg.butSave}" action="#{userBb.formEdit()}" rendered="#{!userBb.chosenNew}"/>
<h:commandButton value="#{msg.butBack}" action="#{userBb.formBack()}"/>
</h:panelGrid>
</h:form>
</ui:define>
In this example method userBb.formCreate() is invoked only on second click on command button although button is visible. When fields are not properly filled up than appropriate messages appear next to them, but... only on second click! Any advice?
I check out points from: this advice, but not found solution.
Ok, I found what was wrong. So:
Appearance of the problem:
I've got a page for user data. Some input items and command buttons. When clicking "Create" button, input data is checked out. If data is ok user is created and table of users appears, or when there are errors - errors messages appear and user stays on the same page:
I found some erratic behavior. Nothing has happened on first click (action), only second and subsequent actions have an effect. But. This behavior was related to kind of web browser I use.
All actions takes place from the first click, in webrowsers: epiphany and konqueror. Although in firefox and chromium I observed this erratic behavior which I described above. Code for a command button was:
<h:commandButton value="#{msg.butCreate}" action="#{userBb.formCreate()}" rendered="#{userBb.chosenNew}"/>
Different behaviors in different webbrowsers.
The cause.
The cause was enumerated by #Balusc in his note, which I read roughly first time. It was indeed pt. 7.
The solution.
I've tried to change button declaration this way:
<h:commandButton value="#{msg.butCreate}" action="#{userBb.formCreate()}" rendered="#{userBb.chosenNew}">
<f:ajax render="userForm"/>
</h:commandButton>
where userForm was proper id of h:form. No result, still only second and subsequent clicks has an effect - shows error messages.
So I changed declaration command button from previous page, that invoked erratic behavior page. Originally it was:
<p:commandButton value="#{msg.butNew}" action="#{userBb.actionNew()}"/>
primefaces command button. And that was it, as Balusc wrote: "If a parent of the with the UICommand button is been rendered/updated by an ajax request beforehand, then the first action will always fail."
So I changed declaration to:
<p:commandButton value="#{msg.butNew}" action="#{userBb.actionNew()}" ajax="false"/>
And that's it. It works fine in any browser, for the first action.

Primefaces confirm dialog disappearing almost instantly

I'm developing an application in JSF 2.0. I'm also using the Primefaces component library. I'm having a problem with the p:confirmDialog of Primefaces. As soon as I want to show a p:confirmDialog, it disappears again almost instantly. The weirdest thing is that this problem only occurs with the application that is deployed on the GlassFish Server at work. When I upload the very same .war file to the GlassFish server on my computer at home or when I run the application in Netbeans this problem does not occur. I really can't find out what the cause of this problem is. Also I couldn't find any information about this on Google. Any help would be greatly appreciated! This is my code:
<h:commandButton value="Verwijderen" onclick="bezoekConfirmation.show()" styleClass="verwijderKnopBig" rendered="#{pageRenderController.canWriteBezoekenMobiele}" />
<p:confirmDialog message="Bent u zeker dat u dit bezoek wilt verwijderen?" closable="false"
header="Bezoek verwijderen" severity="alert" widgetVar="bezoekConfirmation">
<p:commandButton value="Ja" oncomplete="bezoekConfirmation.hide()" action="#{bezoekenMobieleController.deleteBezoek}" ajax="false" />
<p:commandButton value="Nee" onclick="bezoekConfirmation.hide()" type="button" />
</p:confirmDialog>
Clicking on the button will cause a submit. The dialog appears, and the page is reloaded immediately.
Change this:
bezoekConfirmation.show()
to this:
bezoekConfirmation.show(); return false;
It's really strange that your version works on your computer at home.
The solution with return false; will only work if you do not intend to call a method or set a variable.
In this case, just use oncomplete="dialog.show();" instead of onclick="dialog.show();"
This will pass through the method call.
Example:
Given that the following code is in some kind of data table then you can have
<p:commandButton value="edit" update=":dialog" oncomplete="dialog.show();">
<f:setPropertyActionListener target="#{bean.field}" value="#{_item}" />
</p:commandButton>
or call the setter directly
<p:commandButton value="edit" update=":dialog" oncomplete="dialog.show();" action="bean.setField(_item)">
</p:commandButton>
<h:commandButton value="Verwijderen" onclick="bezoekConfirmation.show()" styleClass="verwijderKnopBig" rendered="#{pageRenderController.canWriteBezoekenMobiele}" />
<p:confirmDialog message="Bent u zeker dat u dit bezoek wilt verwijderen?" closable="false"
header="Bezoek verwijderen" severity="alert" widgetVar="bezoekConfirmation" appendToBody="true">
<p:commandButton value="Ja" oncomplete="bezoekConfirmation.hide()" action="#{bezoekenMobieleController.deleteBezoek}" ajax="false" />
<p:commandButton value="Nee" onclick="bezoekConfirmation.hide()" type="button" />
</p:confirmDialog>
appendToBody="true" will overcome your problem

setting f:validatelength dynamically does not work

When I use a bean to set the min and max values on f:validatelength it simply does not work. It breaks the functionality in the form so it can't be submitted...
When I outputtext the values they do come out as legit numbers and hardcoding those numbers work fine.
My guess it that it somehow lacks the required connection to beans at that time in the lifecycle or something? (I'm pretty much a beginner). Example below is example of what I want to do
<h:inputSecret id="password" value="#{userBean.user.password}">
<f:validateLength minimum="#{myBean.minSize}" maximum="#{myBean.maxSize}" />
</h:inputSecret>
<h:message for="password" />
I tried using < a4j:keepAlive > on the bean but I couldn't get that to work.
I am using JSF 1.2 with Richfaces 3.3.3 and Seam 2.
Hopefully someone has a clue here. And a good way to achieve this using another tag then that's fine as well! Thanks for reading.
Is the el expression evaluated to integer type?
I have no idea, but you can try a couple of these variations
<h:inputSecret id="password" value="#{userBean.user.password}" maxlength="#{myBean.maxSize}">
<f:validateLength minimum="#{myBean.minSize}"/>
</h:inputSecret>
<h:message for="password" />
<h:inputSecret id="password" value="#{userBean.user.password}" maxlength="#{myBean.maxSize}">
<f:validator validatorId="javax.faces.validator.LengthValidator">
<f:attribute name="minimum" value="#{myBean.minSize}"/>
</f:validator>
</h:inputSecret>
<h:message for="password" />

Resources