Follow by Email

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;

 

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']}}));