我有一个缝网应用程序,对于一个页面,我有一个硬编码参数,如:
docCodesFrom=ClinicContactsView
在DocCodesEdit.page.xml中我声明它很简单:
<param name="docCodesFrom"/>
问题是在我加载DocCodesEdit.xhtml页面后,当我按下取消按钮(重定向回到我以前的页面)时,我收到一个非常奇怪的错误:
由java.lang.ClassCastException引起 带消息:“java.lang.String不能 被投射到 javax.faces.validator.Validator接口“
所以它抱怨这个docCodesFrom参数......
传播到我按下取消的页面的链接是:
<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>
我花了三个小时才知道原因......
你看到了这个问题吗?
没有Seam开发人员?:(
更新:
ClinicContactsView.xhtml的源代码(用户转到DocCodesEdit.xhtml的页面;此处我附加 docCodesFrom 参数。
<!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 的代码:
<?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>
如果此代码足够,请告诉我。当我在DocCodesEdit.xhtml或者取消时按下Done时,会出现问题,因此不会调用辅助bean的java代码...
答案 0 :(得分:0)
问题确实存在于新代码中:它隐藏在ClinicContactsView.page.xml
中(你在上面写了.xhtml
,但我认为你的意思是页面描述符)。在其中,有一行
<param name="docCodesFrom" validator="ClinicContactView"/>
这是按下Cancel
然后返回到该页面的地方,您尝试将字符串(ClinicContactView
)转换为验证器,这将无效。你可能也想在这里使用value
属性。