New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skipValidators not working when using with primeface commandbutton #460

Closed
Supot opened this Issue Apr 19, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@Supot

Supot commented Apr 19, 2018

Hi,
I'm using omnifaces-2.2 with Primefaces 6.x <o:skipValidators /> is working, But when update to omnifaces-2.6.8 and Primefaces 6.2 <o:skipValidators /> not working.
I'm trying to view source of skipValidators the difference in

  1. hasInvokedSubmit in 2.6.8
    public static boolean hasInvokedSubmit(UIComponent component) {
    UIComponent source = getCurrentActionSource();
    return source != null && source.equals(component);
    }
    public static UIComponent getCurrentActionSource() {
    FacesContext context = FacesContext.getCurrentInstance();

     if (!context.isPostback()) {
     	return null;
     }
    
     UIViewRoot viewRoot = context.getViewRoot();
     Map<String, String> params = context.getExternalContext().getRequestParameterMap();
    
     if (context.getPartialViewContext().isAjaxRequest()) {
     	String sourceClientId = params.get("javax.faces.source");
    
     	if (sourceClientId != null) {
     		UIComponent actionSource = findComponentIgnoringIAE(viewRoot, stripIterationIndexFromClientId(sourceClientId));
    
     		if (actionSource != null) {
     			return actionSource;
     		}
     	}
     }
    
     for (String name : params.keySet()) {
     	if (name.startsWith("javax.faces.")) {
     		continue; // Quick skip.
     	}
    
     	UIComponent actionSource = findComponentIgnoringIAE(viewRoot, stripIterationIndexFromClientId(name));
    
     	if (actionSource instanceof UICommand) {
     		return actionSource;
     	}
     }
    
     return null;
    

    }

  2. hasInvokedSubmit in 2.2
    public static boolean hasInvokedSubmit(UIComponent component) {
    FacesContext context = FacesContext.getCurrentInstance();

     if (!context.isPostback()) {
     	return false;
     }
    
     String clientId = stripIterationIndexFromClientId(component.getClientId(context));
     Map<String, String> params = context.getExternalContext().getRequestParameterMap();
    
     if (context.getPartialViewContext().isAjaxRequest()) {
     	String source = params.get("javax.faces.source");
    
     	if (source != null) {
     		return clientId.equals(stripIterationIndexFromClientId(source));
     	}
     }
    
     if (component instanceof UICommand) {
     	for (String name : params.keySet()) {
     		if (name.startsWith("javax.faces.")) {
     			continue; // Quick skip.
     		}
    
     		if (clientId.equals(stripIterationIndexFromClientId(name))) {
     			return true;
     		}
     	}
     }
    
     return false;
    

    }

Thanks

@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC Apr 21, 2018

Member

But when update to omnifaces-2.6.8 and Primefaces 6.2 <o:skipValidators /> not working.

I cannot reproduce your problem. Below SSCCE works just fine for me.

<h:form>
    <p:inputText required="true" />
    <p:commandButton value="submit" update="@form">
        <o:skipValidators />
    </p:commandButton>
    <p:messages />
</h:form>

Please provide a reproducer.

Member

BalusC commented Apr 21, 2018

But when update to omnifaces-2.6.8 and Primefaces 6.2 <o:skipValidators /> not working.

I cannot reproduce your problem. Below SSCCE works just fine for me.

<h:form>
    <p:inputText required="true" />
    <p:commandButton value="submit" update="@form">
        <o:skipValidators />
    </p:commandButton>
    <p:messages />
</h:form>

Please provide a reproducer.

@Supot

This comment has been minimized.

Show comment
Hide comment
@Supot

Supot Apr 21, 2018

Hi Balusc,
I have the application develop by Primefaces 6.1 and using omnifaces version 2.2, in this application developer using many tag of <o:skipValidators /> and is working fine.
But in last weekend developer team want to migrate this application to omnifaces version 2.6.8 and Primefaces 6.2, After migration the page of using tag <o:skipValidators /> is not working.

I'm trying to create normal jsf application with Primefaces 6.2 and omnifaces-2.6.8 and create sample page like this

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" 
	xmlns:o="http://omnifaces.org/ui">
<h:head>
</h:head>
<h:body>
	<h:form id="sysForm" prependId="false">
		<h:panelGrid>
			<h:outputText value="Firt Name" />
			<p:inputText label="Firt Name" required="true" />
			
			<h:outputText value="Last Name" />
			<p:inputText label="Lat Name" required="true" />
			<p:messages />
		</h:panelGrid>
		
		<p:commandButton value="Not Skip" update="@form">
		</p:commandButton>
		<p:commandButton value="Skip" update="@form">
			<o:skipValidators />
		</p:commandButton>
	</h:form>
</h:body>
</html>

But <o:skipValidators /> not woking.
Environment

  1. JSF 2.2.8
  2. Primefaces 6.2
  3. omnifaces-2.6.8
  4. Run on Tomcate 8.x

DemoJSF.zip

Supot commented Apr 21, 2018

Hi Balusc,
I have the application develop by Primefaces 6.1 and using omnifaces version 2.2, in this application developer using many tag of <o:skipValidators /> and is working fine.
But in last weekend developer team want to migrate this application to omnifaces version 2.6.8 and Primefaces 6.2, After migration the page of using tag <o:skipValidators /> is not working.

I'm trying to create normal jsf application with Primefaces 6.2 and omnifaces-2.6.8 and create sample page like this

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" 
	xmlns:o="http://omnifaces.org/ui">
<h:head>
</h:head>
<h:body>
	<h:form id="sysForm" prependId="false">
		<h:panelGrid>
			<h:outputText value="Firt Name" />
			<p:inputText label="Firt Name" required="true" />
			
			<h:outputText value="Last Name" />
			<p:inputText label="Lat Name" required="true" />
			<p:messages />
		</h:panelGrid>
		
		<p:commandButton value="Not Skip" update="@form">
		</p:commandButton>
		<p:commandButton value="Skip" update="@form">
			<o:skipValidators />
		</p:commandButton>
	</h:form>
</h:body>
</html>

But <o:skipValidators /> not woking.
Environment

  1. JSF 2.2.8
  2. Primefaces 6.2
  3. omnifaces-2.6.8
  4. Run on Tomcate 8.x

DemoJSF.zip

@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC Apr 21, 2018

Member

The prependId="false" is the cause of the problem.

Why do you need this? This is a bad practice and leftover of a wrong solution to a JSF 1.2 specific problem.

Member

BalusC commented Apr 21, 2018

The prependId="false" is the cause of the problem.

Why do you need this? This is a bad practice and leftover of a wrong solution to a JSF 1.2 specific problem.

@Supot

This comment has been minimized.

Show comment
Hide comment
@Supot

Supot Apr 22, 2018

Hi BalusC,
Thank you, The problem is solved. I'm not sure why team using prependId="false"

Supot commented Apr 22, 2018

Hi BalusC,
Thank you, The problem is solved. I'm not sure why team using prependId="false"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment