2012-10-13 1 views
0

사람들은, 너무 친절하게 나와 함께 곰 매우 명확합니다. 최대한 명확하게하려고 노력할 것입니다.JSF 쇼 TextField의 버튼이 같은 행의 열에서 클릭,

첨부 된 화면에서 첫 번째 행이 비어있는 테이블을 볼 수 있으며 두 번째 행에는 테이블 항목이 있습니다.

내가 원하는 것은 테이블의 첫 번째 행을 항목으로 사용하고자하는 것입니다. ID, 이름 및 값에 대한 값을 입력 할 수 있습니다.

"저장"버튼을 클릭하면 행이 데이터베이스에 추가되고 을 가져 와서 표시해야합니다. 나는 데이터베이스 부분에 어떤 문제도 없다.

내 질문은 다음과 같습니다 (당신이 솔루션을 제공 할 때 Pleae 코드 snipets을 제공) 내가 에 대한 "편집"버튼을 클릭하면 (ID, 이름 및 값)에 대한 텍스트 필드를 표시해야합니다

1) 값이있는 행을 클릭하고 "편집"을 클릭하면 버튼 테이블이로드 될 때 "저장"버튼을 사용하도록 설정해야합니다. 그러면 수정할 수 있으며, 지금은 라벨처럼 보입니다.

저장 버튼을 눌렀을 때 TextField를 변경 한 후에는 비활성화해야합니다.

행을 테이블 테이블의 첫 번째 행과 비슷하지만 값을 편집하고 싶습니다. 어떻게 달성할까요?

2) 버튼의 id를 참조하고 이 활성화되어 있는지 여부를 확인하여 텍스트 필드 (ID, 이름 및 값)를 렌더링 할 수 있습니까? 여기

내가 특정 행에 대해 내가 한 번에이 outputText 또는 InputText]를 중 하나를 표시 할 수 있도록이 작업이 완료 을 데이터가있을 때 나는 렌더링하지 않는 테이블

<h:column> 
    <f:facet name="header"> 
     <h:outputText value="Value" /> 
    </f:facet> 
    <h:outputText value="#{dataItem.value}" /> 
    <h:inputText id="value" value="#{dataItem.value}" rendered="#{dataItem.value == null}"/> 
</h:column> 

에 대한 열 코드입니다. 시간이 많이 걸릴 수 있습니다 이러한 경우에 대한 코드를 게시

enter image description here

답변

0

.

<table component> 
<row> 
    <h:inputText value="#{backingBean.current.id}" /> 
    <h:inputText value="#{backingBean.current.name}" /> 
    <h:inputText value="#{backingBean.current.value}" /> 
</row> 
<loop across "#{backingBean.listofItems}" with "item" variable> 
    <row> 
     <h:inputText value="#{item.id}" /> 
     <h:inputText value="#{item.name}" /> 
     <h:inputText value="#{item.value}" /> 
     <h:commandButton text="Edit" 
        actionListener="#{backingBean.editActionListener}" /> 
     <h:commandButton text="Save" actionListener="#{backingBean.saveActionListener}" 
        action="#{backingBean.saveAction}" /> 
    </row> 
</endloop> 
</table component> 
: 우리는 그래서 여기에 psuedocode 몇 가지 힌트입니다 유사한 화면의 숫자 ... XHTML의에서 지금
BackingBean { 
    // take a current variable to keep selected row 
    DataItem current; 
    // list of dataitems to show in grid 
    List<DataItem> listOfItems; 

    // Use ActionListener to set current 
    editActionListener(ActionEvent e){ 
     current = read via actionevent.getAttribute() 
    } 
    // Use save to save the data, reload the table, disable the button 
    saveAction(){ 
     ManagerBean.save(current); 
     reload listOfItems; 
     current = null; 
     disable save; 
    } 
} 

현재의 값을 보여을 사용했다
관련 문제