파일을 제출하기 전에 사용자에게 비밀번호를 입력하라고합니다. 그러므로 <h:panelGroup>
은 제출 버튼을 누른 후에 렌더링되어야합니다. 그러나 <h:panelGoup>
은 렌더링되지 않습니다.빈 필드 값을 기반으로 양식 렌더링
test.xhtml
<ui:define name="body">
<h:form id="uploadForm" enctype="multipart/form-data">
<table>
<t:inputFileUpload id="uploadedFile" storage="file"
value="#{UpdateBean.uploadedFile}"/>
<h:commandButton value="Submit" action="#{UpdateBean.submit()}"/>
</table>
</h:form>
<h:panelGroup id="checkPassword" rendered="#{UpdateBean.submitIsPerformed}">
<h:outputText id="message" value="${UpdateBean.message}" />
<h:inputText id="password" value="#{UpdateBean.password}" />
<h:commandButton value="submit" action="#{UpdateBean.submitPassword()}"/>
</h:panelGroup>
</ui:define>
UpdateBean.java
@ManagedBean(name = "UpdateBean")
@SessionScoped
public class UpdateBean {
protected boolean submitIsPerformed = false;
protected String password = "";
protected String message = "Input your password ";
// omit getter and setter
public void submit() {
this.setSubmitIsPerformed(true);
System.out.println(submitIsPerformed); // output is true
while(true) {
if(password.equals("123")) {
break;
}
}
// then process uploadedFile
}
public void submitPassword(){
if(password.equals("123")) {
message = "Password confirmed !";
} else {
message = "Password is wrong !";
}
}
}
은 (참)'정의? – ryanyuyu
@ryanyuyu submitIsPerformed에 대한 설정자입니다. – Bryan
@Tiny 당신이 의미하는 h : commandButton>? 나는 이것을 시도했지만 작동하지 않는다. –
Bryan