Thursday, May 16, 2013

Query to return fresh data


import org.eclipse.persistence.config.HintValues;
import org.eclipse.persistence.config.QueryHints;
...
@NamedQuery(name = "findSamplesById", 
query = "select s from Sample s where s.sample.id = :sampleId"), 
hints = {@QueryHint(name=QueryHints.REFRESH, value=HintValues.TRUE)}

Programmatical method

public List<Sample> getSamplesById() {
        try {
            Query query = em.createNamedQuery("findSamplesById");
            query.setParameter("sampleId", sampleId);
            query.setHint(QueryHints.REFRESH, HintValues.TRUE);
            return query.getResultList();
        } catch (Exception e) {
            log.error("getSamplesById() failed: " + e.getMessage());
            e.printStackTrace(System.err);
        }
 return null;
}

Tuesday, April 23, 2013

javascript submit is not a function

Javascript:
When you try to call submit() from javascript like the one below,
function addRule() {
var ff=document.forms["testForm"];
ff.wizardAction.value="ADD";
ff.submit();
}

Error Message:
submit is not a function

Resolution:
It means that you named your submit button or some other element submit. Rename such button(s) to some other name and your call will magically work.

When you name the button submit, you override the submit() function on the form.

dynamic id styleId struts html tag

If you want the html ids to be generated dynamically such as 
<input type="text" name="rule" id="rule0">

check this 
<% int index = 0; %>
<html:text property="rule" styleid='<%="rule"+index%>' />
<% index++;%>

Common mistake:
<html:text property="rule" styleid="rule<%=index%>">
shows up on html,
<input type="text" name="rule" id="rule<%=index%>">



Thursday, April 18, 2013

Gems Tibco JMS Putty Xming

Tibco Enterprise service (EMS) is a fully complaint JMS implementation from TIBCO with some added enhancements like load-balancing, routing, fault-tolerant configurations, which help improve performance and minimize failures in the server.

Gems is a graphical user interface utility for TIBCO Enterprise Message Service  (EMS). It can be used by JMS developers as a general purpose test debugging tool and by  administrative support staff as a management and monitorig tool.

What do we do with this ?? I am primarily using this to
  • Server Management. Including, general server configuration, JMS destinations,  JNDI factories, users/groups, permissions, bridges, routes etc.
  • JMS support. Messages may be sent/received, queues may be browsed and message  contents inspected. Selectors and filters may be specified.
  • JMS Message Monitoring. Messages may be monitored (snooped) as they pass trough  the server. Request and reply messages can be correlated to provide service  response times.
  • JMS Message Management. Eg; purging messages, copy messages from a queue to  another queue on a different server.
  • Security. SSL connectivity, view only mode.

    Can i access this gems from putty directly??? No, you need  Xming (http://sourceforge.net/projects/xming/)

    What is Xming??
    We can run graphical programs on Linux/Solaris machines remotely and display them on your desktop computer running Windows. We can do this by using running two applications together on your Windows machine: Xming and PuTTY.

    1. Navigate to the Files section and download:
    • Xming setup from the Xming folder
    • the fonts package installer from the Xming-fonts folder
    1. By default both programs will be installed into the same location, so don't the worry about over writing files. We cannot work without both packages.
    2. Once installed, running All Programs > Xming > XLaunch is a good idea to see what the configuration looks like. In most cases, the default options should be just fine.
    3. Finally run All Programs > Xming > Xming to start the PC X Server. The “X” icon should be visible on the Windows Taskbar. The X Server must be started before setting up a SSH connection to a remote system.
    What is PuTTY ?? 
    As we all know, PuTTY is a free SSH client. Through PuTTY we connect to a remote machine. 

    Any Configuration needed on PuTTY, to run GEMS??? Yes
    Under Session, enter the hostname, port 22, connection type is ssh
    Connection > SSH > X11. Check the box next to Enable X11 Forwarding. By default the X Display location is empty. You can enter localhost:0. The remote authentication should be set to MIT-Magic-Cookie-1

    navigate to the desired folder and run
    ./xxxxxx.sh &
    & runs the command in background so that you can work on your terminal and run the graphical application.


  • Wednesday, March 27, 2013

    extra white space in textarea

    <textarea>
    <c:forEach var="item" items="${items}">
    <c:out value="welcome"/>
    </c:forEach>
    </textarea>

    This gives unnecessary white spaces in the text area. Remove the extra white space between textarea tags. Although this might sound crazy, this works.

    <textarea><c:forEach var="item" items="${items}"><c:out value="welcome"/></c:forEach></textarea>



    Friday, March 15, 2013

    jmagick configuration


    1. Go to http://downloads.jmagick.org/6.3.9/
    2. Download ImageMagick-6.3.9-0-Q8-windows-dll.exe and jmagick-win-6.3.9-Q8.zip.
    3. Install the exe file. This will install ImageMagick which is a prerequisite for JMagick to work.
    4. Extract the zip file. This will give jmagick.dll and jmagick.jar
    5. Copy the jmagick.jar to you lib folder and include it in the classpath
    6. Copy the jmagick.dll to the root installation directory of ImageMagic and add it as an entry to the PATH environment variable

    Tuesday, March 5, 2013

    xmlbeans runtime error NoSuchMethodError


    You might get this run time error when you have two copies of proj-xmlbeans.jar on your classpath, one of which is a old one. 

    check your APP-INF directory. In my case, APP-INF is the culprit. It has the new generated xmlbeans version and the old one as well.