Changeset 2129


Ignore:
Timestamp:
Mar 30, 2006, 9:50:56 AM (17 years ago)
Author:
Martin Svensson
Message:

Fixes #161 Add support for showing help texts in the GUI

Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/Help.java

    r2108 r2129  
    3838  <pre>
    3939    &lt;%@ taglib prefix="base" uri="/WEB-INF/base.tld" %&gt;
    40     &lt;base:help help_id="required_helpsectionID" /&gt;
     40    &lt;base:help help_id="required_helpexternalID" /&gt;
    4141  </pre>
    4242 
     
    4444  <b>Syntax:</b>
    4545  <pre>
    46   &lt;base:icon
    47     id=...
     46  &lt;base:help
    4847    helpid=...
    4948    clazz=...
     
    6463    </tr>
    6564    <tr>
    66       <td>id</td>
    67       <td>-</td>
    68       <td>no</td>
    69       <td>
    70         The ID of the help. The value of this attribute goes
    71         directly into the standard <code>id</code> attribute.
    72         This means that if you need a reference to the note object in your own
    73         JavaScript code, you may for example use the following code:
    74         <p>
    75         <code>
    76           help = document.getElementById('&lt;id&gt;');
    77         </code>     
    78       </td>
    79     </tr>
    80     <tr>
    8165      <td>helpid</td>
    8266      <td></td>
     
    8670        to be identified with.         
    8771      </td>
    88     </tr>
     72    </tr>   
    8973    <tr>
    9074      <td>clazz</td>
     
    200184    return this.helpid;
    201185  }
    202  
     186   
    203187  public void setClazz(String clazz)
    204188  {
     
    259243  {
    260244    page = (Page)findAncestorWithClass(this, Page.class);
    261     if (page == null) throw new JspTagException("Tag <base:icon> must be inside a <base:page> tag");
     245    if (page == null) throw new JspTagException("Tag <base:help > must be inside a <base:page> tag");
    262246    if (!isVisible()) return SKIP_BODY;
    263247   
    264248    String theStyle = getStyle();
     249   
    265250    if (getOnClick() != null)
    266251    {
    267252      theStyle = Values.getString(theStyle) + "cursor: pointer;";
    268253    }
    269    
    270254    StringBuilder sb = new StringBuilder();
    271     sb.append("<a href=\"javascript:Main.openHelp('").append(getHelpid()).append("')\">");   
    272     sb.append("<img border=0");
    273     if (getId() != null) sb.append(" id=\"").append(getId()).append("\"");
     255    sb.append("<a href=\"javascript:Main.openHelp('").append(pageContext.getRequest().getParameter("ID"));
     256    sb.append("' ,'").append(getHelpid()).append("')\">");   
     257    sb.append("<img border=0");   
    274258    if (getClazz() != null) sb.append(" class=\"").append(getClazz()).append("\"");
    275259    if (theStyle != null) sb.append(" style=\"").append(theStyle).append("\"");
  • trunk/src/core/common-queries.xml

    r2104 r2129  
    16111611    </description>
    16121612  </query>
     1613 
     1614  <query id="GET_HELP_FOR_EXTERNAL_ID" type="HQL">
     1615    <sql>
     1616      SELECT hlp
     1617      FROM HelpData hlp
     1618      WHERE hlp.externalId = :externalId AND hlp.client = :client
     1619    </sql>
     1620    <description>
     1621      A Hibernate query that loads a help text.
     1622    </description>
     1623  </query>
    16131624
    16141625</predefined-queries>
  • trunk/src/core/net/sf/basedb/core/Client.java

    r2021 r2129  
    2626
    2727import net.sf.basedb.core.data.ClientData;
     28import net.sf.basedb.core.data.HelpData;
    2829import net.sf.basedb.core.query.Restrictions;
    2930import net.sf.basedb.core.query.Expressions;
     
    275276    return Help.getQuery(this);
    276277  }
    277 
     278 
     279  /**
     280    Get a <code>Help</code> item when you know the external ID.
     281 
     282    @param dc The <code>DbControl</code> which will be used for
     283      permission checking and database access.
     284    @param externalId The external id of the item to load
     285    @return The <code>Help</code> item
     286    @throws ItemNotFoundException If an item with the specified ID is not found
     287    @throws PermissionDeniedException If the logged in user doesn't have
     288      {@link Permission#READ READ} permission for the item
     289    @throws BaseException If there is another error
     290  */
     291  public Help getHelpByExternalId(DbControl dc, String externalId)
     292    throws ItemNotFoundException, PermissionDeniedException, BaseException
     293  {
     294    org.hibernate.Query query = HibernateUtil.getPredefinedQuery(dc.getHibernateSession(),
     295      "GET_HELP_FOR_EXTERNAL_ID");
     296    /*
     297      SELECT hlp
     298      FROM HelpData hlp
     299      WHERE hlp.externalId = :externalId AND hlp.client = :client
     300    */
     301    query.setString("externalId", externalId);
     302    query.setEntity("client", getData());
     303    Help h = dc.getItem(Help.class, HibernateUtil.loadData(HelpData.class, query));
     304    if (h == null) throw new ItemNotFoundException("Help[externalId="+externalId+"]");
     305    return h;
     306  }
    278307}
    279308
  • trunk/www/WEB-INF/base.tld

    r2108 r2129  
    304304    <tagclass>net.sf.basedb.clients.web.taglib.Help</tagclass>
    305305    <attribute>
    306       <name>id</name>
    307       <required>false</required>
    308       <rtexprvalue>true</rtexprvalue>
    309     </attribute>
    310     <attribute>
    311306      <name>helpid</name>
    312307      <required>true</required>
    313308      <rtexprvalue>true</rtexprvalue>
    314     </attribute>
     309    </attribute>   
    315310    <attribute>
    316311      <name>clazz</name>
  • trunk/www/include/scripts/main.js

    r2113 r2129  
    9595    url += '&disabled='+(disabled ? '1' : '0');
    9696    Main.openPopup(url, title.replace(/[^\w]/g, ''), 640, 550);
     97  }
     98 
     99  /*
     100      Opens a popupwindow with helptext
     101     
     102      @param session The ID of the session.
     103      @param helpid The id of the helptext to be displayed.
     104  */
     105  this.openHelp = function(sessionid, helpid)
     106  {
     107    var url = getRoot()+'common/help/view_help.jsp?ID='+sessionid+'&external_id='+helpid;
     108    Main.openPopup(url, 'Help', 640, 550);
    97109  }
    98110 
Note: See TracChangeset for help on using the changeset viewer.