2011-05-03 5 views
0

명령 단추 onclick 이벤트가 작동하지 않습니다. Banking bean 메소드를 호출하지 않습니다.Backing bean 메소드를 실행할 수 없습니다.

action="#{editBean.editQuestionAction}" 
action="#{editBean.addNewQuestionAction}" 

가 잘 작동하지만 것처럼 다른이며 commandButtons이 있습니다이 아니 행동 '의 경우 = "# {editBean.updateQuestionAction}"에서

<p:tab title="Questions"> 
       <h:outputText value="Select a project to add questions: " /> 
       <h:selectOneMenu id="projects_dpd" value="#{editBean.currentProject.projectId}" onchange=""> 
        <f:selectItems value="#{projectBean.projects}" /> 
       </h:selectOneMenu><br/> 

       <h:form id="listForm"> 
        <p:panel id="listPanel" header="List of Questions" toggleable="false" closable="false"> 
         <p:dataList paginatorAlwaysVisible="false" paginatorPosition="bottom" effect="slide" 
            value="#{editBean.editBeanList}" var="q" 
            paginator="true" rows="5" effectSpeed="fast" 
            paginatorTemplate="{PreviousPageLink} {CurrentPageReport} {NextPageLink} {RowsPerPageDropdown}" 
            rowsPerPageTemplate="5,10,15"> 

          <p:column> 
           <p:commandButton action="#{editBean.**editQuestionAction**}" update="editPanel" title="Edit Question" image="edit"> 
            <f:setPropertyActionListener value="#{q}" target="#{editBean.editQuestion}" /> 
           </p:commandButton> 
           <p:spacer width="30" height="30" /> 
           <h:outputText value="#{q.question.questionId} -> #{q.question.questionText} ->"/> <b><h:outputText value="#{q.question.questionType}" /></b> 
          </p:column> 
         </p:dataList> 
         <p:commandButton value="New Question !!" action="#{editBean.**addNewQuestionAction**}" update="editPanel" /> 
         <p:commandButton ajax="false" value="Home Page !!" action="#{indexBean.**gotoHomePage}**" /> 
        </p:panel> 
       </h:form> 

       <p:layoutUnit position="center" scrollable="true"> 
        <p:panel id="editPanel" header="Edit Section" toggleable="false" closable="false" > 
         <h:form id="form"> 
          <table cellspacing="20"> 
           <tr> 
            <td><h:outputLabel value="Question Text:" /></td> 
            <td><p:inputTextarea id="questionText" required="true" value="#{editBean.editQuestion.question.questionText}" autoResize="true" effectDuration="400" maxHeight="100" /></td>        <td><p:message for="questionText" /></td> 
           </tr> 

           <tr> 
            <td>Review:</td> 
            <td><p:inputTextarea id="reviewText" required="true" value="#{editBean.editQuestion.question.reviewText}" autoResize="true" effectDuration="400" maxHeight="100" /></td> 
            <td><p:message for="reviewText" /></td> 
           </tr> 

           <tr> 
            <td>Option Type:</td> 
            <td> 
             <h:selectOneRadio label="Option Type" value="#{editBean.editQuestion.question.optionType}"> 
              <f:selectItem itemLabel="Currency" itemValue="currency" /> 
              <f:selectItem itemLabel="Hours" itemValue="hours" /> 
             </h:selectOneRadio> 
            </td> 
           </tr> 

           <tr> 
            <td>Question Type:</td> 
            <td> 
             <h:selectOneRadio label="Question Type" value="#{editBean.editQuestion.question.questionType}"> 
              <f:selectItem itemLabel="Mandatory" itemValue="mandatory" /> 
              <f:selectItem itemLabel="Linked" itemValue="linked" /> 
             </h:selectOneRadio> 
            </td> 
           </tr> 

           <tr> 
            <td align="right"> 
             <h:selectBooleanCheckbox label="Hide Weight until Review !!" value="#{editBean.editQuestion.question.hideWeight}" /> 
            </td> 
            <td>Hide Weight Until Review</td> 
           </tr> 

           <tr> 
            <td>Options:</td> 
            <td> 
             <p:panel header="Add Option"> 
              <h:panelGrid columns="2" id="grid"> 
               <h:outputLabel value="Text : " for="txt_title"></h:outputLabel> 
               <p:inputText id="txt_title" 
                  value="#{editBean.placeHolderForOption.optionText}" /> 

               <h:outputLabel value="Weight : " for="txt_author"></h:outputLabel> 
               <p:inputText id="txt_author" 
                  value="#{editBean.placeHolderForOption.weight}" /> 

               <p:commandButton value="Reset" type="reset"/> 
               <p:commandButton value="Add" update="options @parent" 
                   action="#{editBean.initOption}" > 
                <p:collector value="#{editBean.placeHolderForOption}" 
                   addTo="#{editBean.editQuestion.options}" /> 
               </p:commandButton> 
              </h:panelGrid> 
             </p:panel> 

             <p:outputPanel id="options"> 
              <p:dataTable value="#{editBean.editQuestion.options}" var="opt"> 
               <p:column headerText="Text" style="width:150px"> 
                <p:cellEditor> 
                 <f:facet name="output"> 
                  <h:outputText value="#{opt.optionText}" /> 
                 </f:facet> 
                 <f:facet name="input"> 
                  <h:inputText value="#{opt.optionText}" /> 
                 </f:facet> 
                </p:cellEditor> 
               </p:column> 
               <p:column headerText="Weight" style="width:150px"> 
                <p:cellEditor> 
                 <f:facet name="output"> 
                  <h:outputText value="#{opt.weight}" /> 
                 </f:facet> 
                 <f:facet name="input"> 
                  <h:inputText value="#{opt.weight}" /> 
                 </f:facet> 
                </p:cellEditor> 
               </p:column> 
               <p:column headerText="Linked Question" style="width:150px"> 
                <p:cellEditor> 
                 <f:facet name="output"> 
                  <h:outputText value="#{opt.linkedQuestionId}" /> 
                 </f:facet> 
                 <f:facet name="input"> 
                  <h:selectOneMenu value="#{opt.linkedQuestionId}"> 
                   <f:selectItems value="#{editBean.linkedQuestionIds}" /> 
                  </h:selectOneMenu> 
                 </f:facet> 
                </p:cellEditor> 
               </p:column> 
               <p:column headerText="Display Order" style="width:150px"> 
                <p:cellEditor> 
                 <f:facet name="output"> 
                  <h:outputText value="#{opt.displayOrder}" /> 
                 </f:facet> 
                 <f:facet name="input"> 
                  <h:inputText value="#{opt.displayOrder}" /> 
                 </f:facet> 
                </p:cellEditor> 
               </p:column> 
               <p:column> 
                <f:facet name="header"> 
                 <h:outputText value="Operation" /> 
                </f:facet> 
                <p:commandLink value="Remove" update="form:options" process="@this"> 
                 <p:collector value="#{opt}" 
                    removeFrom="#{editBean.editQuestion.options}" /> 
                </p:commandLink> 
                <p:spacer width="10" /> 
                <p:rowEditor /> 
               </p:column> 
              </p:dataTable> 
             </p:outputPanel> 
            </td> 
           </tr> 
          </table> 
          <p:commandButton ajax="false" value="Update Question" action="#{editBean.updateQuestionAction}" 
              rendered="#{editBean.operation eq 'edit'}" /> 

          <p:commandButton ajax="false" value="Add Question" update="msgs listForm:listPanel" action="#{editBean.saveQuestion}" 
              rendered="#{editBean.operation eq 'add'}"> 
           <p:collector value="#{editBean.editQuestion}" 
              addTo="#{editBean.editBeanList}" /> 
          </p:commandButton> 

          <p:commandButton ajax="false" value="Delete Question" update="msgs listForm:listPanel" action="#{editBean.deleteQuestionAction}" 
              rendered="#{editBean.operation eq 'edit'}"> 
           <p:collector value="#{editBean.editQuestion}" 
              removeFrom="#{editBean.editBeanList}" /> 
          </p:commandButton> 
         </h:form> 
        </p:panel> 
       </p:layoutUnit> 
      </p:tab> 

그것의 내가 버튼을 클릭하면 실행받지

@ManagedBean 
    @RequestScoped 
    public class EditBean { 

     @ManagedProperty(value = "#{questionDao}") 
     private QuestionDao questionDao; 
     private String operation; 
     private QuestionHelper editQuestion; 
     private SelectItem[] linkedQuestionIds; 
     private List<QuestionHelper> linkedQuestions = new ArrayList<QuestionHelper>(); 
     private List<QuestionHelper> allQuestions = new ArrayList<QuestionHelper>(); 
public void editQuestionAction() { 
     operation = "edit"; 
    } 

    public void deleteQuestionAction() { 
     questionDao.delete(editQuestion.getQuestion()); 
     listBean.getListOfQuestions().remove(editQuestion); 
     addNewQuestionAction(); 
     FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Question: ", "Question Deleted !")); 
    } 

    public void updateQuestionAction() { 
     editQuestion.getQuestion().getOptionses().clear(); 
     for (Options o : editQuestion.getOptions()) { 
      o.setQuestions(editQuestion.getQuestion()); 
      editQuestion.getQuestion().getOptionses().add(o); 
     } 
     getQuestionDao().update(editQuestion.getQuestion()); 
     FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Question: ", "Question Updated !")); 
    } 
+0

전체 파일이 큰 수 있습니다 @madhav 그것의 내가 캔트 매우 큰 파일은 여기 – Bozho

+0

빈 정의를 보여,하지만 당신은, 당신을 실행 – Maddy

+1

을 포함 – Bozho

답변

1

안녕 내가 명령 버튼이 때문에 관리 빈의 렌더링 태그와 요청 범위의 작동하지 않는 내 질문에 대한 답을 발견 이후의 모든 요청으로 누른 후 명령 단추 내 요청 범위 (iseditable) 재설정 중입니다. 내가 Session을 만들었을 때 Session Fine을 작동 시켰습니다.

관련 문제