2009-01-31 5 views
8

Apache BeeHive를 사용하고 있습니다. 내 JSP에는 드롭 다운 상자 (< netui : select >)와 제출 버튼 (< netui : 양식 >) 및 제출 버튼 (< netui : button >)이 포함되어 있습니다. 드롭 다운에서 옵션을 선택하면 다른 작업 ("doAction2")이 제출되기를 원합니다 .. (그림 1 참조)선택 변경 이벤트를 기반으로하는 다양한 양식 작업

내 첫 번째 경향은 양식의 액션 속성을 새 액션 이름으로 변경 한 다음 양식을 제출 (그림 2 참조)하지만 작동하지 않습니다.이 태그가 변환됨을 알게되었습니다. "doAction1"을 http://localhost:7001/app/doAction1.do과 같은 전체 URL로 변경하십시오.

JavaScript submitForm (form, newAction) 메소드에 전달하는 "doAction2"문자열은 "doAction2"를 적절한 URL로 변환 할 수 없습니다 그것은, 그러나 단지 kludgey 방법으로) 할 수 있었다. 일반 작업 이름을 URL로 변환 할 수있는 netui 태그를 찾으러 갔지만 찾을 수는 없습니다.

그래서 이것을 달성하는 올바른 방법은 무엇입니까?

그림 1 - JSP 코드 조각

<netui:form action="doAction1" method="post"> 
    <netui:select dataSource="actionForm.field1" 
        optionsDataSource="${actionForm.field1Selections}" 
        onChange="submitForm(this.form, 'doAction2')"/> 

    <p/> 
    <netui:button>Submit</netui:button> 
</netui:form> 

그림 2 - 양식을 양식 작업을 변경하고 제출 자바 스크립트 기능

<netui:scriptBlock placement="before"> 

    function submitForm(form, newAction) { 
     form.action = newAction; 
     form.submit();    
    } 

</netui:scriptBlock> 

답변

0
function submitForm(form, newAction) { 
    form.action = newAction + ".do"; 
    form.submit();     
} 

또는

<c:url var="newActionUrl" value="/the/path/to/the/action/doAction2.do"/> 

<netui:select dataSource="actionForm.field1" 
       optionsDataSource="${actionForm.field1Selections}" 
       onChange="submitForm(this.form, '${newActionUrl}')"/> 
관련 문제