Friday, September 28, 2012

Function for accessing URL variables in HTML

Function for accessing URL variables in HTML:

function getUrlVar(key){
        var result = new RegExp(key + "=([^&]*)", "i").exec(window.location.search);
         return result && unescape(result[1]) || "";
}

Ex:
URL: http://blog.com?name=suresh&lastname=raja
you have to use the function like this getUrlVal('name') you will get the result as 'suresh'.

Tuesday, November 22, 2011

Facebook Like/Share button in your site

Reference page http://developers.facebook.com/docs/reference/plugins/like/

Include the JavaScript SDK on your page once, ideally right after the opening <body> tag.

<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

Place the code for your plugin wherever you want the plugin to appear on your page.
<div class="fb-like" data-href="www.we4you.co.cc" data-send="true" data-layout="button_count" data-width="450" data-show-faces="false" data-font="tahoma"></div>

Thursday, November 17, 2011

Configuring proxy settings in Java


System.getProperties().put("http.proxyPort", "someProxyPort");
System.getProperties().put("http.proxyUser", "someUserName");
System.getProperties().put("http.proxyPassword", "somePassword");
System.getProperties().put("http.proxyHost", "someProxyURL");

Courtesy by: Harish Gokavarapu

Saturday, May 14, 2011

IBM Learning video, audio and pdf available for free

IBM Education Assistance

This is a free site, any body can access and go through the learning sessions provided by them.

For WebSphere Commerce Suite learning, please visit the following url

http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/index.jsp?topic=/com.ibm.iea.wcs/plugin_coverpage.html

In the left side menu items of the loaded page search for "WebSphere Commerce"

Friday, May 13, 2011

How to get the Date and Time for client TimeZone in Java class


You need to get the timeZoneOffSet from browser by using the following javascript snippet:
<script type="text/javascript">
   var dateObj = new Date()
   var timeZoneOffsetInMins = dateObj.getTimezoneOffset();
   document.getElementById("bTimeZoneOffset").value = timeZoneOffsetInMins;
</script>

<form>
  <input id="bTimeZoneOffset" type="hidden" />
</form>

Java Class Method:::
private String getClientDateTime(String strFormat, long timeZoneOffSet){
    SimpleDateFormat sdf = new SimpleDateFormat(strFormat);
    TimeZone timeZone= TimeZone.getTimeZone("UTC");

    if(timeZoneOffSet < 0){
        timeZoneOffSet = -1 * timeZoneOffSet;
    }
    timeZoneOffSet = timeZoneOffSet * 60000;
    timeZone.setRawOffset(timeZoneOffSet);
    
    sdf.setTimeZone(timeZone);
    
    return sdf.format(new Date());
}

Tuesday, April 26, 2011

Converting special Characters in properties file to UTF8 using native2ascii


Eg: Converting poland special charectres to native language
1.  Rename the file provided by the customer (i.e., storetext.properties) to storetext.nta
2.  Run the following command:                                                 C:\WebSphere\IBM\SDP\runtimes\basev7\java\bin\native2ascii -encoding utf-8 <.nta-file locaiton> <target file name with path>
3.  Target properties file is your converted file.

Wednesday, December 2, 2009

Delete the Web server definition in a standalone application server

The uninstaller program for the Web server plug-ins for WebSphere Application Server does not delete Web server definitions. However, you can delete a Web server definition from admin console OR by using the following wsadmin commands:

$AdminTask deleteServer { -serverName webserver1 -nodeName WebserverHostName-node_node }
$AdminTask removeUnmanagedNode { -nodeName WebserverHostName-node_node }
$AdminConfig save

Ex:
$AdminTask deleteServer { -serverName webserver1 -nodeName webserver1_node}
$AdminTask removeUnmanagedNode { -nodeName webserver1_node}
$AdminConfig save

Tuesday, December 1, 2009

Enabling trace for WSAdmin Tool

1. Enable tracing on the wsadmin tool. To do this, edit the WC_profiledir /properties/wsadmin.properties file. You must set the com.ibm.ws.scripting.traceString property to the correct trace specification. By default this line is commented out; be sure to remove the comment character (#) when you set the desired trace specification. The wsadmin client's trace file is WC_profiledir /logs/wsadmin.traceout.
2. Restart server1
3. Try to use wsadmin tool to manually export the EAR.
4. After the exception was thrown, collect the trace WC_profiledir/logs/wsadmin.traceout.

Thursday, November 12, 2009

Changing ORACLE LISTENER port number

Stop Listener

Change the port number in the following path:
D:\oracle\product\10.1.0\Db_1\NETWORK\ADMIN\listener.ora

Change the port number to desired port number and save.

Start the listener.

Run the following statement in the SQL prompt as sys dba.
ALTER SYSTEM SET LOCAL_LISTENER='(ADDRESS = (PROTOCOL = TCP)(HOST = host-name)(PORT = 1522))';

Check the status of listener, it should pick up your service name.

Monday, November 2, 2009

SOAP request Timeout

In wsadmin.traceout, the exception was thrown:org.apache.soap.SOAPException: [SOAPException: faultCode=SOAP-ENV:Client; msg=Read timed out; targetException=java.net.SocketTimeoutException: Read timed out]"
follows:
---------------------------
com.ibm.websphere.management.exception.ConnectorException: ADMC0009E: The system failed to make the SOAP RPC call: invokeat com.ibm.ws.management.connector.soap.SOAPConnectorClient.invokeTemplate(SOAPConnectorClient.java:642)at com.ibm.ws.management.connector.soap.SOAPConnectorClient.invoke(SOAPConnectorClient.java:512)at com.ibm.ws.management.connector.soap.SOAPConnectorClient.invoke(SOAPConnectorClient.java:332)
----------------------------
SocketTimeoutException was possibly thrown because the SOAP timeout was not be long enough, if the exporting of the ear takes longer than the value specified by the SOAP timeout, it would fail.The SOAP timeout parameter was specified in \opt\IBM\WebSphere\AppServer\profiles\FairPrice\properties\soap.client.props, as following in your environment:
#------------------------------------------------------------------------------
# SOAP Request Timeout #
# - timeout (specified in seconds [default 180], 0 implies no timeout)#
#------------------------------------------------------------------------------
com.ibm.SOAP.requestTimeout=180
#------------------------------------------------------------------------------
So I have following suggestion to resolve the problem:
1. Chanage com.ibm.SOAP.requestTimeout to 0 or a larger value (e.g. 3600)
2. Restart server1

Export fix while Applying APAR

Find exportEar.jacl under $Commerce_installDIR/config/deployment/scripts. Make a backup.
2. Change
$WCSHelper exportApplication $AppName $AppPath
to
$AdminApp export $AppName $AppPath
3. Launch UPDI and retry the APAR deployment

Friday, September 25, 2009

Prepare url dynamically in Javascript

<% String sWebAppPath=UIUtil.getWebappPath(request); %>string url = window.location.protocol + "://" + window.location.hostname + "/" + <%=sWebAppPath%> + "/" + ViewName

Wednesday, September 23, 2009

Creating Cookie in a Session

The ViewCommandContext offers the getResponse() method which can be used to gain access to the HttpServletResponse, from where you can add the cookies.

http://publib.boulder.ibm.com/infocenter/wchelp/v6r0m0/index.jsp?topic=/com.ibm.commerce.api.doc/com/ibm/commerce/command/ViewCommandContext.html

For example:

if ( commandContext instanceof com.ibm.commerce.command.ViewCommandContext ) {
 com.ibm.commerce.command.ViewCommandContext v = (com.ibm.commerce.command.ViewCommandContext)commandContext;
 javax.servlet.http.HttpServletResponse response = (javax.servlet.http.HttpServletResponse)v.getResponse();
 javax.servlet.http.Cookie myCookie = new javax.servlet.http.Cookie("name","value");
 response.addCookie(myCookie);
} 

Tuesday, September 22, 2009

Home Page - Getting Admin Console in Store Front

https://localhost:8004/webapp/wcs/orgadmin/servlet/BuyAdminConsoleView?
XMLFile=buyerconsole.BuySiteAdminConsole&
customFrameset=common.MerchantCenterFramesetRHS&
webPathToUse=/webapp/wcs/stores/servlet&
sidebarViewName=SidebarDisplayView&
headerViewName=HeaderDisplayView&
footerViewName=FooterDisplayView&
actionName=organization&langId=-1&
storeIdToUse=10051&
buyer=true

Monday, September 21, 2009

Create DB Schema (When Instance exists)

Command For Create Schema (When Instace exists):
/opt/IBM/WebSphere/CommerceServer60/bin/createdb.oracle.sh /opt/IBM/WebSphere/CommerceServer60/instances/instance-name/properties/createInstance.properties

Check the log for Errors:
/opt/IBM/WebSphere/CommerceServer60/logs/populateDB_oracle.log

Monday, September 14, 2009

TNS NAME BLOCKED - SOLUTION

When lsnrctl status result as follows:
Instance "music", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully

Solution:
Connect as sysdba

SELECT STATUS FROM V$INSTANCE;
ALTER DATABASE MOUNT;
ALTER DATABASE OPEN;


Friday, September 11, 2009

Start and Stop Servers

Start Commerce Server:
/opt/IBM/WebSphere/AppServer/profiles/instance-name/bin/startServer.sh server1

Stop Commerce Server:
/opt/IBM/WebSphere/AppServer/profiles/instance-name/bin/stopServer.sh server1

Start WebServer:
/opt/IBMIHS/bin/apachectl -f /opt/IBM/WebSphere/CommerceServer60/instances/instance-name/httpconf/httpd.conf -k start

Stop WebServer:
/opt/IBMIHS/bin/apachectl -f /opt/IBM/WebSphere/CommerceServer60/instances/instance-name/httpconf/httpd.conf -k stop

HTTP Conf Syntax Check:
/opt/IBMIHS/bin/apachectl -f /opt/IBM/WebSphere/CommerceServer60/instances/instance-name/httpconf/httpd.conf -t

TNS-Names Settings

/opt/ora10g/product/10.2.0/client_1/network/admin/tnsnames.ora

suresh1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = IP-Address)(PORT = 1524))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = suresh1.sureshdomain.com)
)
)

Create user for WCS

drop user suresh1usr cascade;

drop tablespace suresh1db including contents and datafiles;

CREATE TABLESPACE suresh1db DATAFILE '/oracle/u01/app/oracle/oradata/suresh1/suresh1db.dbf' SIZE 4M AUTOEXTEND ON NEXT 2M MAXSIZE UNLIMITED;

CREATE USER suresh1usr IDENTIFIED BY suresh1usrs00 DEFAULT TABLESPACE suresh1db QUOTA UNLIMITED ON suresh1db;

grant all privileges to suresh1usr;

ALTER USER suresh1usr TEMPORARY TABLESPACE TEMP;

CONNECT suresh1usr/suresh1usrs00;

CREATE SCHEMA AUTHORIZATION suresh1usr;