0

任何人都知道如何传递选定的行值。当按下“批准”按钮时,我需要更新数据表。

主页.xhtml

 <?xml version="1.0" encoding="UTF-8"?>
  <!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: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.org/ui"
            template="/WEB-INF/layouts/standard.xhtml">
 <ui:define name="notes">
 <h:form>
 <p:commandButton value="Sick Leave" action="sickleave" id="sickleave"/>
    <p:commandButton value="Paid off Leave" action="paidleave" id="paidleave"/>
</h:form>   


 </ui:define>
<ui:define name="content">


   <h2>Approve Leave</h2>
   <h:form>
<h:dataTable value="#{employeeleave}" var="e"
            styleClass="order-table"
            headerClass="order-table-header"
            rowClasses="order-table-odd-row,order-table-even-row"
            columnClasses="order-table-odd-column,order-table-even-column"
        >



    <h:column>
            <f:facet name="header">
                No.
            </f:facet>
                #{e.employeeId}
        </h:column>

        <h:column>
            <f:facet name="header">
                Start Date
            </f:facet>
                #{e.startDate}
        </h:column>

        <h:column>
            <f:facet name="header">
                End Date
            </f:facet>
                #{e.endDate}
        </h:column>

        <h:column>
            <f:facet name="header">
                Reason
            </f:facet>
                #{e.reason}
        </h:column>

        <h:column>
            <f:facet name="header">
                Status
            </f:facet>
                <h:selectOneMenu id="approveleavetype" value="#{employeeLeave.status}">
                        <f:selectItems value="#{referenceData.approveLeave}"/>
                    </h:selectOneMenu>
        </h:column>
        <p:column>
                    <f:facet name="header">Action</f:facet>
                    <p:commandButton value="Approve Leave" action="approveleave" id="approveleave" style="margin-left:250px;">
                    <f:setPropertyActionListener value="#{e}" target="#{employeeleave.selected}" /></p:commandButton>
                </p:column>
    </h:dataTable>  

    </h:form>
    <h2>Please Apply for Leave Here</h2>
    <h:form>

        <h:panelGrid columns="3" id="leaveform" >



                <h:outputLabel for="beds">Select the Type of the Leave</h:outputLabel>



                    <h:selectOneMenu id="leavetype" value="#{employeeLeave.type}">
                        <f:selectItems value="#{referenceData.leaveType}"/>
                    </h:selectOneMenu>


            <div>

                <h:outputLabel for="startDate">Start Date</h:outputLabel>



                    <p:calendar id="startDate" label="Start Date" 
                        value="#{employeeLeave.startDate}" pattern="MM-dd-yyyy" timeZone="EST" required="true" />


            </div>
            <div>
                <h:outputLabel for="endDate">End Date</h:outputLabel>



                    <p:calendar id="endDate" label="End Date" 
                        value="#{employeeLeave.endDate}" pattern="MM-dd-yyyy" timeZone="EST" required="true" />

            </div>
            <div>
                <h:outputLabel for="checkoutDate">Reason</h:outputLabel>



            <h:inputTextarea id="reason" value="#{employeeLeave.reason}" 
                 required="true" 
                label="reason" >
            </h:inputTextarea>
            </div>






        </h:panelGrid>

        <center><p:commandButton value="Apply Leave" action="applyleave" id="applyleave" style="margin-left:250px;"/></center>


    </h:form>
    <br></br>

   <center> <h1 style="font-size: 16px;font-weight:bold;margin-top:100px;">Leave Application</h1></center>




     </ui:define>
    </ui:composition>

主流.xml

  <action-state id="ApproveLeave">
<!-- <set name="viewScope.employeeleave" value="employeeleave.selected" /> -->
    <evaluate expression="leaveBo.approveLeave(employeeLeave.selectedRow)"></evaluate>
    <transition to="managerpage"></transition>
</action-state>

这里试图获取选定的行并尝试评估它。

但我收到以下错误。

      javax.el.ELException: /WEB-INF/flows/main/managerpage.xhtml @70,86 target="#{employeeleave.selected}": Cannot convert selected of type class java.lang.String to class java.lang.Integer
at  com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:103)
at  com.sun.faces.facelets.tag.jsf.core.SetPropertyActionListenerHandler$SetPropertyListener.processAction(SetPropertyActionListenerHandler.java:210)
at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
at javax.faces.component.UICommand.broadcast(UICommand.java:300)
at javax.faces.component.UIData.broadcast(UIData.java:1093)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at org.springframework.faces.webflow.FlowLifecycle.invokePhase(FlowLifecycle.java:127)
at org.springframework.faces.webflow.FlowLifecycle.execute(FlowLifecycle.java:70)
at org.springframework.faces.webflow.JsfView.processUserEvent(JsfView.java:120)
at org.springframework.webflow.engine.ViewState.handleEvent(ViewState.java:226)
at org.springframework.webflow.engine.ViewState.resume(ViewState.java:196)
at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:258)
at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
at org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
4

1 回答 1

0

正如错误日志所说:

The method arguments for the setter setSelected need to be of type String in your case, like this:


public class Employeeleave {
  public void setSelected(String newValue){
    selected = newValue;
  }
}
于 2012-07-04T13:49:26.910 回答