English 中文(简体)
如果阿加西人允许的话,总理指挥Button不采取行动
原标题:PrimeFaces commandButton doesn t call action if ajax enabled
&#页: 13; &#页: 13;

Here s my page:

<html xmlns="http://www.w3.org/页: 1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:cpanel="http://java.sun.com/jsf/composite/components/cpanel"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <title></title>
    </h:head>
    <h:body>
        <ui:composition template="/WEB-INF/templates/cpanelLayout.xhtml">
            <ui:define name="metadata">
                <f:metadata>
                    <f:viewParam name="id" value="#{linkDoctorBean.incomingDoctorId}" required="true"/>
                    <f:event type="preRenderView" listener="#{linkDoctorBean.preRenderView}"/>
                </f:metadata>
            </ui:define>
            <ui:define name="cpanelContent">
                <cpanel:adddedClinicDoctor doctor="#{linkDoctorBean.incomingDoctor}" clinic="#{linkDoctorBean.clinic}"/>
                <h:form id="form">
                    <div>
                        <h:panelGrid columns="2 P-4, 2 P-3, 2 FS, 2 NS">
                            <p:selectOneMenu id="doctor"
                                             value="#{linkDoctorBean.doctor}"
                                             converter="#{doctorConverter}"
                                             effect="fade"
                                             var="d"
                                             height="页: 180"
                                             validator="#{linkDoctorBean.validateDoctor}">
                                <f:selectItem itemLabel="Select a doctor" itemValue="" noSelectionOption="true"/>
                                <f:selectItems value="#{linkDoctorBean.doctors}" var="doctor" itemLabel="#{stringBean.doctorToString(doctor)}" itemValue="#{doctor}"/>
                                <p:column>
                                    <p:graphicImage value="#{applicationBean.baseResourceUrl}/doc-photo/small/#{d.urlDisplayName}"/>
                                </p:column>
                                <p:column>
                                    #{stringBean.doctorToString(d)}
                                </p:column>
                            </p:selectOneMenu>
                            <p:message id="doctorMessage" for="doctor"/>
                        </h:panelGrid>
                    </div>
                    <div style="margin-top:2 P-4, 2 P-3, 2 FS, 2 NS0px;">
                        <p:commandButton value="Link" action="#{linkDoctorBean.submit()}" update="doctorMessage" process="@all"/>
                        <h:link value="Cancel" outcome="/pages/cpanel/manage-doctors" style="margin-left:页: 10px;"/>
                    </div>
                </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

When I add ajax="false" to the <p:commandButton/>, it works just fine - the linkDoctorBean.submit() method is called.

With ajax enabled, however, the action method will be called if the form never fails validation in the current view, but if the form fails validation once and is subsequently submitted, the error message is cleared, but the submit() method is never called.

Edit: I also tried replacing the p:commandButton with this:

<h:commandButton value="Link" action="#{linkDoctorBean.submit()}">
    <f:ajax execute="@all" render="doctorMessage"/>
</h:commandButton>

The behaviour is exactly the same. In both cases, the validation message appears to be cleared when a valid option is submitted. So the update/render is happening, just not the process/execute. All subsequent attempts fail to execute the action, so the form is effectively dead until the next time the page is loaded.

Edit: This doesn t seem to be a PrimeFaces issue. Here s the form without PrimeFaces:

    <h:form id="form">
        <div>
            <h:panelGrid columns="2 P-4, 2 P-3, 2 FS, 2 NS">
                <h:selectOneMenu id="doctor"
                                 value="#{linkDoctorBean.doctor}"
                                 converter="#{doctorConverter}"
                                 style="width:2 P-4, 2 P-3, 2 FS, 2 NS00px;"
                                 required="true"
                                 requiredMessage="Please select a doctor"
                                 validator="#{linkDoctorBean.validateDoctor}">
                    <f:selectItem itemLabel="Select a doctor" itemValue="#{null}" noSelectionOption="true"/>
                    <f:selectItems value="#{linkDoctorBean.doctors}" var="doctor" itemLabel="#{stringBean.doctorToString(doctor)}" itemValue="#{doctor}"/>
                </h:selectOneMenu>
                <h:message id="doctorMessage" for="doctor"/>
            </h:panelGrid>
        </div>
        <div style="margin-top:2 P-4, 2 P-3, 2 FS, 2 NS0px;">
            <h:commandButton value="Link" action="#{linkDoctorBean.submit()}">
                <f:ajax execute="@form" render="doctorMessage"/>
            </h:commandButton>
            <h:link value="Cancel" outcome="/pages/cpanel/manage-doctors" style="margin-left:页: 10px;"/>
        </div>
    </h:form>

There are some minor differences now, such as required and the place-holder select item s value being null. Perhaps it would be best to focus on what might be going wrong with this latest snippet and forget PrimeFaces for a moment.

如果有的话,请见<代码>。 DrConverter 班级:

@Named("doctorConverter")
@RequestScoped
public class DoctorConverter implements Converter, Serializable
{
    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value)
    {
        UIInput in = (UIInput) component;
        String s = in.getSubmittedValue() != null ? in.getSubmittedValue().toString() : "";

        try
        {
            long doctorId = Long.parseLong(s);
            Doctor doctor = doctorDao.findByDoctorId(doctorId);
            if (doctor == null)
            {
                throw new Exception("Doctor not found.");
            }
            return doctor;
        }
        catch (Exception e)
        {
            throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Please enter a valid doctor", null), e);
        }
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value)
    {
        if (value == null || value.toString().length() == 0)
        {
            return "";
        }
        Doctor doctor = (Doctor) value;
        return doctor.getDoctorId().toString();
    }

    @EJB
    private DoctorDao doctorDao;
}

Edit: ... and here are a couple of methods from the Doctor entity class:

@Override
public int hashCode()
{
    int hash = 0;
    hash += (doctorId != null ? doctorId.hashCode() : 0);
    return hash;
}

@Override
public boolean equals(Object object)
{
    if (!(object instanceof Doctor))
    {
        return false;
    }
    Doctor other = (Doctor) object;
    if ((this.doctorId == null && other.doctorId != null) || (this.doctorId != null && !this.doctorId.equals(other.doctorId)))
    {
        return false;
    }
    return true;
}

Edit: As discussed in comments, DoctorConverter.getAsObject is called three times. Here are the stack traces for the three calls in order:

页: 1

at java.lang.Thread.dumpStack(Thread.java:页: 1342 P-4, 2 P-3, 2 FS, 2 NS)
at com.localgp.jsf.converter.DoctorConverter.getAsObject(DoctorConverter.java:34)
at com.localgp.jsf.converter.org$jboss$weld$bean-localgp-server-web-页: 1$0-SNAPSHOT_war-ManagedBean-class_com$localgp$jsf$converter$DoctorConverter_$$_WeldClientProxy.getAsObject(org$jboss$weld$bean-localgp-server-web-页: 1$0-SNAPSHOT_war-ManagedBean-class_com$localgp$jsf$converter$DoctorConverter_$$_WeldClientProxy.java)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:页: 17页: 1)
at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectOneValue(MenuRenderer.java:2 P-4, 2 P-3, 2 FS, 2 NS02 P-4, 2 P-3, 2 FS, 2 NS)
at com.sun.faces.renderkit.html_basic.MenuRenderer.getConvertedValue(MenuRenderer.java:3页: 19)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:页: 1030)
at javax.faces.component.UIInput.validate(UIInput.java:960)
at javax.faces.component.UIInput.executeValidate(UIInput.java:页: 12 P-4, 2 P-3, 2 FS, 2 NS33)
at javax.faces.component.UIInput.processValidators(UIInput.java:698)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:页: 12 P-4, 2 P-3, 2 FS, 2 NS页: 14)
at javax.faces.component.UIForm.processValidators(UIForm.java:2 P-4, 2 P-3, 2 FS, 2 NS53)
at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:508)
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:页: 183)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:页: 1589)
at javax.faces.component.UIForm.visitTree(UIForm.java:344)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:页: 1600)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:页: 1600)
at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:376)
at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:2 P-4, 2 P-3, 2 FS, 2 NS52 P-4, 2 P-3, 2 FS, 2 NS)
at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:页: 183)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:页: 1页: 170)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:页: 10页: 1)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:页: 1页: 18)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:页: 1539)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS页: 17)
at com.localgp.NoCacheFilter.doFilter(NoCacheFilter.java:36)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS56)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS页: 17)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:785)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:483)
at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454)
at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:300)
at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:2 P-4, 2 P-3, 2 FS, 2 NS页: 13)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:页: 17页: 1)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:页: 145)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92 P-4, 2 P-3, 2 FS, 2 NS)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:38页: 1)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS56)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS页: 17)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS56)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS页: 17)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:2 P-4, 2 P-3, 2 FS, 2 NS79)
at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:页: 175)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:9页: 1)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:页: 162 P-4, 2 P-3, 2 FS, 2 NS)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:2 P-4, 2 P-3, 2 FS, 2 NS3页: 1)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:页: 174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:82 P-4, 2 P-3, 2 FS, 2 NS8)
at com.sun.grizzly.comet.CometEngine.executeServlet(CometEngine.java:444)
at com.sun.grizzly.comet.CometEngine.handle(CometEngine.java:308)
at com.sun.grizzly.comet.CometAsyncFilter.doFilter(CometAsyncFilter.java:87)
at com.sun.grizzly.arp.DefaultAsyncExecutor.invokeFilters(DefaultAsyncExecutor.java:页: 17页: 1)
at com.sun.grizzly.arp.DefaultAsyncExecutor.interrupt(DefaultAsyncExecutor.java:页: 143)
at com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:94)
at com.sun.grizzly.http.TaskBase.run(TaskBase.java:页: 193)
at com.sun.grizzly.http.TaskBase.execute(TaskBase.java:页: 175)
at com.sun.grizzly.arp.DefaultAsyncHandler.handle(DefaultAsyncHandler.java:页: 145)
at com.sun.grizzly.arp.AsyncProtocolFilter.execute(AsyncProtocolFilter.java:2 P-4, 2 P-3, 2 FS, 2 NS04)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:页: 137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:页: 104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:7页: 1)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532 P-4, 2 P-3, 2 FS, 2 NS)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:5页: 13)
at java.lang.Thread.run(Thread.java:72 P-4, 2 P-3, 2 FS, 2 NS2 P-4, 2 P-3, 2 FS, 2 NS)

2 P-4, 2 P-3, 2 FS, 2 NS

at java.lang.Thread.dumpStack(Thread.java:页: 1342 P-4, 2 P-3, 2 FS, 2 NS)
at com.localgp.jsf.converter.DoctorConverter.getAsObject(DoctorConverter.java:34)
at com.localgp.jsf.converter.org$jboss$weld$bean-localgp-server-web-页: 1$0-SNAPSHOT_war-ManagedBean-class_com$localgp$jsf$converter$DoctorConverter_$$_WeldClientProxy.getAsObject(org$jboss$weld$bean-localgp-server-web-页: 1$0-SNAPSHOT_war-ManagedBean-class_com$localgp$jsf$converter$DoctorConverter_$$_WeldClientProxy.java)
at javax.faces.component.SelectUtils.doConversion(SelectUtils.java:页: 19页: 1)
at javax.faces.component.SelectUtils.matchValue(SelectUtils.java:99)
at javax.faces.component.UISelectOne.validateValue(UISelectOne.java:页: 153)
at javax.faces.component.UIInput.validate(UIInput.java:967)
at javax.faces.component.UIInput.executeValidate(UIInput.java:页: 12 P-4, 2 P-3, 2 FS, 2 NS33)
at javax.faces.component.UIInput.processValidators(UIInput.java:698)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:页: 12 P-4, 2 P-3, 2 FS, 2 NS页: 14)
at javax.faces.component.UIForm.processValidators(UIForm.java:2 P-4, 2 P-3, 2 FS, 2 NS53)
at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:508)
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:页: 183)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:页: 1589)
at javax.faces.component.UIForm.visitTree(UIForm.java:344)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:页: 1600)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:页: 1600)
at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:376)
at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:2 P-4, 2 P-3, 2 FS, 2 NS52 P-4, 2 P-3, 2 FS, 2 NS)
at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:页: 183)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:页: 1页: 170)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:页: 10页: 1)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:页: 1页: 18)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:页: 1539)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS页: 17)
at com.localgp.NoCacheFilter.doFilter(NoCacheFilter.java:36)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS56)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS页: 17)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:785)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:483)
at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454)
at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:300)
at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:2 P-4, 2 P-3, 2 FS, 2 NS页: 13)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:页: 17页: 1)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:页: 145)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92 P-4, 2 P-3, 2 FS, 2 NS)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:38页: 1)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS56)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS页: 17)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS56)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS页: 17)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:2 P-4, 2 P-3, 2 FS, 2 NS79)
at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:页: 175)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:9页: 1)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:页: 162 P-4, 2 P-3, 2 FS, 2 NS)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:2 P-4, 2 P-3, 2 FS, 2 NS3页: 1)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:页: 174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:82 P-4, 2 P-3, 2 FS, 2 NS8)
at com.sun.grizzly.comet.CometEngine.executeServlet(CometEngine.java:444)
at com.sun.grizzly.comet.CometEngine.handle(CometEngine.java:308)
at com.sun.grizzly.comet.CometAsyncFilter.doFilter(CometAsyncFilter.java:87)
at com.sun.grizzly.arp.DefaultAsyncExecutor.invokeFilters(DefaultAsyncExecutor.java:页: 17页: 1)
at com.sun.grizzly.arp.DefaultAsyncExecutor.interrupt(DefaultAsyncExecutor.java:页: 143)
at com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:94)
at com.sun.grizzly.http.TaskBase.run(TaskBase.java:页: 193)
at com.sun.grizzly.http.TaskBase.execute(TaskBase.java:页: 175)
at com.sun.grizzly.arp.DefaultAsyncHandler.handle(DefaultAsyncHandler.java:页: 145)
at com.sun.grizzly.arp.AsyncProtocolFilter.execute(AsyncProtocolFilter.java:2 P-4, 2 P-3, 2 FS, 2 NS04)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:页: 137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:页: 104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:7页: 1)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532 P-4, 2 P-3, 2 FS, 2 NS)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:5页: 13)
at java.lang.Thread.run(Thread.java:72 P-4, 2 P-3, 2 FS, 2 NS2 P-4, 2 P-3, 2 FS, 2 NS)

3

at java.lang.Thread.dumpStack(Thread.java:页: 1342 P-4, 2 P-3, 2 FS, 2 NS)
at com.localgp.jsf.converter.DoctorConverter.getAsObject(DoctorConverter.java:34)
at com.localgp.jsf.converter.org$jboss$weld$bean-localgp-server-web-页: 1$0-SNAPSHOT_war-ManagedBean-class_com$localgp$jsf$converter$DoctorConverter_$$_WeldClientProxy.getAsObject(org$jboss$weld$bean-localgp-server-web-页: 1$0-SNAPSHOT_war-ManagedBean-class_com$localgp$jsf$converter$DoctorConverter_$$_WeldClientProxy.java)
at javax.faces.component.SelectUtils.doConversion(SelectUtils.java:页: 19页: 1)
at javax.faces.component.SelectUtils.valueIsNoSelectionOption(SelectUtils.java:页: 150)
at javax.faces.component.UISelectOne.validateValue(UISelectOne.java:页: 159)
at javax.faces.component.UIInput.validate(UIInput.java:967)
at javax.faces.component.UIInput.executeValidate(UIInput.java:页: 12 P-4, 2 P-3, 2 FS, 2 NS33)
at javax.faces.component.UIInput.processValidators(UIInput.java:698)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:页: 12 P-4, 2 P-3, 2 FS, 2 NS页: 14)
at javax.faces.component.UIForm.processValidators(UIForm.java:2 P-4, 2 P-3, 2 FS, 2 NS53)
at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:508)
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:页: 183)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:页: 1589)
at javax.faces.component.UIForm.visitTree(UIForm.java:344)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:页: 1600)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:页: 1600)
at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:376)
at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:2 P-4, 2 P-3, 2 FS, 2 NS52 P-4, 2 P-3, 2 FS, 2 NS)
at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:页: 183)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:页: 1页: 170)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:页: 10页: 1)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:页: 1页: 18)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:页: 1539)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS页: 17)
at com.localgp.NoCacheFilter.doFilter(NoCacheFilter.java:36)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS56)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS页: 17)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:785)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:483)
at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454)
at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:300)
at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:2 P-4, 2 P-3, 2 FS, 2 NS页: 13)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:页: 17页: 1)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:页: 145)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92 P-4, 2 P-3, 2 FS, 2 NS)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:38页: 1)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS56)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS页: 17)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS56)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:2 P-4, 2 P-3, 2 FS, 2 NS页: 17)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:2 P-4, 2 P-3, 2 FS, 2 NS79)
at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:页: 175)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:9页: 1)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:页: 162 P-4, 2 P-3, 2 FS, 2 NS)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:2 P-4, 2 P-3, 2 FS, 2 NS3页: 1)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:页: 174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:82 P-4, 2 P-3, 2 FS, 2 NS8)
at com.sun.grizzly.comet.CometEngine.executeServlet(CometEngine.java:444)
at com.sun.grizzly.comet.CometEngine.handle(CometEngine.java:308)
at com.sun.grizzly.comet.CometAsyncFilter.doFilter(CometAsyncFilter.java:87)
at com.sun.grizzly.arp.DefaultAsyncExecutor.invokeFilters(DefaultAsyncExecutor.java:页: 17页: 1)
at com.sun.grizzly.arp.DefaultAsyncExecutor.interrupt(DefaultAsyncExecutor.java:页: 143)
at com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:94)
at com.sun.grizzly.http.TaskBase.run(TaskBase.java:页: 193)
at com.sun.grizzly.http.TaskBase.execute(TaskBase.java:页: 175)
at com.sun.grizzly.arp.DefaultAsyncHandler.handle(DefaultAsyncHandler.java:页: 145)
at com.sun.grizzly.arp.AsyncProtocolFilter.execute(AsyncProtocolFilter.java:2 P-4, 2 P-3, 2 FS, 2 NS04)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:页: 137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:页: 104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:7页: 1)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532 P-4, 2 P-3, 2 FS, 2 NS)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:5页: 13)
at java.lang.Thread.run(Thread.java:72 P-4, 2 P-3, 2 FS, 2 NS2 P-4, 2 P-3, 2 FS, 2 NS)

The present form in the JSF page:

<h:form id="form">
    <!-- Validating here instead of at the selectOneMenu level due to its invalidity not being cleared. -->
    <div style="clear:both;">
        <h:panelGrid columns="2 P-4, 2 P-3, 2 FS, 2 NS">
            <h:selectOneMenu id="doctor"
                             value="#{linkDoctorBean.doctor}"
                             converter="#{doctorConverter}"
                             converterMessage="Please select a doctor"
                             style="width:2 P-4, 2 P-3, 2 FS, 2 NS00px;"
                             required="true">
                <f:selectItem itemLabel="Select a doctor" itemValue="" noSelectionOption="true"/>
                <f:selectItems value="#{linkDoctorBean.doctors}" var="doctor" itemLabel="#{stringBean.doctorToString(doctor)}" itemValue="#{doctor}"/>
            </h:selectOneMenu>
            <p:message id="doctorMessage" for="doctor"/>
        </h:panelGrid>
    </div>
    <div style="margin-top:2 P-4, 2 P-3, 2 FS, 2 NS0px;">
        <h:commandButton value="Link" action="#{linkDoctorBean.submit()}">
            <f:ajax execute="@form" render="doctorMessage"/>
        </h:commandButton>
        <h:link value="Cancel" outcome="/pages/cpanel/manage-doctors" style="margin-left:页: 10px;"/>
    </div>
</h:form>

Edit: Removed <f:ajax/> and DoctorConverter.getAsObject is still being called three times.

&#页: 13; &#页: 13;
最佳回答

你的皈依者被打破。 它必须根据<代码> 数值的论点,而不是<代码>Input#getSubmittedValue (。 <代码>noSelectionOption数值也通过兑换商通过(作为第3次跟踪背心)。 如果您的实际提交价值等于<代码>noSelectionOption<>code>数值,那么该数值即被视为无效,因此,验证错误。

我也建议其他小rew;空洞应当无效。

@Override
public String getAsString(FacesContext context, UIComponent component, Object modelValue) {
    if (modelValue == null) {
        return "";
    }

    if (modelValue instanceof Doctor) {
        Long id = ((Doctor) modelValue).getId();
        return (id != null) ? String.valueOf(id) : null;
    } else {
        throw new ConverterException(new FacesMessage(modelValue + " is not a valid Doctor"));
    }
}

@Override
public Object getAsObject(FacesContext context, UIComponent component, String submittedValue) {
    if (submittedValue == null || submittedValue.isEmpty()) {
        return null;
    }

    try {
        Long id = Long.valueOf(submittedValue);
        return doctorService.find(id);
    } catch (NumberFormatException e) {
        throw new ConverterException(new FacesMessage(submittedValue + " is not a valid Doctor ID"));
    }
}

请注意,我可在web.xml上查阅。 此外:

<context-param>
    <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
    <param-value>true</param-value>
</context-param>

<>Update:根据评论,通过<h:messages/>,可以看出还需要做些什么。 最后,它变成了<代码><f:viewParam required=“true”>,在退学后重新印发。 防止这种情况发生,而是使用

<f:viewParam ... required="#{not facesContext.postback}" />
问题回答

The following:

converter="#{doctorConverter}"

必须写成:

converter="doctorConverter"




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签