1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice
Hey Guest, we are running a Photoshop competition with a 32" monitor as the first prize - See here for details.

Can someone tweak this js for me?

Discussion in 'HTML, Graphics & Programming' started by Whoop, Apr 15, 2019 at 12:32 PM.

  1. Whoop

    Wise Guy

    Joined: Nov 27, 2003

    Posts: 2,329

    Location: Loughborough

    Long story short, we have a html based dashboard that shows information down the side of the work area. This particular part has an expander on that I don't want in there and I haven't got the foggiest idea which part to remove.

    Can anyone highlight the relevant code/take it off so it just displays without requiring you to click the + ? Thanks (I hope) :)

    Code:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %>
    <%@ page import="com.aibuild.ui.uiserver.*" %>
    <%@ page import="com.aibuild.util.*" %>
    <%@ page import="java.util.*" %>
    <%// Create and hook up the objects we need...
    DashboardPartServer thisDashboard = new DashboardPartServer(pageContext);
    ContextInformation context = thisDashboard.getContext();
    /////////////////////////////////////////////////////////////////////%>
    <%
        String ordref = context.getParameter("ordref");
        if (StringUtil.isEmpty(ordref))
        {
            thisDashboard.hidePart();
            return;
        }
        String product = context.getParameter("product");
        if (StringUtil.isEmpty(product))
        {
            thisDashboard.hidePart();
            return;
        }
        String customer = context.getParameter("customer");
        if (StringUtil.isEmpty(customer))
        {
            thisDashboard.hidePart();
            return;
        }
     customer = customer.replaceAll("&","&amp;");
        String priority = context.getParameter("priority");
        //String titleStr = "Sales Promotions for order "+ordref;
        String titleStr = "<font color='ff0000'><strong>Promotion Available</strong></font>";
    
        Promotions promotions = (Promotions)context.getService("promotions");
        ArrayList<Promotion> PromotionList = promotions.getPromotionsByOrder(product, ordref, customer, priority);
        
        StringBuffer strHTML = new StringBuffer();
    
    /*
                         for (int i = 0; i < PromotionList.size();i++)
        {
            //strHTML.append("<b>Promotion No.").append(i+1).append("</b><br/>\n");
            Promotion promotion = PromotionList.get(i);
            //if (!StringUtil.isEmpty(promotion.pCode))
            //    strHTML.append("PCode:").append(promotion.pCode).append("<br/>\n");
            // The promotion.text is HTML and may contain images etc, so you might not want to show it.
            //if (!StringUtil.isEmpty(promotion.text))
            //    strHTML.append(promotion.text).append("<br/>\n");
            //if (!StringUtil.isEmpty(promotion.customerText))
            //    strHTML.append(promotion.customerText).append("<br/>\n");
            //if (!StringUtil.isEmpty(promotion.description))
            //    strHTML.append(promotion.description).append("<br/>\n");
            if (!StringUtil.isEmpty(promotion.smallText))
                strHTML.append(promotion.smallText).append("<br/>\n");
        }
        
    */
                        for (int i = 0; i < PromotionList.size();i++)
        {
        Promotion promotion = PromotionList.get(i);
    
        Expander exp = thisDashboard.getExpander();
                         // A fixed section always appears before the expandable bit
                         // exp.addFixedSection(promotion.customerText);
                         StringBuffer promStr = new StringBuffer();
                         promStr.append(promotion.smallText).append("<br/>\n");
                         //promStr.append("<font color='red' >").append(promotion.smallText).append("</font><br/>\n");
    
                         //promStr.append("<font color='red' >").append(promotion.customerText).append("</font><br/>\n");
                         //promStr.append("PCode:").append(promotion.pCode).append("<br/>\n");
    
                        if (!StringUtil.isEmpty(promotion.text))
                        promStr.append(promotion.text).append("<br/>\n");
                        //if (!StringUtil.isEmpty(promotion.customerText))
                       //  strHTML.append(promotion.customerText).append("<br/>\n");
                       //if (!StringUtil.isEmpty(promotion.description))
                       //  promStr.append(promotion.description).append("<br/>\n");
                       //if (!StringUtil.isEmpty(promotion.smallText))
                       //promStr.append(promotion.smallText).append("<br/>\n");
    
                       exp.addSection(promStr.toString());
                       strHTML.append(exp.render());
    
        }
    
        thisDashboard.renderPart(titleStr, strHTML.toString());
    %>
     
  2. kaku

    Wise Guy

    Joined: May 21, 2013

    Posts: 1,796

    That's not javascript, it looks like some kind of Java-based templating system that runs on the server and spits our raw HTML.

    Probably worth looking at the Expander class definition because it's not obvious from that snippet how it works. Alternatively, do away with the Expander entirely and append the contents directly to strHTML.
     
  3. PaulStat

    Soldato

    Joined: Mar 1, 2003

    Posts: 5,383

    Location: Cotham, Bristol

    Looks like jsp to me. Comment this bit

    Code:
    strHTML.append(exp.render());
    And add this in its place

    Code:
    strHTML.append(promStr.toString());
     
    Last edited: Apr 16, 2019 at 8:53 AM
  4. Whoop

    Wise Guy

    Joined: Nov 27, 2003

    Posts: 2,329

    Location: Loughborough

    This.... appears to do exactly what I need!

    Thanks both :D