Search the OSCAR Documentation
< All Topics
Print

Developer’s Corner

Coding Pointers

Internationalization

OSCAR depends on the browser locale to signal which language to serve labels. Thus OSCAR is extensively i18n tagged with keys kept in resource files based on the language. For English we use oscarResources_en.properties to keep the key and its value. Both new and reworked code should avoid English UI labels and instead add values to the English language resource file.

UI Look and Feel

UI we try to keep it consistent with an older Bootstrap. You will note that the blue raised buttons for indicating the primary button class=”btn btn-primary” is a convention used throughout OSCAR to make the interface more intuitive.

https://bootstrapdocs.com/v2.3.1/docs/index.html

Font awesome should be used for icons and they are already in OSCAR
oscar/src/main/webapp/css/font-awesome.min.css

https://fontawesome.com/v3.2/cheatsheet/

The icons are black and can be styled whatever colour and size you want
Treat them as fonts for CSS

To link Bootstrap and Font awesome in an OSCAR JSP to use, add the following:

<link href="<%=request.getContextPath() %>/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="<%=request.getContextPath() %>/css/datepicker.css" rel="stylesheet" type="text/css">
<link href="<%=request.getContextPath() %>/css/DT_bootstrap.css" rel="stylesheet" type="text/css">
<link href="<%=request.getContextPath() %>/css/bootstrap-responsive.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="<%=request.getContextPath() %>/css/font-awesome.min.css">
<link rel="stylesheet" href="../css/helpdetails.css" type="text/css">

When possible entertain using Data-tables (also embedded in OSCAR) for displaying tabular output.

UI Security

Don’t assume that the end user of OSCAR is benign or can’t be tricked to save malicious content into the database. Even with the login data is transfered to OSCAR potentially to be displayed (with malicious code being run) when a log file is displayed. You must assume that the database has untrustable content and escape it. OSCAR is using the OWASP library to prevent arbitrary injection.

Rather than

document.forms[0].notes.value = "<%= apptObj.getNotes() %>";

Include the library in the JSP and escape the content

<%@page import="org.owasp.encoder.Encode" %>

....
document.forms[0].notes.value = "<%= Encode.forHtmlAttribute(apptObj.getNotes()) %>";

TIP: do this at the last step before it becomes visible in the browser. If you don’t you risk missing bits or double encoding.

Stylecheck

Try to compile your code without unit testing to have the stylecheck plugin examine your code. Certain forms and approaches are deprecated (eg Vectors) to ensure consistency.

Libraries

Everything from Angular to Jquery to Bootstrap to Apache Commons libraries moves through a series of versions. For ease of maintenance please use EXISTING libraries in OSCAR unless they don’t work or are insecure.

Linking Master Record in Developed JSP
<%=request.getContextPath() %>/demographic/demographiccontrol.jsp?demographic_no=<%=patient.getDemographicNo()%>&displaymode=edit&dboperation=search_detail)

TIP: use <%=request.getContextPath() %> to link various items in OSCAR in a developed JSP.
<%=request.getContextPath() %> is the oscar folder: /var/lib/tomcat9/webapps/oscar

Copyright Copy Paste Block for JSP
<%--

    Copyright (c) 2001-2002. Department of Family Medicine, McMaster University. All Rights Reserved.
    This software is published under the GPL GNU General Public License.
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

    This software was written for the
    Department of Family Medicine
    McMaster University
    Hamilton
    Ontario, Canada

--%>
Table of Contents