2014-11-14 3 views
0

페이지간에 전환 할 때 양식 페이지에 상태를 캐시하고 싶습니다.Eclipse 스카우트 캐시 양식 페이지

So : 양식이있는 3 페이지가 있으며 하나에서 다른 것으로 전환 할 때 데이터를 양식에 유지하고 싶습니다.

나는이 발견 https://wiki.eclipse.org/Scout/Concepts/Page_Detail_Form

@Override 
protected void execPageActivated() throws ProcessingException { 
    if (getDetailForm() == null) { 
    PersonDetailForm form = new PersonDetailForm(); 
    form.setPersonNr(getPersonNr()); 
    setDetailForm(form); 
    form.startView(); 
    } 
} 

및 setDetailForm()가 캐시

As already said, attaching a detail form to a page means the detail form will automatically be 
hidden when the page gets deactivated and shown when the page gets activated (see 
PageDetailFormChanged on Desktop). So the detail form actually gets cached and does not need to 
be started more than once per page. This requires that the form does not get closed. 

을 datas 그러나 이것은 나를 위해 작동하지 않는 것을 말한다.

내 코드

@Override 
protected void execPageActivated() throws ProcessingException { 

    ///Create and open form 
    if (getDetailForm() == null) { 
     MarginCalculationForm form = new MarginCalculationForm(); 
     form.startModify(); 
     setDetailForm(form); 
    } 

    super.execPageActivated(); 
} 

이지만 마지막 페이지에 유지됩니다. 예를 들어

:

내가 페이지 A를 가지고 있다면, B, C와 I는 페이지 A를 열

는 그것 자체를 만들고 detailForm로 설정(). 그러면 페이지 B를 열어도 괜찮습니다.

I : 다음 페이지 A를 클릭하면 detailForm가() (그렇지 않은) null는 아니고, 그래서 페이지 B에 남아하지만 다시 확인

EDIT (페이지 A를가는 insted) getDetailForm()이 올바른 양식을 반환하고 있지만 super.execPageActivated()가 작동하지 않는 것 같습니다.

+0

내 작업 영역에서 문제를 재현하는 관리하지 않습니다. execPageActivated()에 중단 점이 있습니다. 처음 페이지를 클릭하면 getDetailForm()이 null이고 양식이 인스턴스화됩니다. 나는 다른 곳을 클릭한다. 그 다음에 같은 페이지를 다시 방문하면 getDetailForm()은 null이 아니며 이전 instanciated 양식 (이 페이지 인스턴스에 해당)이 다시 표시됩니다. "페이지가 활성화 될 때마다 양식을 새로 고침"한다는 것은 무엇을 의미합니까? – Jmini

+0

나는 나의 질문을 편집한다. 이전 동작은 내 서버를 다시 시작하지 않아서였던 것 같습니다. –

+0

클라이언트 콘솔 로그에 stacktrace 또는 이와 유사한 항목이 있습니까? – Jmini

답변

0

무엇이 잘못되었는지 알아 냈습니다.

문제가 스카우트의 DefaultPageChangeStrategy 클래스에 있습니다.

@Override 
public void pageChanged(IOutline outline, IPage deselectedPage, IPage selectedPage) { 
    if (outline == null) { 
    return; 
    } 

    outline.clearContextPage(); 
    IForm detailForm = null; 
    ITable detailTable = null; 
    ISearchForm searchForm = null; 
    // new active page 
    outline.makeActivePageToContextPage(); 
    IPage activePage = outline.getActivePage(); 
    if (activePage != null) { 
    try { 
     activePage.ensureChildrenLoaded(); 
    } 
    catch (ProcessingException e1) { 
     SERVICES.getService(IExceptionHandlerService.class).handleException(e1); 
    } 
    if (activePage instanceof IPageWithTable) { 
     IPageWithTable tablePage = (IPageWithTable) activePage; 
     detailForm = activePage.getDetailForm(); 
     if (activePage.isTableVisible()) { 
     detailTable = tablePage.getTable(); 
     } 
     if (tablePage.isSearchActive()) { 
     searchForm = tablePage.getSearchFormInternal(); 
     } 
    } 
    else if (activePage instanceof IPageWithNodes) { 
     IPageWithNodes nodePage = (IPageWithNodes) activePage; 
     detailForm = activePage.getDetailForm(); 
     if (activePage.isTableVisible()) { 
     detailTable = nodePage.getInternalTable(); 
     } 
    } 
    } 

    // remove first 
    if (detailForm == null) { 
    outline.setDetailForm(null); 
    } 
    if (detailTable == null) { 
    outline.setDetailTable(null); 
    } 
    if (searchForm == null) { 
    outline.setSearchForm(null); 
    } 
    // add new 
    if (detailForm != null) { 
    outline.setDetailForm(detailForm); 
    } 
    if (detailTable != null) { 
    outline.setDetailTable(detailTable); 
    } 
    if (searchForm != null) { 
    outline.setSearchForm(searchForm); 
    } 
} 
} 

그리고 그것은 activePage AbstractPage (그리고 AbstractPageWithTableAbstractPageWithNode) 인 경우, detailForm 항상 null이며,이 브레이크 동작 : 방법 pageChanged()이 같다.

그래서 솔루션 라인을이 줄은 (는) 전나무 시간 시작 페이지 제시되지 않습니다 아니기 때문에 경우에 필요

setTableVisible(false); 

을 AbstractPageWithNode와 AbstractPage을 변경하고 추가하는 것입니다. (nodePage.getInternalTable()는 null가 아닌하지만 그렇게 비어 :

if (detailTable != null) { 
    outline.setDetailTable(detailTable); 
    } 

빈 페이지를 제공합니다.)