Problem with h: form and p: ajax (Mojarra 2.0.2 and Primefaces 2.0.2)

I have this site:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<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:p="http://primefaces.prime.com.tr/ui">

<h:head></h:head>
<h:body>


    <h:form id="form-some">
        <h:inputText id="copingFilePhaseFocus">
            <p:ajax event="focus" actionListener="#{installationController.startCopyingWarFile}" />
        </h:inputText>
    </h:form>


</h:body>
</html>

And bean support:

@ManagedBean(name = "installationController")
@SessionScoped
public class InstallationController implements IPluginInstallationListener {

    // Some methods here (...)

    public void startCopyingWarFile(ActionEvent event) {
        System.out.println("\n\n\n\nStarted\n\n\n\n");
    }
}

This code worked in MyFaces 2.0.0. But in MyFaces 2.0.2 or Mojarra 2.0.2 not. Saying "does not work", I mean that clicking (focusing) the input text does not start the actionListener (the text "Started" does not appear on the standard output). Does anyone have a similar problem?

EDIT 1 (After changing p: ajax to f: ajax):

    <p:outputPanel id="copingFilePhase">
        <p:accordionPanel speed="0.2"
            rendered="#{pluginInstallerWebBean.copingFilePhase}">
            <p:tab
                title="#{msg['installPlugin.copyingWar']} ... #{pluginInstallerWebBean.copingFilePhaseState}">
                <h:form prependId="false">
                    <p:focus for="copingFilePhaseFocus" />
                    <h:inputText id="copingFilePhaseFocus"
                        rendered="#{pluginInstallerWebBean.copingFilePhaseFocus}"
                        style="display:none;">
                        <f:ajax event="focus"
                            render="copingFilePhase obtainingPluginInformationPhase"
                            listener="#{installationController.startCopyingWarFile}" />
                    </h:inputText>
                </h:form>
                #{msg['installPlugin.copyingWarDescription']}
            </p:tab>
        </p:accordionPanel>
    </p:outputPanel>

    <p:outputPanel id="obtainingPluginInformationPhase">(...)</p:outputPanel>

And the error:

javax.faces.FacesException: contains an unknown identifier 'copingFilePhase' - cannot find it in the context of the copingFilePhaseFocus component

+1
source share
1 answer

This may have two reasons:

  • Primefaces , , JavaScripts . , JS - JS . Firefox Ctrl + Shift + J.

    Servlet 3.0 (Glassfish v3, Tomcat 7, JBoss 6 ..), web.xml:

    <servlet>
        <servlet-name>PrimeFaces Resource Servlet</servlet-name>
        <servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>PrimeFaces Resource Servlet</servlet-name>
        <url-pattern>/primefaces_resource/*</url-pattern>
    </servlet-mapping>
    
  • . , javax.el.MethodNotFoundException . , ActionEvent. java.awt.event. , () . , javax.faces.event.ActionEvent, - .

, PrimeFaces p:ajax JSF 2.0 f:ajax:

<f:ajax event="focus" listener="#{installationController.startCopyingWarFile}" />

public void startCopyingWarFile(AjaxBehaviorEvent event) {
    // ...
}

AjaxBehaviorEvent - javax.faces.event.AjaxBehaviorEvent.

+4

Source: https://habr.com/ru/post/1778091/


All Articles