开发者

seam strange param error

I have a seam web application and for one page I have an hardcoded parameter like:

docCodesFrom=ClinicContactsView

In DocCodesEdit.page.xml I declare it simple like:

<param name="docCodesFrom"/>

The problem is that after I am loading the DocCodesEdit.xhtml page, when I press the cancel button (which redirects back to the page I was before) I receive a very strange error:

Caused by java.lang.ClassCastException with message: "java.lang.String cannot be cast to javax.faces.validator.Validator"

so it's complaining about this docCodesFrom parameter....

The link which does the propagation to the page where I press Cancel is:

<s:link view="/#{empty from ? 'DocCodes' : from}View.xhtml"
       value="#{empty from ? 'View' : 'Select'}"
       propagation="#{empty from ? 'none' : 'default'}"
       id="docCodesViewId">
       <f:param name="docCodesId"
            value="#{_docCodes.id}"/>
       <f:param name="docCodesFrom" value="ClinicContactsView"/>
 </s:link>

I have spent three hours on this and cannot figure the cause...

Do you see the issue?

No Seam developer overhere?:(

UPDATE:

The source code of the ClinicContactsView.xhtml (the page from where the user goes to the DocCodesEdit.xhtml; here I append the docCodesFrom parameter.

 <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:a4j="http://richfaces.org/a4j"
                template="layout/template.xhtml">

<ui:define name="body">
    <h:form id="contactDetailsSearch">
        <rich:panel style="width:650px">
            <f:facet name="header">View Clinic Details</f:facet>


            <!--Clinic Contact's View-->

            <div style="widht:350px; float:left;">
                <div>
                    <s:decorate id="clinicName" template="/layout/display.xhtml">
                        <ui:define name="label">Clinic Name</ui:define>
                        <h:outputText value="#{clinicContactsHomeFacade.instance.name}">

                        </h:outputText>
                    </s:decorate>
                </div>
                <div>
                    <s:decorate id="address1" template="/layout/display.xhtml">
                        <ui:define name="label">Address</ui:define>
                        <h:outputText value="#{clinicContactsHomeFacade.instance.address1}"/>
                        <h:outputText value="#{clinicContactsHomeFacade.instance.address2}"/>
                    </s:decorate>
                </div>
                <div>
                    <s:decorate id="state" template="/layout/display.xhtml">
                        <ui:define name="label">State</ui:define>
                        <h:outputText value="#{clinicContactsHomeFacade.instance.state}"/>
                    </s:decorate>
                </div>
                <div>
                    <s:decorate id="city" template="/layout/display.xhtml">
                        <ui:define name="label">City</ui:define>
                        <h:outputText value="#{clinicContactsHomeFacade.instance.city}"/>
                    </s:decorate>
                </div>
                <div>
                    <s:decorate id="postalcode" template="/layout/display.xhtml">
                        <ui:define name="label">Postal Code</ui:define>
                        <h:outputText value="#{clinicContactsHomeFacade.instance.postalCode}"/>
                    </s:decorate>
                </div>
                <div>
                    <s:decorate id="country" template="/layout/display.xhtml">
                        <ui:define name="label">Country</ui:define>
                        <h:outputText id="countryEdit" value="#{clinicContactsHomeFacade.instance.country}"/>
                    </s:decorate>
                </div>
            </div>

            <div style="clear:both"/>


            <div class="actionButtonsMiddle">

                <s:button view="/ClinicContactsEdit.xhtml"
                          id="edit"
                          value="Edit"/>

                <s:button view="/#{empty clinicContactsFrom ? 'ClinicContactsList' : clinicContactsFrom}.xhtml"
                          id="done"
                          value="Done"/>
            </div>

            <!--TABS-->
            <rich:spacer height="20"/>
            <rich:tabPanel width="100%">
                <!--Show contact details related to the current clinic-->
                <rich:tab label="Contact Details">

                    <div class="results" id="contactDetailsList">

                        <h:outputText value="The contactDetails search returned no results."
                                      rendered="#{contactDetailsDataModel.rowCount == 0}"/>
                        <rich:dataTable id="contactDetailsTable"
                                        var="_contactDetails"
                                        value="#{contactDetailsDataModel}"
                                        rows="10"
                                        rendered="#{contactDetailsDataModel.rowCount > 0}">

                            <rich:column sortBy="#{_contactDetails.contactType}">
                                <f:facet name="header">Contact type
                                </f:facet>
                                <h:outputText value="#{_contactDetails.contactType}"/>
                            </rich:column>
                            <rich:column sortBy="#{_contactDetails.active}">
                                <f:facet name="header">Active
                                </f:facet>
                                <h:outputText value="#{_contactDetails.active}"/>
                            </rich:column>
                            <rich:column sortBy="#{_contactDetails.contactInfo}">
                                <f:facet name="header">Contact info
                                </f:facet>
                                <h:outputText value="#{_contactDetails.contactInfo}"/>
                            </rich:column>
                            <rich:column sortBy="#{_contactDetails.remarks}">
                                <f:facet name="header">Remarks
                                </f:facet>
                                <h:outputText value="#{_contactDetails.remarks}"/>
                            </rich:column>

                            <rich:column styleClass="action">
                                <f:facet name="header">Action</f:facet>
                                <s:link view="/#{empty from ? 'ContactDetails' : from}View.xhtml"
                                        value="#{empty from ? 'View' : 'Select'}"
                                        propagation="#{empty from ? 'none' : 'default'}"
                                        id="contactDetailsViewId">
                                    <f:param name="contactDetailsId"
                                             value="#{_contactDetails.id}"/>
                                    <f:param name="contactDetailsFrom" value="ClinicContactsView"/>
                                </s:link>
                                #{' '}
                                <s:link view="/ContactDetailsEdit.xhtml"
                                        value="Edit"
                                        propagation="none"
                                        id="contactDetailsEdit"
                                        rendered="#{empty from}">
                                    <f:param name="contactDetailsId"
                                             value="#{_contactDetails.id}"/>
                                    <f:param name="contactDetailsFrom" value="ClinicContactsView"/>
                                </s:link>
                            </rich:column>
                        </rich:dataTable>
                    </div>
                    <s:div styleClass="actionButtons" rendered="#{empty from}">
                        <s:button view="/ContactDetailsEdit.xhtml"
                                  id="create"
                                  propagation="none"
                                  value="Add Contact Details">
                            <f:param name="clinicContactsId" value="#{clinicContactsHomeFacade.instance.id}"/>
                            <f:param name="contactDetailsFrom" value="ClinicContactsView"/>
                        </s:button>
                    </s:div>

                </rich:tab>
                <rich:tab label="Doc Codes">
                    <rich:dataTable id="docCodesTable"
                                    var="_docCodes"
                                    value="#{docCodesDataModel}"
                                    rows="10"
                                    rendered="#{docCodesDataModel.rowCount > 0}">
                        <rich:column sortBy="#{_docCodes.active}">
                            <f:facet name="header">Doc Code
                            </f:facet>
                            <h:outputText value="#{_docCodes.docCode}"/>
                        </rich:column>
                        <rich:column sortBy="#{_docCodes.active}">
                            <f:facet name="header">Doctor
                            </f:facet>
                            <h:outputText value="#{_docCodes.doctorContacts.name}"/>
                        </rich:column>
                        <rich:column styleClass="action">
                            <f:facet name="header">Action</f:facet>
                            <s:link view="/#{empty from ? 'DocCodes' : from}View.xhtml"
                                    value="#{empty from ? 'View' : 'Select'}"
                                    propagation="#{empty from ? 'none' : 'default'}"
                                    id="docCodesViewId">
                                <f:param name="docCodesId"
                                         value="#{_docCodes.id}"/>
                                <f:param name="docCodesFrom" value="ClinicContactsView"/>
                                <f:param name="doctorContactsId" value="#{_docCodes.doctorContacts.id}"/>
                            </s:link>
                            #{' '}
                            <s:link view="/DocCodesEdit.xhtml"
                                    value="Edit"
                                    propagation="none"
                                    id="docCodesEdit"
                                    rendered="#{empty from}">
                                <f:param name="docCodesId"
                                         value="#{_docCodes.id}"/>
                                <f:param name="docCodesFrom" value="ClinicContactsView"/>
                                <f:param name="doctorContactsId" value="#{_docCodes.doctorContacts.id}"/>
                            </s:link>
                        </rich:column>
                    </rich:dataTable>


                    <rich:datascroller for="docCodesTable" rendered="#{docCodesDataModel.rowCount > 0}"/>

                    <s:div styleClass="actionButtons" rendered="#{empty from}">
                        <s:button view="/DocCodesEdit.xhtml"
                                  id="createDocCode"
                                  propagation="none"
                                  value="Create DocCode">
                            <f:param name="clinicContactsId" value="#{clinicContactsHomeFacade.instance.id}"/>
                            <f:param name="docCodesFrom" value="ClinicContactsView"/>
                        </s:button>
                    </s:div>

                </rich:tab>
            </rich:tabPanel>

        </rich:panel>
    </h:form>
</ui:define>

</ui:composition>

ClinicContactsView.page.xhtml's code:

    <?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://jboss.com/products/seam/pages"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.1.xsd">

   <param name="docCodesFrom" validator="ClinicContactView"/>
   <param name="clinicContactsFrom"/>
   <param name="clinicContactsId" value="#{clinicContactsHome.clinicContactsId}"/>
   <param name="clinicContactsId" value="#{clinicContactsHomeFacade.clinicContactsId}"/>
   <param name="clinicContactsId" value="#{contactDetailsDataModel.contactId}"/>
</page>

DocCodesEdit.xhtml

    <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
              开发者_开发百科  xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:a="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich" xmlns:a4j="http://richfaces.org/a4j"
                template="layout/template.xhtml">

<ui:define name="body">

<h:form id="docCodes" styleClass="edit">

    <rich:panel style="width:550px;">
        <f:facet name="header">#{docCodesHomeFacade.managed ? 'Edit' : 'Add'} Doc code</f:facet>

        <div style="float:left;width:350;">
            <s:decorate id="doctorField" template="layout/edit.xhtml">
                <ui:define name="label">Doctor</ui:define>
                <h:inputText id="docCode"
                             required="true"
                             size="30"
                             maxlength="45"
                             value="#{doctorContactsHomeFacade.getInstance().name}">
                    <a:support event="onblur" reRender="docCodeField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>
            <s:decorate id="docCodeField" template="layout/edit.xhtml">
                <ui:define name="label">Doc code</ui:define>
                <h:inputText id="docCode"
                             required="true"
                             size="30"
                             maxlength="45"
                             value="#{docCodesHomeFacade.instance.docCode}">
                    <a:support event="onblur" reRender="docCodeField, doctorContactsTable" bypassUpdates="true"
                               ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>
        </div>
        <!--LOOKUP for doctor name: Button and Modal Panel-->
        <div style="float:right;width:80px;margin-right:0px;">
            <a4j:commandButton style="display:block;width:80px;margin-top:8px;" reRender="doctorContactsTable"
                               onclick="Richfaces.showModalPanel('pnl');"
                               value="Lookup">
            </a4j:commandButton>

        </div>

        <div style="clear:both">
            <span class="required">*</span>
            required fields
        </div>

    </rich:panel>

    <rich:spacer height="20"/>
    <rich:panel style="width:90%"
                rendered="#{not empty doctorContactsHomeFacade.doctorContactsId || not empty clinicContactsHomeFacade.clinicContactsId}">
        <f:facet
                name="header">Contact Details</f:facet>
        <!--Doctors' Contact Details-->
        <div class="results" id="contactDetailsListDoctors">

            <h:outputText value="The contactDetails search returned no results."
                          rendered="#{contactDetailsDataModel.rowCount == 0}"/>
            <rich:dataTable id="contactDetailsTableDoctors"
                            var="_contactDetails"
                            value="#{contactDetailsDataModel}"
                            rows="10"
                            rendered="#{contactDetailsDataModel.rowCount > 0}">
                <rich:column sortBy="#{_contactDetails.active}">
                    <f:facet name="header">Clinic/Doctor Name
                    </f:facet>
                    <h:outputText value="#{_contactDetails.contacts.name}"/>
                </rich:column>
                <rich:column sortBy="#{_contactDetails.contactInfo}">
                    <f:facet name="header">Contact Details
                    </f:facet>
                    <h:outputText value="#{_contactDetails.contactInfo}"/>
                </rich:column>
                <rich:column sortBy="#{_contactDetails.contactType}">
                    <f:facet name="header">Contact type
                    </f:facet>
                    <h:outputText value="#{_contactDetails.contactType}"/>
                </rich:column>

                <rich:column styleClass="action">
                    <f:facet name="header">Send?</f:facet>
                    <a:region>
                        <h:selectBooleanCheckbox>
                            <!--<a4j:support event="onselect" ajaxSingle="true" action="#{docCodesHomeFacade.addSelectedContactId()}"/>-->
                            <a4j:support event="onclick"
                                         action="#{docCodesHomeFacade.addSelectedContactId(_contactDetails.id)}"
                                         ignoreDupResponses="true">
                            </a4j:support>
                        </h:selectBooleanCheckbox>
                    </a:region>
                </rich:column>
            </rich:dataTable>
        </div>
    </rich:panel>

    <div class="actionButtons">

        <h:commandButton id="save"
                         value="Save"
                         action="#{docCodesHomeFacade.persist}"
                         disabled="#{!docCodesHomeFacade.wired}"
                         rendered="#{!docCodesHomeFacade.managed}"/>

        <h:commandButton id="update"
                         value="Save"
                         action="#{docCodesHomeFacade.update}"
                         rendered="#{docCodesHomeFacade.managed}"/>

        <h:commandButton id="delete"
                         value="Delete"
                         action="#{docCodesHomeFacade.remove}"
                         immediate="true"
                         rendered="#{docCodesHomeFacade.managed}"/>

        <s:button id="cancelEdit"
                  value="Cancel"
                  propagation="end"
                  view="/ClinicContactsView.xhtml" includePageParams="true"
                  rendered="#{docCodesHomeFacade.managed}"/>

        <s:button id="cancelAdd"
                  value="Cancel"
                  propagation="end"
                  view="/#{empty docCodesFrom ? 'DocCodesList' : docCodesFrom}.xhtml"
                  rendered="#{!docCodesHomeFacade.managed}"/>

    </div>
</h:form>

<!--RICH MODAL PANEL to LOOKUP for Doctors-->
<!--  <a4j:form>-->
<a:form>
    <rich:modalPanel id="pnl" width="800" height="500">

        <f:facet name="header">
            <h:outputText value="Select Doctor"/>
        </f:facet>

        <f:facet name="controls">
            <h:panelGroup>
                <h:graphicImage value="/img/icons/close.gif" style="cursor:pointer" id="hidelink"/>
                <rich:componentControl for="pnl" attachTo="hidelink" operation="hide"
                                       event="onclick"/>
            </h:panelGroup>
        </f:facet>

       <!-- some unsignificant code removed --!>
        <div class="actionButtons">
            <a:commandButton id="search" value="Search" reRender="doctorContactsTable"/>
            <s:button id="reset" value="Reset" includePageParams="false"/>
        </div>

        <rich:panel>
            <f:facet
                    name="header">Doctors Search Results</f:facet>

            <div class="results" id="doctorsContactsList">
                <h:outputText
                        value="The doctors contact search returned no results."
                        rendered="#{doctorContactsDataModel.rowCount == 0}"/>
                <rich:dataTable
                        id="doctorContactsTable" var="_doctorContact" value="#{doctorContactsDataModel}"
                        rows="10" rendered="#{doctorContactsDataModel.rowCount > 0}">

                    <rich:column sortBy="#{_doctorContact.name}">
                        <f:facet name="header">Doctor </f:facet>
                        <h:outputText value="#{_doctorContact.name}"/>
                    </rich:column>

                    <rich:column sortBy="#{_doctorContact.state}">
                        <f:facet name="header">SMC </f:facet>
                        <h:outputText value="#{_doctorContact.nationalCode}"/>
                    </rich:column>

                    <rich:column sortBy="#{_doctorContact.state}">
                        <f:facet name="header">Address 1 </f:facet>
                        <h:outputText value="#{_doctorContact.address1}"/>
                    </rich:column>

                    <rich:column sortBy="#{_doctorContact.state}">
                        <f:facet name="header">Address 2</f:facet>
                        <h:outputText value="#{_doctorContact.address2}"/>
                    </rich:column>

                    <rich:column sortBy="#{_doctorContact.state}">
                        <f:facet name="header">Postal Code </f:facet>
                        <h:outputText value="#{_doctorContact.postalCode}"/>
                    </rich:column>

                    <rich:column styleClass="action">
                        <f:facet name="header">#{messages['action']}</f:facet>
                        <s:button view="/DocCodesEdit.xhtml"
                                  id="loadDoctor"
                                  propagation="none"
                                  value="Select" includePageParams="true">
                            <f:param name="doctorContactsId" value="#{_doctorContact.id}"/>
                        </s:button>
                    </rich:column>
                </rich:dataTable></div>
        </rich:panel>

        <rich:datascroller for="doctorContactsTable" rendered="#{doctorContactsDataModel.rowCount > 0}"/>

    </rich:modalPanel>
</a:form>

</ui:define>

</ui:composition>

DocCodesEdit.page.xml

 <?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://jboss.com/products/seam/pages"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.1.xsd"
      no-conversation-view-id="/DocCodesList.xhtml"
      login-required="true">

    <begin-conversation join="true" flush-mode="MANUAL"/>

    <action execute="#{docCodesHomeFacade.wire}"/>
    <param name="docCodesFrom"/>
    <param name="docCodesId" value="#{docCodesHome.docCodesId}"/>
    <param name="docCodesId" value="#{docCodesHomeFacade.docCodesId}"/>
    <param name="clinicContactsFrom"/>
    <param name="clinicContactsId" value="#{clinicContactsHome.clinicContactsId}"/>
    <param name="clinicContactsId" value="#{clinicContactsHomeFacade.clinicContactsId}"/>

    <param name="doctorContactsFrom"/>
    <param name="doctorContactsId" value="#{doctorContactsHome.doctorContactsId}"/>
    <param name="doctorContactsId" value="#{doctorContactsHomeFacade.doctorContactsId}"/>
    <action execute="#{contactDetailsDataModel.setDoctorContactId(doctorContactsId)}" if="#{not empty doctorContactsId}"></action>
    <action execute="#{contactDetailsDataModel.setClinicContactId(clinicContactsId)}" if="#{not empty clinicContactsId}"></action>

    <navigation from-action="#{docCodesHomeFacade.persist}">
        <rule if-outcome="persisted">
            <end-conversation/>
            <redirect view-id="/#{empty docCodesFrom ? 'DocCodesList' : docCodesFrom}.xhtml"
                      include-page-params="true">
                <param name="clinicContactsId" value="#{docCodesHomeFacade.getInstance().getClinicContacts().getId()}"/>
            </redirect>
        </rule>
    </navigation>

    <navigation from-action="#{docCodesHomeFacade.update}">
        <rule if-outcome="updated">
            <end-conversation/>
            <redirect view-id="/#{empty docCodesFrom ? 'DocCodesList' : docCodesFrom}.xhtml"
                      include-page-params="true">
                <param name="clinicContactsId" value="#{docCodesHomeFacade.getInstance().getClinicContacts().getId()}"/>
            </redirect>
        </rule>
    </navigation>

    <navigation from-action="#{docCodesHomeFacade.remove}">
        <rule if-outcome="removed">
            <end-conversation/>
            <redirect view-id="/#{empty docCodesFrom ? 'DocCodesList' : docCodesFrom}.xhtml"
                      include-page-params="true">
                <param name="clinicContactsId" value="#{docCodesHomeFacade.getInstance().getClinicContacts().getId()}"/>
            </redirect>
        </rule>
    </navigation>

</page>

Please let me know if this code is enough. When I'm pressing Done on the DocCodesEdit.xhtml or Cancel, the issue occurs so no java code from the backing bean is called...


The problem is indeed in the new code: It is hidden in ClinicContactsView.page.xml (you wrote that as .xhtml above, but I assumed you meant the page descriptor). In it, there is the line

<param name="docCodesFrom" validator="ClinicContactView"/>

This is where, upon pressing Cancel and thereby returning to that page, you try to convert a string (ClinicContactView) to a validator, which won’t work. You probably meant to use the value attribute here as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜