Follow by Email

Tuesday, December 23, 2014

Spring : How to escape HTML in all the pages of your application

 
 
In Spring we can escape HTML in all JSP pages generated by < form > tags.
 
 
For entire application put below lines in your web.xml
 

<context-param>
    <param-name>defaultHtmlEscape</param-name>
    <param-value>true</param-value>
</context-param>
 
 
For more details see the below stackoverflow thread
 

Wednesday, December 10, 2014

Tinymce multiple textareas block problem


Problem :

I am using Internet Explorer , I have 4 text editors in one page all TimyMCE , the problem I am facing is that I am able to enter text in first editor however when I click on next textarea I can't type anything in it however I can see the cursor blinking in it

I have also noticed
  1. If i use tab to go to 2nd editor I am able to type , but when I use mouse to click on that textarea I can't type.
  2. I have waited for enough time to allow scipts to be loaded properly but I still face the same problme.
I am running Internet explorer in below mode

meta http-equiv="X-UA-Compatible" content="IE=8"  Shifitng it to IE=9 seems to resolve problems , but I want to run my application as IE=8. 


Solution :

I found that the latest TinyMCE editor version 4.X was not working very welll will the older browser compatibility IE=8 , being in that mode is a must for me right now because of some other dependent scripts which create problems in IE=9 .
 
So I decided to use an older version of TinyMCE 3.X which appeared to be compatable and now the applicaiotn is working fine.

 

Tuesday, November 25, 2014

HTML TD Can't Wrap text , grows with the size of line and mess up the witdh of the TD



I am using Internet Explorer 9.

A dynamicaly generated text having a very long line when displayed in a TD in my HTML table mess up the whole width of the TD which basically grows to fit the whole line and doesn't automaticaly wrap text

applying wrap text CSS on TD is not working , The solution was to apply the below style at table level

style="width: 100%; table-layout: fixed;"

I didn't even need to apply text wraping to my TDs.




Below Thread was very helpfull

http://stackoverflow.com/questions/1057574/html-td-wrap-text

and the solution which worked for me in this thread is copy pasted below

table-layout:fixed will resolve the expanding cell problem, but will create a new one. IE by default will hide the overflow but Mozilla will render it outside the box.
Another solution would be to use: overflow:hidden;width:?px
<table style="table-layout:fixed; width:100px">
 <tr>
   <td style="overflow:hidden; width:50px;">fearofthedarkihaveaconstantfearofadark</td>
   <td>
     test
   </td>
 </tr>
</table>
 
Since I am using IE I had to only use
 
style="width: 100%; table-layout: fixed;"
 
for my table.
 

Wednesday, October 8, 2014

oracle How can I tell where my database function was used




http://stackoverflow.com/questions/4670164/how-can-you-tell-if-a-pl-sql-package-procedure-or-function-is-being-used
 
As mentioned in the above stackoverflow thread , below query can be used to find where your database function/procedure has been used.
 
SELECT * FROM all_source where UPPER(TEXT) like UPPER('%YOUR_DATABASE_FUNCTION_NAME%')
 
The oracle documentation for all_sources can be found at below link
 
 http://docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_2063.htm 


Below post is also very informative

http://oracletuts.net/sql/how-to-search-code-using-user_source-and-all_source-in-sql/
 

Thursday, September 25, 2014

Crystal report passing string date parameter to a report from my jsp page


Problem Statement :

Just found out that passing a string attribute from my jsp page to a crystal report is not working and the report was asking for the date parameter again.

Solution :

Thanks to a thread on stackoverflow , the solution was to create date string as

#9/25/2014# and then pass it to crystal report from my page and now it's working fine.

 

Monday, September 8, 2014

Eclipse saving workbench state hangs

I followed the below instructions in the blog

  • Make a backup of your “.metadata“-folder (very important!!) (this folder inside teh eclipse workbench/workspace folder)
  • navigate into the “.plugins“-folder located inside “.metadata
  • delete the folder “org.eclipse.ui.workbench
  • startup eclipse again and check if there is still everything you need


  • http://blog.elitecoderz.net/repair-eclipse-workbencheclipse-workbench-reparieren/2009/06/comment-page-1/#comment-6693

    and the problem was resolved , now when I close my eclipse it doesn't hang at saving workbench state.

    infact I have noticed that the eclipse is starting a closing faster than before.

    Usefull Oracle Database Queries


    Get the details of important oracle parameters such as "PASSWORD_LOCK_TIME" and "SESSIONS_PER_USER" etc

    select * from dba_profiles order by profiles

    Get the Name of the oracle instance

    SELECT sys_context('USERENV','DB_NAME') AS Instance FROM dual;
    Get the name of the current oracle instance and user id

     select name,user from v$database


    Query to see who has access to your package


    select grantee, table_name, privilege
         from dba_tab_privs
         where
           table_name = 'YOUR_PACKAGE_NAME'


    Query to see what tables are being used in your package
    SELECT a.owner schema_name,a.name package_name,a.referenced_name table_name,b.COMMENTSFROM dba_dependencies a,dba_tab_comments bWHERE TYPE IN ('TABLE', 'PACKAGE BODY')

    and referenced_type ='TABLE'

    and name like ('%CSAS%')

    and a.REFERENCED_NAME=b.TABLE_NAME







    /*select * from dba_tab_comments where comments is not null*/












    I will keep adding other usefull queries here....

    java.net.SocketException: Connection reset

    One reason of this exception I have noticed is when user clicked on a link in your website and before it was loaded completly user clicked anotehr link on the same page.

    This causes
    java.net.SocketException: Connection reset

    Sunday, August 10, 2014

    Oracle Splitting String into multiple rows


    I used below query to split a comma separated string to rows in oracle

    select regexp_substr(a.col1,'[^,]+', 1, level) RT_PARAM_NAME from

            (select 'a,b,c,d' col1 from dual) a

            connect by regexp_substr(a.col1,'[^,]+', 1, level) is not null  



    Note the regular expression '[^,]+' which basically tells the query to use , as a delimeter , and note the use of level and connect by.

    Wednesday, August 6, 2014

    ORA-01422: exact fetch returns more than requested number of rows


    This error normaly means that the query fetched more than one records , while it was expected to return only one record (in cases where you are using in clause in a query to assign the result to a variable , you are assuming it will always retun only one row but at the time of this exception it is returning more rows).

    If this is the case the solution is very simple , introduce more strict criteria in your query to make sure that it alwasy returns only one row.

    How ever I also faced this exception in another interesting case.

    Problem:

    In my oracle function I was passing a parameter and the name of the parameter was "alert_id" , then I was comparing the value of this parameter with a field in the query below


    select a.message into html from  My_Table a where a.alert_id=alert_id;

    I double checked there was only one record in the databas with that alert_id , but inside trhe function when i was running this query it was giving me ORA-01422 again which did not make sense.

    Solution:

    I found that the problem was that the name of the field in the database and the name of the parameter was same (alert_id in my case) , when you do that you will face this problem because oracle will pace the current value in the database field after the = sign , so my query was getting interprated as (suppose alertid in the data base is 5380)

    select a.message  from  rtoc.rtoc_alert a where 5380=5380;

    when I ran the above query in PL/SQL it showed me more than one records.

    Moral of the story :)

    Naver use the parameter names ina  function which have any possibility of exsitance in tables you are using in your function.

    Suggessted Naming Convention

    function parameters should start with "p_" ==> "p_alert_id"
     variables declared whould start with  "v_"


     

    Monday, August 4, 2014

    Caused by: java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream

    I was getting this error in my eclipse project , pressing ctrl+t and finding for this class I found that it was avaialable in one of my jar files in the maven m2 directory under below jar file

    commonns-io-2.1.jar

    So I was considering that it is in my class path already , but I was wrong.

    I soon found out that the dependency related to this jar file in my pom was mistakenly commented out and because of that the jar file was not included in my war.

    so I uncommented the below dependency in my pom file

      <dependency>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
       <version>2.1</version>
      </dependency>
    and recompiled the project nd nwo it's running fine.
     

    Summary:

    NoClassDefFoundError means the related jar is not in your classpath and ctrl+t shows you only to which jar file a class belongs to . it doesn't mean that the jar file is in your classpath ( It's a reminder for myself :)  ) .

    Sunday, August 3, 2014

    java.lang.IllegalAccessError: tried to access class com.documentum.bpm.WorkflowVariables from class com.documentum.bpm.impl.DfWorkflowEx

    We recently migrated from documentum 6.5 to 7.1 , and had to retest our code with new documentum jar files.

    I found that bpm_infra.jar file was not any more in the new documentum lib folder so removed it from my class path , but I started getting "IDfWorkflowEx cannot be resolved to a type" compiler error.

    This was understood as in the old version we had the related jar file "dpm_infra.jar". I also tried to keep the jar file in class path and then was able to compile and execute the project and even initiate the workflow successfully , but when i was trying to process a workflow item I was getiing the exception

    java.lang.IllegalAccessError: tried to access class com.documentum.bpm.WorkflowVariables from class com.documentum.bpm.impl.DfWorkflowEx


     Luckily I found an epert friend who adviced me to just comment the code as it was not really being used anywhere in my applicaiton (I was using a custom API to do docuemntum operations ) , so after commenting the related code and removing the dpm_infra.jar file from my classpath I was able to do all the workflow operations and file uploads and downloads.





     

    Java was started but returned exit code=13

    I was getting this error when i was trying to run my eclipse

    Here is the solution

    • Open your eclipse.ini file and see which javaw.exe file you are trying to use
      • in my case it was C:\Program Files\Java\jdk1.7.0_55\bin\javaw.exe
    • I am using windows64bit platform.
    • Open cmd and run java -version
      • This will tell you which java version you are currently using (like below)
    java version "1.7.0_55"
    Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)
    • Notice the 3rd line which is telling my I am currently using the 64bit java , but that is not what I see in my eclipse.ini file (There it's 32 bit java)
    • So I changed it like below
      • C:\Program Files (x86)\Java\jdk1.7.0_55\bin/javaw.exe
    And now I can run my eclipse without any error , hoope this helps somebody out there.

    Summary

    This problem happens when your java version and OS java version is different , for example if you are using 32 bit java version and the OS has 64 bit java version you will see this error. the easy solution is to have same version of java for both your OS and your eclipse.

    Saturday, July 26, 2014

    Loading image bypassing browser cache

    In my JSP page I was using an img tag to load an image in my view page.

    Problem :
    <html:img page="/myAction.do?id=${aForm.id}"   width="400" height="550" style="border:none" /> I was facing problems to load the latest image using above image tag , the browser was retrieving the cached image to me not the latest Below are the steps I was doing 
    1. update the image from my update page
    2. show the view page to the user , showing him the current image , but current image was not shown to the user instead the last loaded page from the cahce was being loded by browser.
    I had the related no-cache meta tag in my page still I was facing this problem.


    Solution

    Apparently I found that it was the imag tag which was causing problem , since the browser was getitng the same link with no change it was loading the image from cahce , the only solution is to have unique link to load that URL by adding a uniquie value at the end of the link t load image , so I started appending the time stamo with the link and now it's working fine I can always see the lates image now , below is what I did in my JSP

    <!-- Define date variable-->
    <jsp:useBean id="current" class="java.util.Date" />
     
    <!-- Append time at the end of image page -->
               <html:img page="/myAction.do?id=${aForm.id}"}&a=${current.time}"   width="400" height="550" style="border:none" />
     
    This will always make it a unique URL for browser hence it will not load the image from cache.

    Monday, July 21, 2014

    Struts 1.1 forward to another action with additional paramenters

    Yeah yeah I know you must be smiling by looking at this blog post in 2014 and thinking who still posts about STRUTS :).

    Well it's a person who is supporting an applicaiton built on Struts ;).

    Problem Statement

    Ok so I had this problem where I wanted to forward to another Action from my current action and also I wanted to send some extra attributes

    Solution

    In my Action class I had to create my own ActionForward Object like below and return it



    ActionForward actionRedirect = new ActionForward("/pages/myAction.do"+ "?reportType=someReport&someValue="+myBean.getSomeValue(), true);

    return actionRedirect; Now I am able to forward to myAction and the form bean in populated with the values I am sending as request parameters.

    Wednesday, July 9, 2014

    ORA-01858: a non-numeric character was found where a numeric was expected

    I was getting this problesm while I was trying to debug PLSQL code written by someone else . And I found the sql statement like below where he was trying to apply to_date function on a date type column ,

    The format of MY_DATE_COLUMN is like "09-JULY-2014" , so when to-date function was applied on this date format to convert it to MM/DD/YYYY oracle was throwing this error

    SELECT TO_DATE(MY_DATE_COLUMN, 'MM/DD/YYYY') - INTERVAL '5' YEAR FROM DUAL

    The solutionw was simple , to get rid of the to_date function , so the below query is working fine for me now.

    SELECT MY_DATE_COLUMN - INTERVAL '5' YEAR FROM DUAL



    Wednesday, July 2, 2014

    Using Oracle PL/SQL how do I know to which database instance I am currently connected

    Below query will give you the name of the instance you are currently connected with

    SELECT sys_context('USERENV','DB_NAME') AS Instance FROM dual;

     Also we can use the below query to use the database name


    select name from v$database

    Thursday, June 12, 2014

    Spring Roo add an empty option to a combo

    Spring roo by default creates a combo box with widgetType "dijit.form.FilteringSelect" applied on it , this combo box doesn't contain an empty option.

    To add an empty option to it please follow the below steps

    In your java code when you are preparing a List for that combo box try to add first option with

    code =0 and value = -- Not Selected

    and then add all the other options in that list.

    A simple java code snipet I am using is

    ComboDTO comboDTO=new ComboDTO();
    comboDTO.setCode("0");
    comboDTO.setDescription("--Not Selected--");

    list.add(comboDTO); //This is the list which will be used to populate values in combo box

    The option having the code = 0 will be shown as the first element in your combo box. Now if you want it to be mendatory field implement your Validator in and check if the option slected in combo has code=0 send an error back

    Sample code for checking the value and sending error back from validator is like below

     if(myObject.getFieldCode().equals("0")){
      errors.rejectValue("fieldCode", "required.fieldCode");
     }
     
     This way you can have a combo box with an empty option and can check the validity at server side.

    Unfortunatly I couldn't find a way to show dojo type notification at client end if the user has not selected a valid option in the combo box. But this is working for me now.


     

    Wednesday, June 11, 2014

    Documentum getting list of workflow performers


    Below queries can be used to get the details about

    • What happend during a wrokflow
    • Which user performed which task
    • How long a task was waiting to be processed e.t.c.

    1. Use the below query to get the process ids related to your templete
                select * from dm_process where object_name like '%DBP%';
     
    2. Use the Below query to get  the completed workflow ids related to a process id

    select * from dmc_completed_workflow where process_id = 'my_process_id';

     3. Use the below query to get the information related to a completed workflow

    select * from dmc_completed_workitem where workflow_id in (select workflow_id from dmc_completed_workflow where process_id = 'my_process_id' )

    order by workflow_id, act_seqno;

    Wednesday, June 4, 2014

    Spring roo Customize Dojo Editor

    I wanted to add more extensions to the dojo editor in my spring roo application , below is what I did

     
    IN editor.tagx

    I added the required plugins to be added to Editor like below

    <script type="text/javascript">
     dojo.require("dijit.Editor");
    dojo.require('dijit._editor.plugins.ViewSource');
    dojo.require('dijit._editor.plugins.FullScreen');
    </script>

    and I added the decoraiton like below

    //**Added by sajjad as recomended in http://forum.spring.io/forum/spring-projects/web/web-flow/85188-customize-dojo-dijit-editor

    Spring.addDecoration(
    new Spring.ElementDecoration({elementId : '_${sec_field}_id_', widgetType : 'dijit.Editor', widgetAttrs : {disabled: ${disabled},extraPlugins: ['viewsource','fullscreen']}}));

    Wednesday, April 9, 2014

    pls-00201 identifier must be declared Oracle

    I Created a new package in a schema let's call it "A" and was trying to run a function in that package using my own ID.

    Oracle was showing me this error  "pls-00201 identifier must be declared " , after a little research I found that I had to grant execute on this package to my user ID otherwise Oracle will show me the above error so I executed below command as the Schema owner of  "A"

    grant execute on A to My_User_id

    and only then I was able to run the functions in the package "A"

    Thanks to the below link

    http://www.dbasupport.com/forums/showthread.php?53493-DBMS_JOB-errors-PLS-00201-identifier-package-proc_name-must-be-declared


    Let's define the steps to be done here to avoid error "pls-00201 identifier must be declared "

    1. Create a package
    2. Grant execute access to your user or role to that package
    3. Try to run any pricedure in that package , you should be able to do it now as you have been granted the execute rights on it.
     

    Wednesday, March 12, 2014

    Useful Documentum Queries

    ---getting the work flow using workflow name
    select * from dm_workflow where object_name like '3333%';
    --Getting the workflow using id
    select * from dm_workflow where r_object_id='abc'

    --getting user name in documentum using network ID in small
    select user_name from dm_user where LOWER(user_login_name)='abc'
    ----Getiing inbox

    EXECUTE get_inbox WITH name='abc'
    EXECUTE get_inbox WITH category=1,name='Weekse Alexander E',order_by=date_sent desc

    --Get the completed work flow information
    select * from dmc_completed_workflow where workflow_id='4d00eb438002ba00';
    ---Get all the completed work items
    select * from dmc_completed_workitem where workflow_id='4d00eb438002ba00';

    ---Get User Inbox
    SELECT router_id,item_id,read_flag,stamp,task_name,sent_by, date_sent,task_state,due_date,name  FROM dm_queue WHERE name = abc' AND task_name !='event' order by date_sent DESC;
    --Get user status (if 1 it means locked)
    select user_name,user_state from dm_user where user_os_name in ('a','b','c')


     Check the Documentum groups for a user -
    select i_all_users_names, group_name from dm_group where any i_all_users_names in (select user_name from dm_user where upper(user_os_name) = upper('<<network id>>'))
     Is a user disabled - 
    select * from ep_user where upper(user_os_name)=upper('<<network id>>') and user_state=1
     Check all users in a group -
    select i_all_users_names, group_name from dm_group where group_name =’<<Documentum group>>’
     The below query will check the status of user on Documentum 0 = active otherwise inactive
    select user_os_name,user_state from ep_user where user_os_name in ('a','b','c')
    ---Query to check users in a group
    select i_all_users_names from dm_group where group_name like '%a%'
    ---checking if a user is in a documentum group
    select i_all_users_names from dm_group where group_name like '%b%' and any "i_all_users_names" = 'a'

    ---Get the list of performer names of completed workitems for a live workflow
    select r_performer_name from dmi_workitem where r_workflow_id ='4d00ea968006f2d6' and r_runtime_state in (2) ;

    ---Get the performer name of current workitem for a live workflow
    select r_performer_name from dmi_workitem where r_workflow_id ='4d00ea968006f2d6' and r_runtime_state in (0) ;


    --Get work item performer names and action names for a given workflow
    ---the first two columns will have comma separated values with same order
    select all r_performers,r_perf_act_name,r_object_id from dm_workflow where r_object_id in ('Workflowid1','Workflowid2');
    ---Get the current workitem for a live workflow (router_id = workflow id , item_id  = workitem id )

    Select item_id as workitem_id from dmi_queue_item a where a.router_id = 'workflow_id' and delete_flag = 0;

    Sunday, February 16, 2014

    Maven error occurred during initialization of VM Could not reserve enough space for object heap

    Today I faced the same problem with same error message but this time it was when I was trying to run Maven for my project to clean and build , eclipse was showing me below message again

    Error occurred during initialization of VM Could not reserve enough space for object heap

    The reason for this problem was that I am using a 32 bit JDK and in my VM parameters I was initiating the head size like

    -Xmx1024m equal to 1GB

    when you do that on a 64bit windows platform the windows can't alocate this uch memory and you will see the above error message , so I just reduced the size to less then a GB like below

    -Xmx1000m

    and now I can run maven.

    Sunday, February 9, 2014

    Error occurred during initialization of VM; Could not reserve enough space for object heap ,

    I am running tomcat/weblogic in eclipse and when I was trying to start server from within eclipse I was facing this problem.

    I found that I was not adding the tns VM parameter in server enviorment variable.

    By adding the below VM argument to the JEE server (tomcat/weblogic) I was able to run my server from eclipse.
     
    -Doracle.net.tns_admin=The location of you tns


     

    Thursday, February 6, 2014

    ORA-31061: XDB error: special char to escaped char conversion failed.


    I encountered this exception while trying to get the XML data for a query while I was using
    dbms_xmlgen.getXML function in oracle.

    Problem :
    I found that one of the varchar columns in my table had invalid xml characters in it , so whenever the query was trying to fetch a record having that column with invalid data oracle was showing me the error as

    ORA-31061: XDB error: special char to escaped char conversion failed.

    For a list of invalid xml characters please see below





    List of invalid XML chars



    Solution :
    The best solution I can think of is to update that column and remove the invalid xml characters , and make sure by adding a trigger rule that nobody can enter those characters again in any similar field.

    Thursday, January 16, 2014

    java.sql.SQLDataException: ORA-01405: fetched column value is NULL



    Exception Description

    ORA-01405 is thrown when you attempt to execute FETCH, which was returned as a NULL value, but there was no indicator in use. If you are using Oracle

    I have a databse function to which if you pass a query it will give you back a CLOB containing XML output of that query , I encountered this error today when I try to pass a query which returns null as result there I got this exception.



    Handling

    Once I understood the exception and it's cause the handling code aws easy to write , in my catch block I will retun an error message like "No Record Found ,You may want to revise your query to get some data satifying your conditions".


    Solution

    You might try resolving ORA-01405 by substituting a value with NVL function when a NULL value appears, or simply construct your cursor so that NULL values are not returned (you may also specify that columns with NULL values are not received).