[richfaces-issues] [JBoss JIRA] Commented: (RF-10940) Client side validation refers to non existing javascript function

Mano Swerts (JIRA) jira-events at lists.jboss.org
Thu Jul 7 06:15:24 EDT 2011


    [ https://issues.jboss.org/browse/RF-10940?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612824#comment-12612824 ] 

Mano Swerts commented on RF-10940:
----------------------------------

Hi all,

Like my colleague stated in his last comment, this issue seems to be fixed only for validations not using an ajax request. When the generated validation function uses an ajax request to validate, the issue remains.

My colleague noted that setting the "required" attribute to "true" uses ajax validation, so we worked around the problem by using @NotNull instead. However, when working with java.util.Date objects on the backing bean, ajax validation is always used. Also when using @NotNull. Because we cannot work around this issue with Date objects, this issue is starting to be blocking for us. This issue raises JavaScript errors, prevents our validation to be executed correctly and it even prevents rich:calendar components to close automatically when selecting a date (due to the JavaScript error).

We already use the 4.1-SNAPSHOT builds in our code due to several bugfixes in those builds, so we are hoping that the fix for this issue will make it's way to the trunk of 4.1 soon. Here is an example XHTML page and bean implementation for producing the issue:

{code}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a="http://richfaces.org/a4j"
	xmlns:sec="http://www.springframework.org/security/facelets/tags"
	xmlns:rich="http://richfaces.org/rich">

	<f:view>
		<h:head>
			<title>Calendar Validation Test</title>
		</h:head>
		
		<h:body>
			<h:form>
			<h:outputLabel value="Start date" for="#{startDate}" />
				<rich:calendar id="startDate" value="#{calendarTestBean.startDate}">
					<rich:validator />
				</rich:calendar>

				<h:outputLabel value="End date" for="#{endDate}" />
				
				<a:outputPanel id="endDatePanel">
					<rich:calendar id="endDate" value="#{calendarTestBean.endDate}">
						<rich:validator />
					</rich:calendar>
				</a:outputPanel>
		
				<a:commandButton value="Rerender end date" render="endDatePanel" />
				</h:form>
		</h:body>
	</f:view>
</html>
{code}

{code}
package be.idewe.riscpro.ui;

import java.util.Date;

import javax.validation.constraints.NotNull;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

@Controller
@Scope("request")
public class CalendarTestBean {
	@NotNull
	private Date startDate;
	@NotNull
	private Date endDate;

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
}
{code}

The error message is as follows:

{code}
calendarTest.faces:5Uncaught ReferenceError: j_idt41_3AendDate_3Av is not defined
RichFaces.ui.Calendar.onchangecalendarTest.faces:5
$.extend.invokeEventrichfaces-base-component.js.faces:278
$.extend.setInputFieldcalendar.js.faces:1011
$.extend.__selectDatecalendar.js.faces:1633
$.extend.eventCellOnClickcalendar.js.faces:1084
(anonymous function)
{code}

Can we be kept up to date regarding the process? Thank you.

Kind regards,

Mano Swerts


> Client side validation refers to non existing javascript function
> -----------------------------------------------------------------
>
>                 Key: RF-10940
>                 URL: https://issues.jboss.org/browse/RF-10940
>             Project: RichFaces
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: component-validators
>    Affects Versions: 4.0.0.Final
>            Reporter: Niels Soeffers
>            Assignee: Lukáš Fryč
>            Priority: Critical
>              Labels: tran
>             Fix For: 4.1.0.Milestone1
>
>
> Client Side Javascript functions are called on the component tags (for example onChange attribute) and defined at the bottom of the rendered page. We encountered a case where the function called in the onchange attribute is not defined at the bottom of the page.
> Our domain layer contains two different classes RG and SRG (they do not inherit from each other). However they both embed an embeddable class E with a field "name"
> In the GUI we have a page with a single form and two regions. One for adding a RG object and one for adding a SRG object. Both regions contain a h:inputText for the "name" field. So the first inputText is bound to {{RG.embedded.name}} and the second on {{SRG.embedded.name}}. Both inputTexts have a rich:validator tag as a child component.
> When the page is initially rendered both h:inputText have the same javascript function referred to in their onchange attribute (RGName_3Av). 
> Which is not wrong because the validation (@NotNull on the "name" field in the Embedded class) is the same for both value bindings. It is a little bit confusing to see a method with a name of RGName_3Av on a component that is actually bound to SRG and so we would expect the method to call SRGName_3Av, but it's certainly not wrong and I even find it a very nice optimization.
> However when we click on an a:commandButton in the second region and rerender this second region, then suddenly the javascript function in the onchange attribute of the second inputText is changed and the name refers to the SRG component (SRGName_3Av), but this javascript method is never defined, because it was optimized when we initially rendered the complete page.
> Hope you can reproduce the problem with the above description and fix the problem or provide a workaround?
> Kind Regards,
> Niels

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the richfaces-issues mailing list