コード例 #1
0
 public void afterPhase(PhaseEvent event) {
   FacesContext facesContext = event.getFacesContext();
   AddResource addResource = AddResourceFactory.getInstance(facesContext);
   String jsTxt = genJavaScriptCodeForMessages(facesContext);
   if (jsTxt != null) {
     addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, jsTxt);
   }
 }
コード例 #2
0
  @SuppressWarnings("unchecked")
  public void beforePhase(PhaseEvent event) {
    FacesContext facesContext = event.getFacesContext();
    UIViewRoot root = facesContext.getViewRoot();
    AddResource addResource = AddResourceFactory.getInstance(facesContext);
    addReferences(facesContext, addResource);
    visitComponent(facesContext, root);
    //        String jsTxt = genJavaScriptCodeForMessages(facesContext);
    //        if (jsTxt != null) {
    //            addResource.addInlineScriptAtPosition(facesContext,
    //                AddResource.HEADER_BEGIN, jsTxt);
    //        }

    String styleSheetCode = genStyleCode(facesContext);
    if (styleSheetCode != null) {
      addResource.addInlineStyleAtPosition(facesContext, AddResource.HEADER_BEGIN, styleSheetCode);
    }
  }
コード例 #3
0
  private static void addReferences(FacesContext facesContext, AddResource addResource) {

    //        addBodyEndJavaScriptRef(facesContext, addResource, "prototype.js");
    //        addBodyEndJavaScriptRef(facesContext, addResource, "fx4web.js");
    addJavaScriptRef(facesContext, addResource, "jquery-1.10.2.js");
    //        addResource.addJavaScriptAtPosition(facesContext,
    //            AddResource.HEADER_BEGIN,
    // "http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js");
    addResource.addInlineScriptAtPosition(
        facesContext, AddResource.HEADER_BEGIN, "var $j = jQuery.noConflict();");
    addJavaScriptRef(facesContext, addResource, "initPages.js");
    addJavaScriptRef(facesContext, addResource, "prototype.js");
    addJavaScriptRef(facesContext, addResource, "fx4web.js");

    addJavaScriptRef(facesContext, addResource, "ieSpell.js");
    addStyleSheetRef(facesContext, addResource, "fx4web.css");

    // get the district id from config file and set the appropriate css
    String district =
        ConfigService.getInstance().getAttributeString("ereg", "appSettings", "district");
    addStyleSheetRef(facesContext, addResource, district.toLowerCase() + ".css");
  }
コード例 #4
0
 private static void addBodyEndJavaScriptRef(
     FacesContext facesContext, AddResource addResource, String uri) {
   addResource.addJavaScriptAtPosition(facesContext, AddResource.BODY_END, "/js/" + uri);
 }
コード例 #5
0
 private static void addJavaScriptRef(
     FacesContext facesContext, AddResource addResource, String uri) {
   addResource.addJavaScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, "/js/" + uri);
 }
コード例 #6
0
 private static void addStyleSheetRef(
     FacesContext facesContext, AddResource addResource, String uri) {
   addResource.addStyleSheet(facesContext, AddResource.HEADER_BEGIN, "/css/" + uri);
 }