Skip to main content

Posts

Liferay soy template double rendering work around

  inside the render method, add a flag to prevent double rendering @Override public   String render( RenderRequest  renderRequest , RenderResponse  renderResponse ) { Template template = (Template) renderRequest .getAttribute( WebKeys. TEMPLATE ); Object ob = template .get( "firstRendered" ); if ( ob == null ) { template .put( "firstRendered" , true ); } else { return null ; } return "view-soy-template-name"; }
Recent posts

Oracle refuses connection after few days (resolved)

  By default the number of allowed processes are 150 which may not be enough in production. below is how to increase the processes & sessions and transactions from sys dba user sql> alter system set processes=500 scope=spfile; sql> alter system set sessions=555 scope=spfile; sql> alter system set transactions=610 scope=spfile; sql> shutdown abort sql> startup

java standard simple method for logging actions in details

        public static void log(String msg){      Logger logger = Logger.getLogger("MyLog");      FileHandler fh;      try {          boolean append = true;         string filePath = "actions.log";         File file = new File(filePath );           // This block configure the logger with handler and formatter          fh = new FileHandler(filePath ,append);              logger.addHandler(fh);         SimpleFormatter formatter = new SimpleFormatter();          fh.setFormatter(formatter);          // the following statement is used to log any messages          logger.info(msg);      } catch (SecurityException e) {        // log(e.getMessage());     } catch (IOException e) {        //  log(e.getMessage());      }      }

Oracle delete duplicates

delete from tablename  where id not in ( select min(id) from tablename  group by column1 , column2 ,column3) example DELETE  FROM  DAILY_ATTENDANCE WHERE  ATT_ID NOT IN (       SELECT    MIN(ATT_ID)          FROM DAILY_ATTENDANCE        GROUP BY STAFF_ID, TIME_IN, TIME_OUT ) 

SAP simple transformer

let say we have s insurance xml data as a response of a web service and we want to expose this data as  a complex structure data type to deal with it in SAP   (the same like DOM parser in other programming languages) the xml data as below <?xml version="1.0" encoding="utf-8"?> <RequestResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">   <Response>     <TreatmentBasis>1</TreatmentBasis>     <TreatmentClassification>1</TreatmentClassification>     <MemberDetails>       <Tag>         <ID>1</ID>         <Label>DOB</Label>         <Value>05-Jun-2011</Value>         <Type>Date</Type>       </Tag>       <Tag>         <ID>2</ID>         <Label>Gender</Label>         <Value>Female</Value>         <Type>Text</Type>  

Oracle 11g socket timeout while working well locally via sqlplus

It was not a firewall or port blockage It was  a trace listener.log file increasing (5 Giga) ( it was located under  C:\app\admin_user_name\diag\tnslsnr\onlinesurvey\listener\trace) i have resolved this issue by 1- stop the listener      lsnrctl stop 2- shutdown db  sqlplus / as sysdba SHUTDOWN IMMEDIATE 3- rename the log    ( it should be listener.log file) 4- start db sqlplus / as sysdba STARTUP 5-start listner      lsnrctl start to stop listener log at all  i used this command lsnrctl set log_status off

liferay service connects to external oracle database

1- configure service.xml 2- create ext-spring.xml 3-create the oracle  table and sequesnce 4- build the service 1-service.xml  note that we add <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.2.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_2_0.dtd"> <service-builder package-path="com.dash.hr.forms"> <author>melsonbati</author> <namespace>SAMPLE</namespace> <entity name="Coupon"  table="HR_COUPON" local-service="true" remote-service="true" data-source="tcsDS" session-factory="testSessionFactory" tx-manager="testTransactionManager"> <!-- PK fields --> <column name="couponId" type="long" primary="true"  id-type="sequence" id-param="id_sequence_cp"  /> <