I work with JSF, RichCalendar and a4j. My problem: I want to rerender components of my website but if someone edits the date of one rich-calendar input field to '12.aa.2012' a FacesMessage is thrown, which is correct and good. Anyway my a4j-rerender-event did not get triggered due to unhandeld facesMessages. On my Tomcat-Console I get this errorMessage:
WARNUNG: There are some unhandled FacesMessages, this means not every FacesMessage had a chance to be rendered.
These unhandled FacesMessages are:
- Bitte ein gültiges Datum eingeben!
How can I handle this problem, I tried several ways to show the errorMessage and I can figure out how to show it, but there is still the warning and still the not triggered-rerender-event?
Thanks in advance.
UPDATE: here is the code to my question. As you can see after you select one of the radio buttons, one dateContainer will show up, for example 'admissionDateContainer'. If you change the value to 'asd', and select another choice, no rerendering of the related box happens, the choice will change but the wrong dateContainer will stay there ?!
<h:panelGroup layout="block" id="caseTypeContainer" rendered="#{CaseController.isFallContainer}" styleClass="fieldContainer">
<t:outputLabel for="caseType" styleClass="generalInputLabel" style="width:200px; float:left;" value="#{resources.labels['caseType']}:" title="#{resources.labels['caseType']}" />
<h:selectOneRadio id="caseType" style="font-size:13px;" value="#{CaseController.caseType}" styleClass="radioButtonTableMasterdata inlineBlock">
<f:selectItem itemValue="#{resources.labels['caseTypeDocAttrStationaer']}" itemLabel="#{resources.labels['caseTypeDocAttrStationaerLabel']}" />
<f:selectItem itemValue="#{resources.labels['caseTypeDocAttrAmbulant']}" itemLabel="#{resources.labels['caseTypeDocAttrAmbulant']}"/>
<f:selectItem itemValue="#{resources.labels['caseTypeDocAttrUnbekannt']}" itemLabel="#{resources.labels['caseTypeDocAttrUnbekannt']}"/>
<a4j:support oncomplete="initializeFocusBlurEvents(); " event="onchange" reRender="captureDateContainerDiv, admissionDateContainerDiv, dischargeDateContainerDiv, messagesContainer, warnings"/>
</h:selectOneRadio>
</h:panelGroup>
<t:div id="admissionDateContainerDiv">
<h:panelGroup layout="block" id="admissionDateContainer" rendered="#{CaseController.isCaseTypeStationaerOrAmbulant}" styleClass="fieldContainer showDateInputWithTime">
<t:outputLabel for="admissionDate" rendered="#{CaseController.isCaseTypeStationaer}" styleClass="generalInputLabel" style="width:200px;" value="#{resources.labels['caseAdmissionDateStationaer']}:" title="#{resources.labels['caseAdmissionDateStationaer']}" />
<t:outputLabel for="admissionDate" rendered="#{CaseController.isCaseTypeAmbulant}" styleClass="generalInputLabel" style="width:200px;" value="#{resources.labels['caseAdmissionDateAmbulant']}:" title="#{resources.labels['caseAdmissionDateAmbulant']}" />
<rich:calendar id="admissionDate" value="#{CaseController.caseContainerAdmissionDate}" datePattern="dd.MM.yyyy HH:mm" enableManualInput="true" direction="auto">
<f:facet name="footer">
<h:panelGrid columns="3" width="100%" columnClasses="fake, width100 talign">
<h:outputText value="{selectedDateControl}" style="font-weight:bold;" />
<h:outputText value="{timeControl}" style="font-weight:bold;" />
<h:outputText value="{todayControl}" style="font-weight:bold;" />
</h:panelGrid>
</f:facet>
</rich:calendar>
<rich:message for="admissionDate" />
</h:panelGroup>
</t:div>
<t:div id="messagesContainer" rendered="true">
<p>Messages global</p>
<rich:messages global="true" />
</t:div>
Add <rich:messages or <rich:message to your page
Take a look at rich:messages and rich:message
Also make sure that they are being rendered after your button is being clicked... add their ids or their wrapper (#form for example) ids to the reRender of your calendar
Related
I have a problem with the JSF validation. I have the following form - only the first inputfield is required. So if I leave them empty and click on the primefaces calendar field - JSF render the whole form and of course I got a message that the field is required.
So I need a solutions that the field only call the blur event or required message when I leave the field not when I click another field etc.
<h:form>
<p:growl id="msg" showDetail="true" />
<b:panelGrid col-spans="4,8" columns="2" id="inputPanel">
<h:outputLabel value="ID*"></h:outputLabel>
<b:inputText value="#{managedBean.avsId}" required="true"
update="msg" onblur="ajax:managedBean.checkDublicates()"></b:inputText>
<h:outputLabel value="Legal Form"></h:outputLabel>
<b:switch animate="true" on-text="natural" offColor="danger"
onColor="success" off-text="forensic"
value="#{managedBean.legalform}">
</b:switch>
<h:outputLabel value="Date"></h:outputLabel>
<p:calendar value="#{managedBean.date}" pattern="dd.MM.yyyy">
<f:converter converterId="timestampConverter" />
</p:calendar>
<h:outputLabel value="Note" style="margin-top:5%;"></h:outputLabel>
<b:inputTextarea style="margin-top:5%;"
value="#{managedBean.note}"></b:inputTextarea>
</b:panelGrid>
<b:commandButton value="apply" look="success"
style="width:100%;" action="#{managedBean.create()}"
update="#form" />
</h:form>
if i want to show the selected elements in the datalist when i click on 'übernehmen' commandbutton, the List from the ManagedBean is empty, but i dont know why. My Converter works fine. No error from my console is show. All elements are in the same form.
Thanks
<p:selectManyMenu id="standard"
value="#{hauptBean.standardSelektion}" converter="konverter"
var="t" filter="true" filterMatchMode="contains"
showCheckbox="true">
<f:selectItems value="#{hauptBean.vorbelegt}" var="risk" itemLabel="#{risk.risikobereich}" itemValue="#{risk}" />
<p:column>
<h:outputText value="#{t.risikobereich}" />
</p:column>
</p:selectManyMenu>
<p:commandButton value="übernehmen" update="ge" icon="ui-icon-check"/>
<h:outputText value="gewählt" styleClass="fetterText" />
<h:panelGroup />
<h:panelGroup id="ge">
<p:dataList value="#{hauptBean.standardSelektion}" var="t">
<h:outputText value="#{t}" />
</p:dataList>
</h:panelGroup>
By default, when you click the commandButton, the p:selectManyMenu will not be processed and update its selected value to the ManagedBean. To change this behaviour you can add attribute process="standard" to your p:commandButton
I have a rich:modal panel (code below). I want to pass the #{currentLeg} to the method called in action="#{legHandler.assignAndInitLoadPlanning}. But when I debug, at the method legHandler.assignAndInitLoadPlanning, resolveVariable("currentLeg"); returns an object with all its attribute values equal to null. It's attributes should not be null.
Additionally, this rich:modal is called from an a4j:commandLink onclick="showUnitDialog(); on the same jsp file. If I change this said onclick to onclick="#{legHandler.assignAndInitLoadPlanning}" the currentleg will be passed properly but i cannot do this because i need to have a popup (which is a rich:modalpanel) to display. And I am using JSF 1.
I've already tried keep alive and set variable but still not works. It seems that the currentLeg is not properly passed. Do you have any idea why?
<rich:modalPanel id="unitDialog" width="400" height="100">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="Please Select Unit for the Leg"></h:outputText>
<h:outputText value="#{currentLeg.legId}"></h:outputText>
</h:panelGroup>
</f:facet>
<h:panelGrid width="100%" columns="2" columnClasses="colStyle1, colStyle2">
<h:selectOneRadio value="legHandler.unit">
<f:selectItem itemValue="kg" itemLabel="kg" />
<f:selectItem itemValue="lb" itemLabel="lb" />
</h:selectOneRadio>
</h:panelGrid>
<h:panelGrid style="text-align: center" columns="3"
columnClasses="col1, col2" width="100%">
<a4j:commandButton value="Apply" styleClass="big_btn"
id="applyButton" immediate="true"
action="#{legHandler.assignAndInitLoadPlanning}"
oncomplete="{#{rich:component('unitDialog')}.hide();}">
</a4j:commandButton>
<a4j:commandButton value="Cancel" styleClass="big_btn"
immediate="true"
id="closeUnitPopupDialog"
onclick="#{rich:component('unitDialog')}.hide();"/>
</h:panelGrid>
</rich:modalPanel>
If you're using EL 2.2+ you can simply pass the value as parameter:
<a4j:commandButton action="#{legHandler.assignAndInitLoadPlanning(currentLeg)}" … />
Otherwise use a4j:actionparam and save the value to the bean
<a4j:commandButton …>
<a4j:actionparam name="currentLeg" value="#{currentLeg}" assignTo="#{legHandler.currentLeg}" />
<a4j:commandButton>
when i click on the command button. validate method is getting called but the error message is not getting displayed..
here is my code..
<h:form id="form">
<h:body>
<p:panel style="width:500px">
<h:outputLabel for="year" value="Select Year: *" style="font-weight:bold" />
<p:selectOneMenu id="year" value="#{leaveBean.year}">
<f:selectItem itemLabel="Select One" itemValue="null" />
<f:selectItems value="#{leaveBean.yearDTO}" var="currentUser" itemValue="#{currentUser.name}" itemLabel="#{currentUser.name}" />
<f:validator validatorId="LeaveCardValidator" />
</p:selectOneMenu>
</p:panel>
<p:commandButton value="Submit" action="#{leaveController.leaveCard}" update="updateList,updateDetails" id="button"/>
<h:message for="year" style="color:red"/>
You seem to expect that JSF auto-updates the <h:message> on every ajax request. This is untrue. Perhaps you're confusing with PrimeFaces <p:messages> or <p:growl> which have each an autoUpdate attribute which enables you to tell them to auto-update themselves on every ajax request.
You really need to make sure that the <h:message> is covered by the ajax update. Just give it an ID
<h:message id="yearMessage" ... />
and include it in the client ID collection of the ajax update
<p:commandButton ... update="updateList updateDetails yearMessage" />
An alternative would be to replace <h:message> by <p:messages autoUpdate="true">.
Not sure where are the updateList and updateDetails are located but in the example give above you should use update="#form" instead or in addtion like this:
update="updateList updateDetails #form"
so that the form will be rendered again...
just use one of these :
update the whole form in order to update the content of
<h:message />
<p:commandButton value="Submit" action="#{leaveController.leaveCard}" update="#form" id="button"/>
or give the <h:message /> an id and id this id to the <p:commandButton/>
<h:message id="msg" for="year" style="color:red"/>
<p:commandButton value="Submit" action="#{leaveController.leaveCard}" update="updateList,updateDetails,msg" id="button"/>
I have bean struggling to understand how to use the rich:popupPanel component in the right way. There are (at least not that I could find) few post about how to use the rich:popupPanel and how to submit values from it.
To make matter worse the panel seams to add (when checking the html) a hard coded "_content" to its component id name (to the div generated). I have tried to use aj4:region tag to partial render the complete form. But that didn't seamed to work, cause nothing where posted to managed bean. So now I have one option left, where the panel has its own form, outside the main one on the page.
I can see that the evaluation of the form (popup) values is happening, but not the execution of the bean function that persist the values (I see the POST request of the command button). The only reason I can think of at the moment, is that the pop-up panel use another bean to persist the values that the main form on the page (both of them are session scoped).
I am thinking of omit the pop-up panel all together, since it seams so hard to make this work. Maybe its a well know secret, since it so few post about it. It behaves the same if if use componentController or only a a4j:commanLink.
How is it possible to submit values from a rich:popupPanel and invoke a backing bean function to persist the pop-up form values ?
Appreciate if someone can shed some light on this, greetings Chris.
I use Richfaces 4.0-final on Glassfish 3.1
<h:form id="main_form">
<!-- Command for popup -->
<a4j:commandLink actionListener="#{userController.prepareCreateSysRequest}" oncomplete="#{rich:component('popup_sys_user_req_form:popup_sys_user_req')}.show(); return false;"
execute="#this" value="Request New Sector/Category" />
...
<a4j:commandButton action="#{projectController.Create}" ...>
</h:form>
<h:form id="popup_sys_user_req_form">
<rich:popupPanel id="popup_sys_user_req" modal="true" autosized="true" resizeable="false">
<f:facet name="header">
<h:outputText value="New Project Request" />
</f:facet>
<f:facet name="controls">
<h:outputLink value="#"
onclick="#{rich:component('popup_sys_user_req')}.hide(); return false;">
X
</h:outputLink>
</f:facet>
<h:panelGrid columns="2">
<h:outputLabel value="Request New:" />
<h:selectOneMenu id="sys_req_type" value="#{userController.selectedSysRequestType}" required="true" requiredMessage="Request Type is required" title="Request Type">
<f:selectItems value="#{userController.getSysRequestTypeItems()}">
</f:selectItems>
</h:selectOneMenu>
<h:outputLabel value="Description:" />
<h:inputTextarea id="user_req_desc" value="#{userController.selectedSysUserRequest.description}" required="true" requiredMessage="Decription is missing" />
</h:panelGrid>
<a4j:commandButton action="#{userController.CreateSysUserRequest}" onclick="#{rich:component('popup_sys_user_req')}.hide(); return false;" execute="#form" render="popup_sys_user_req_form" value="Send Request" />
</rich:popupPanel>
</h:form>
For what I have done I used to have the issue to got to submit twice only the first time.
To fix it the form got to be outside the popupPane. And also that the popupPanel should have the attibute domElementAttachment="form".
Example.
<h:form>
<rich:popupPanel id="shipmentItemUpdateDialog"
autosized="true"
domElementAttachment="form">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="#{shipmentBundle.shipmentItemDetailsHeader}" />
</h:panelGroup>
</f:facet>
<f:facet name="controls">
<h:commandLink>
<h:graphicImage value="/core/images/modal/close.png"/>
<rich:componentControl target="shipmentItemUpdateDialog" operation="hide" />
</h:commandLink>
</f:facet>
<h:outputText for="shipmentItemName"
value="#{coreBundle.requiredChar} #{shipmentBundle.shipmentItemName}"
/>
<h:inputText id="shipmentItemName"
disabled ="false"
required ="true"
value="#{shipmentItemController.shipmentItemUI.value.name}"
label="#{shipmentBundle.shipmentItemName}"
size="40" >
</h:inputText>
<h:outputText for="shipmentItemCode"
value="#{coreBundle.requiredChar} #{shipmentBundle.shipmentItemCode}"
/>
<h:inputText id="shipmentItemCode"
disabled ="false"
required ="true"
value="#{shipmentItemController.shipmentItemUI.value.code}"
label="#{shipmentBundle.shipmentItemCode}"
size="40" >
</h:inputText>
<h:outputText value="#{coreBundle.requiredChar} #{shipmentBundle.shipmentItemAmount}"
/>
<h:inputText id="shipmentItemAmount"
disabled ="false"
required ="true"
value="#{shipmentItemController.shipmentItemUI.value.amount}"
label="#{shipmentBundle.shipmentItemAmount}"
size="4" >
<f:validateLongRange minimum="1"/>
</h:inputText>
<h:outputText value="#{coreBundle.requiredChar} #{shipmentBundle.shipmentItemNeedsCooling}"
/>
<h:selectBooleanCheckbox id="shipmentItemNeedsCooling"
disabled ="false"
required ="true"
value="#{shipmentItemController.shipmentItemUI.value.needsCooling}"
label="#{shipmentBundle.shipmentItemNeedsCooling}"
/>
<h:outputText for="shipmentItemDetails"
value="#{shipmentBundle.shipmentItemDetails}"
/>
<h:inputTextarea id="shipmentItemDetails"
disabled ="false"
required ="true"
value="#{shipmentItemController.shipmentItemUI.value.details}"
label="#{shipmentBundle.shipmentItemDetails}"
cols="38"
rows="5"
/>
</h:panelGrid>
<h:panelGrid columns="1" dir="LTR">
<h:panelGrid columns="2" dir="LTR">
<a4j:commandButton value="#{coreBundle.acceptButton}"
action="#{shipmentItemController.onUpdate()}"
render="shipmentItemsTable">
</a4j:commandButton>
<h:commandLink value="#{coreBundle.closeLink}"
immediate="true">
<rich:componentControl target="shipmentItemUpdateDialog" operation="hide" />
</h:commandLink>
</h:panelGrid>
<h:outputText value="#{coreBundle.requiredText}"/>
</h:panelGrid>
</rich:popupPanel>
</h:form>
I hope this helps.
I think you got it right.. think of the pop-up as a regular page. To submit and close the pop-up, do something like this:
<a4j:commandButton value="Save" onclick="#{rich:component('panelId}.hide();" render="..."/>
Hope this helps..