JSF2.0+RichFaces3.3.3 suggestionBox inside a modalPanel - jsf

Following this example http://livedemo.exadel.com/richfaces-demo/richfaces/dataTable.jsf?tab=editDataTable&cid=101317 I created a modal panel used for editing an entry. The difference is that one of my inputText fields has a suggestion box:
<h:inputText id="entryName" value="#{controller.currentItem.name}" validator="#{controller.entryNameValidator}"/>
<rich:suggestionbox id="suggestionBoxId" for="entryName" suggestionAction="#{controller.autocomplete}" var="result">
<h:column>
<h:outputText value="#{result.name}" />
</h:column>
</rich:suggestionbox>
<rich:message for="entryName"/>
The problem is that when the modal appears and I change a single letter in the "entryName" the suggestion takes place, but when it finds no suggestions it reverts the changed value (the one without the letter i just deleted) to the original value (the one before deleting). If on the other hand it finds some suggestions it still reverts the value to the old one but also prints the suggestions in the modal right below "entryName" (and not in a suggestion box, it's just grey text). Also the suggestion triggers only once. If I lets say change "hello" to "hell" it reverts back to "hello" and the next time i try to modify it to "hell" nothing happens.
What am I doing wrong? Oh also I'm using the very exact same code in my jsf view when adding entries (it's not a modal though, just a table) and it works fine.
#Edit: apparently enclosing it with a "a4j:region" helps a bit as at least I'm able to see the suggestion box (but in the background, so I have to set the zindex) and in the left corner of the browser not below the "entryName" AND still I can't click it (it just sits there and doesn't disappear even after closing the modal), the suggestions still are printed below the inputText (not in a suggestionBox and in grey) and it still triggers only once...

try this modify the following stuff as per your requirement.
enter code here <h:panelGrid columns="2" cellpadding="0" cellspacing="0">
<h:inputText id="input" size="30"/>
<h:graphicImage value="#{facesContext.externalContext.requestContextPath}/../images/arrow.png"
onclick="#{rich:component('equity')}.callSuggestion(true)"
alt="click" />
</h:panelGrid>
<rich:suggestionbox width="200"
suggestionAction="#{StockMasterServiceBean.suggest}" var="stock" id="equity" for="input">
<h:column>
<h:outputText value="#{stock.symbolId}"/>
</h:column>
<h:column>
<h:outputText value="#{stock.companyName}" />
</h:column>
<a4j:support ajaxSingle="true" event="onselect" reRender="abc,xyz">
<f:setPropertyActionListener value="#{stock}" target="#{StockMasterServiceBean.selectedStockMaster}"/>
</a4j:support>
</rich:suggestionbox>

Related

use of cellEditor in facet not working primefaces

In a project, I have to merge two datatables (the first to set the header of the second and the second displaying the informations contained in an uploaded file) into one to simplify the legibility on the page.
Since the first datatable was using a cellEditor I tried using one in the merged one the following way for the header:
<f:facet name="header">
<p:cellEditor>
<f:facet name="output">
<h:outputLabel id="output" value="some text" />
</f:facet>
<f:facet name="input">
<p:selectOneMenu value="#{handler.selectItems}">
<!-- List of selectItems -->
<p:ajax event="change" update="output" />
</p:selectOneMenu>
</f:facet>
</p:cellEditor>
</f:facet>
But when I build the project and click on the header of my columns, I don't have any list of selectItems appearing to give me the possibility to change the header. It was used in <p:column> before without problem so I imagine the <f:facet> is the problem
I succesfully made the possibility to change the value of the header using <p:inplace> instead, but it doesn't behave exactly like I want.
I want that even if I don't modify the value when I click on the header (and make the list appears), I can click somewhere on the page and make the list disappear to have a "clean" header. I don't really want to use the editor="true" option of inplace because the goal is also to try to reduce the number of click needed for the user. I also made it a bit using <p:ajax event="blur" update="output" /> but some value of the list of selectItems make one or two inputText appear. And with that event, when I click in the text box, it closes the field automatically and I can only the value of the field once. After, the moment I click on the list to open it, it closes the field.
How can I fix that ?

ajax ReRender throws away the html tags for inputs that it re-renders

First of all I am new to AJAX and JSF so excuse my ignorance.
I am troubleshooting an issue on one of our existing applications.
Basically we want to rerender certain input fields if another has a value in it.
The code looks as follows
<rich:column valign="top" align="center">
<f:facet name="header">QTY Locos <br/>Staged</f:facet>
<h:inputText id="qtyLocos" value="#{dataItem.qtyLocosStaged}" width="80px" disabled="#{dataItem.rejected or !stagingDetailBean.editable}" styleClass="inputValidNumber">
<rich:jQuery selector="#qtyLocos" timing="onload" query="numeric" />
<a4j:support event="onchange" limitToList="true" reRender="facesMessagePanel, locoType, teleRequired, crewQualification" />
</h:inputText>
</rich:column>
<rich:column valign="top" styleClass="inputValid" id="locoType" align="center">
<f:facet name="header">Loco Type</f:facet>
<h:selectOneMenu value="#{dataItem.locoType}" disabled="#{dataItem.qtyLocosStaged eq 0 or dataItem.rejected or !stagingDetailBean.editable}">
<f:selectItem itemValue="" itemLabel="" />
<f:selectItem itemValue="6E" itemLabel="6E" />
<f:selectItem itemValue="6E1" itemLabel="6E1" />
<f:selectItem itemValue="7E" itemLabel="7E" />
</h:selectOneMenu>
</rich:column>
<rich:column valign="top" styleClass="center" id="teleRequired">
<f:facet name="header">Telemeter<br/>Required</f:facet>
<h:selectBooleanCheckbox value="#{dataItem.telemeterRequired}" disabled="#{dataItem.qtyLocosStaged eq 0 or dataItem.rejected or !stagingDetailBean.editable}"/>
</rich:column>
On certain browsers when you enter a value in the input field id=qtyLocos the drop down list and tick box becomes active as the criteria for disabled is now false.
But it happens in certain browsers that when you enter a value and the onchange event kicks in it physically removes the HTML tags for the drop down and the tick box. So my page renders completely incorrect.
Is anyone aware of issues with certain versions of chrome and ajax that could explain this behavior?
Some more info regarding this issue. The column headers dont disappear they are still visable. Just the inputs are missing, shifting all the fields after these fields to the left (and then not aligning with its column name anymore)
Ok this problem is getting weirder by the moment. This ONLY happens on machines that are on the company domain. Any machine that doesnt log onto the domain this does not happen. Can company policies influence how these things gets rendered?

What makes my richfaces combobox not working after first usage?

I'm currently using JSF 1.2, and Richfaces 3.3.3.
I get a quite strange bug with a combobox in a rich:datatable :
The first time I click and select a value, it's working, and via ajax:support, it updates the page as required. But then, if I try to change the value in the combobox, it seems "blocked"... field is not editable, and the arrow not "clickable". If I click on another field of the page, then come back, it usually works better (but not always).
Here is the code :
<rich:column style="border:none;" id="KitCol">
<f:facet name="header">
<h:outputText value="Kit"/>
</f:facet>
<rich:comboBox id="kit" value="#{deployItem.kit}"
directInputSuggestions="true" defaultLabel="Enter kit name >
<f:selectItems value="#{deployItem.kits}" />
<a4j:support event="onchange" action="#{deployItem.kitChanged}"
reRender="deployActions, deployTable">
<f:setPropertyActionListener value="true" target="#{deployController.atLeastOneItem}" />
</a4j:support>
</rich:comboBox>
</rich:column>
Would somebody have an idea about how to solve this issue ?
Thanks in advance.

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.

Trying to understand why h:commandLink submits through validation and a4j:commandLink doesn't

First of all, i'm using Jsf 1.2...
I have a problem with submitting some values in a form to validation.
Specifically this code segement:
<h:panelGrid columns="4" id="StatusPanel">
<h:outputText value="#{msg.Phone_number_to_send_SMS_to}" />
<h:inputText id="phoneNumber" value="#{general.smsPhoneNumber}" required="true"
requiredMessage="Please enter a valid phone number." />
<a4j:commandLink value="#{msg.Submit_Button}"
reRender="pinCodeDeliveryMsgText, pinCodeDeliveryMsg, pinCodeDeliveryFailedMsg, pinCodeDeliveryMainPanel, LastPinCodeMsg, SendingSMSMSG"
action="#{general.submit}" />
<h:message for="phoneNumber" fatalClass="mandatoryFieldMissing" errorClass="mandatoryFieldMissing" tooltip="true" />
</h:panelGrid>
Which looks like this in the html page:
Whenever I press the submit link, the page doesn't really go through validation, it seems to go with the last successull values instead. The result being that, if the phone number field is left empty, it does nothing and doesn't even render the <h:message> tag.
Actually, I have a workaround fix that looks like this:
<h:commandLink value="#{msg.Submit_Button}">
<a4j:support event="onclick" reRender="pinCodeDeliveryMsgText, pinCodeDeliveryMsg, pinCodeDeliveryFailedMsg, pinCodeDeliveryMainPanel, LastPinCodeMsg, SendingSMSMSG"
action="#{general.submit}"/>
</h:commandLink>
But i'm really curious to know what's the difference between a4j:commandLink and h:commandLink that makes one woirk and the other not.
TnX
Have you tried to set the process attribute of a4j:commandLink to the id of the inputText? Looks like you are just triggering rerendering of some components, so no model update is performed at all.

Resources