2017-11-27 14 views
0

위킷 신청이 있습니다. Page js 다음에 일부 Panel js 코드를 렌더링하려고합니다. 렌더링 UI를 renderHead 메서드로 사용하십시오.개찰구 머리 렌더링 순서

@Override 
public void renderHead(IHeaderResponse response) { 
    response.render(JavaScriptReferenceHeaderItem.forReference(new JavaScriptResourceReference(BasePage.class, "assets/js/core/jquery.min.js"))); 
    super.renderHead(response); 

    response.render(JavaScriptReferenceHeaderItem.forReference(new JavaScriptResourceReference(BasePage.class, "assets/js/core/popper.min.js"))); 
    response.render(JavaScriptReferenceHeaderItem.forReference(new JavaScriptResourceReference(BasePage.class, "assets/js/core/bootstrap.min.js"))); 
    response.render(JavaScriptReferenceHeaderItem.forReference(new JavaScriptResourceReference(BasePage.class, "assets/js/core/jquery.slimscroll.min.js"))); 
    response.render(JavaScriptReferenceHeaderItem.forReference(new JavaScriptResourceReference(BasePage.class, "assets/js/core/jquery.scrollLock.min.js"))); 
    response.render(JavaScriptReferenceHeaderItem.forReference(new JavaScriptResourceReference(BasePage.class, "assets/js/core/jquery.appear.min.js"))); 
    response.render(JavaScriptReferenceHeaderItem.forReference(new JavaScriptResourceReference(BasePage.class, "assets/js/core/jquery.countTo.min.js"))); 
    response.render(JavaScriptReferenceHeaderItem.forReference(new JavaScriptResourceReference(BasePage.class, "assets/js/core/js.cookie.min.js"))); 
    response.render(JavaScriptReferenceHeaderItem.forReference(new JavaScriptResourceReference(BasePage.class, "assets/js/codebase.js"))); 
} 

@Override 
public void renderHead(IHeaderResponse response) { 
    super.renderHead(response); 
    response.render(JavaScriptReferenceHeaderItem.forReference(new JavaScriptResourceReference(CompanySignUpPanelStep23.class, "CompanySignUpPanelStep23.js"))); 
} 

패널 JS 페이지 렌더링 jQuery를에 따라 패널에 일부 패널 관련 코드를 추가합니다.

wicket처럼 보이게하려면 internalRenderHead를 사용하십시오. 먼저 childs를 렌더링 한 다음 Own Head를 렌더링합니다.

/** 
* THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT. 
* 
* Print to the web response what ever the component wants to contribute to the head section. 
* Make sure that all attached behaviors are asked as well. 
* <p> 
* NOT intended for overriding by framework clients. Rather, use 
* {@link Component#renderHead(org.apache.wicket.markup.head.IHeaderResponse)} 
* </p> 
* 
* @param container 
*   The HtmlHeaderContainer 
*/ 
public void internalRenderHead(final HtmlHeaderContainer container) 
{ 
    if (isVisibleInHierarchy() && isRenderAllowed()) 
    { 
     if (log.isDebugEnabled()) 
     { 
      log.debug("internalRenderHead: {}", toString(false)); 
     } 

     IHeaderResponse response = container.getHeaderResponse(); 

     // Allow component to contribute 
     if (response.wasRendered(this) == false) 
     { 
      StringResponse markupHeaderResponse = new StringResponse(); 
      Response oldResponse = getResponse(); 
      RequestCycle.get().setResponse(markupHeaderResponse); 
      try 
      { 
       // Make sure the markup source strategy contributes to the header first 
       // to be backward compatible. WICKET-3761 
       getMarkupSourcingStrategy().renderHead(this, container); 
       CharSequence headerContribution = markupHeaderResponse.getBuffer(); 
       if (Strings.isEmpty(headerContribution) == false) 
       { 
        response.render(StringHeaderItem.forString(headerContribution)); 
       } 
      } 
      finally 
      { 
       RequestCycle.get().setResponse(oldResponse); 
      } 
      // Then let the component itself to contribute to the header 
      renderHead(this, response); 

      response.markRendered(this); 
     } 

     // Then ask all behaviors 
     for (Behavior behavior : getBehaviors()) 
     { 
      if (isBehaviorAccepted(behavior)) 
      { 
       if (response.wasRendered(behavior) == false) 
       { 
        behavior.renderHead(this, response); 
        List<IClusterable> pair = Arrays.asList(this, behavior); 
        response.markRendered(pair); 
       } 
      } 
     } 
    } 
} 

주문을 결정하는 방법이 있습니까?

답변

1

대신 Wicket HeaderItem/ResourceReference 종속성을 사용해야합니다.

귀하의 JavaScriptResourceReference#getDependencies() 메소드를 오버라이드 (override) jQuery.js에 대한 ResourceReference를 포함하는 List를 반환해야 Panel.js합니다. 이렇게하면 각 리소스는 의존성을 선언하고 Wicket은 올바른 순서로 렌더링합니다. 예 : WicketAjaxJQueryResourceReference을 참조하십시오.