Yes!
While trying to brush up and plain Servlets and JSP, I was trying to improve on architecture and I happen to read the MySQL connector/J documentation. I was wondering if I should cache the DataSource or just create a call to JNDI everytime I invoke a database service on the application level.
/*
* Lookup the DataSource, which will be backed by a pool
* that the application server provides. DataSource instances
* are also a good candidate for caching as an instance
* variable, as JNDI lookups can be expensive as well.
*/
In my previous company our Systems Analyst always gave emphasis on User Interface and always reminded us that it's not a trivial thing. I thought that it was a mature way of thinking to develop all the functionalities first. Yeah, if you're just a coder then that might be a more important thing. But being a software engineer, designing user interfaces is a required skills or else, who would want to use your application? This is why I've spend time re-learning CSS, Javascript and JQuery. JQuery with some of its components already skinned really adds to the ease of development of user interfaces (plus some sleake design).
I have to thank many of my friends online who helped me develop my web design skills. Just a few months ago I could hardly match colors (still working on it) but with some patience and hardwork it seems to be a rewarding task. I tried to research online for some guidelines and this article seems fine.
Christmas is the Spirit of Giving and not Receiving. By posting a wish list online, I hope you're not getting the wrong idea that I only want to receive. These things, of course are my heart's desire to help me "create" and have something to share (like knowledge). I hope I could give you a moment of fun while browsing through this list.
Flex 3 With Java - http://www.amazon.com/Flex-3-Java-Satish-Kore/dp/1847195342/ref=sr_1_1?ie=UTF8&s=books&qid=1260766324&sr=1-1

One of the frustrations I get here in Manila is that we are so dated on technology books. I can order online but would cost me too much on shipping. Now, I've done some basic Flex tutorials here in the past using PHP but I'm really hoping to use Flex with Java since that's the language I'm most comfortable with.
Dell Mini

This is a Dell Mini 12 in the picutre. I dunno what' the latest one is, it's not very important. I've done a little research and Dell still seems to promote their Mini 10. I think I've grown a loyalty to Dell since I bought my Inspiron 1525 a few months ago and I use Dell Latitude E6400 at work. Why do I still want a Dell Mini you say? I bought my Dell with development in mind and I truly loved its 15.4 inch screen, I thought it would already be portable enough to work on any place in our house. It proved a little difficult still. It's difficult when I have to sit beside my child and wife on bed before sleep because my child, though small covers a huge portion of the bed. I love to do my stuff with the two of them near me and I just hate to disturb their sleep each time I try to move even a little.
LG Chocolate Full Touch Screen - http://www.youtube.com/watch?v=D9p_m8OYaQI

Whenever I read books I find it hard to store my notes on my current mobile phone. I have very limited space and it's very hard to organize. I don't know if such feature is supported by this phone but that's one of the things I'm looking for in touch mobile phones. I'm really looking forward to entering the touch screen craze next year.
Windows 7 Ultimate

I really want to replace Windows Vista that is currently installed on my laptop. One of the candidates is Windows 7 because I've heard of its stability and I've actually experienced it myself. I want to get the most out of my machine and Vista just ain't doing the job. Some of my old programs also don't work in Vista. :(
Playstation 3

During development of my game (a personal project, 2D Scrolling Manic Shooter), I found out that the most effective way to keep yourself motivated is to actually play some games and get ideas from those games. How can you develop games if you do not play games yourself? I have to admit I've been a little left behind with video games since Playstation 2. A few months ago, I had a PSP but then I had to sell it when I spilled some cooking oil in it. :(
Thanks for hearing me out! Merry Christmas and Happ New Year!
SQL has always been my weakest point as a developer. So in times like this, I usually resort to application-level solutions. This is the magic of doing pet-projects, you get to work on your weak points.
PROBLEM: The COUNT(*) function was return 1 on zero-row entries... Or was it really zero?
I was trying to do a simple COUNT on two LEFT joined tables...
------------------
items_tbl
------------------
item_id
item_name
------------------
------------------
item_entries_tbl
------------------
item_entry_id
item_id
------------------
Now, if I had the following data
------------------
items_tbl
------------------
item_id | item_name
1 | Shampoo
2 | Soap
3 | Baby Powder
and have two of these items listed on the item_entries_tbl
------------------
items_entries_tbl
------------------
item_entry_id | item_id
1 | 1
2 | 1
3 | 1
4 | 2
5 | 2
If I do the query:
SELECT A.item_id, COUNT(*) AS in_stock FROM items_tbl A LEFT JOIN item_entries_tbl B
Would give me...
------------------
SQL_RESULT
------------------
item_id | in_stock
1 | 3
2 | 2
3 | 1
Wait... There's something wrong here... I didn't have an entry for item_id 3 and yet it counted "1" in_stock. I guess the reason is that COUNT, counts for the number of rows.
When I left joined with items_tbl, it actually created a virtual row (as I like to call it) that has item_id = 3 in it. So how did I discount it?
I put in a counter-check item_id. I modified the query as follows...
SELECT A.item_id, B.item_id AS counter_check_item_id, COUNT(*) AS in_stock FROM items_tbl A LEFT JOIN item_entries_tbl B
It now gives me the result:
------------------
SQL_RESULT
------------------
item_id | counter_check_item_id | in_stock
1 | 1 | 3
2 | 2 | 2
3 | NULL | 1
At the application level, I just have to check if counter_check_item_id is NULL, the value 1 in in_stock would only be bogus and counter_check_item_id would verify if that row really exists.
In java:
//rs = java.sql.ResultSet
if ( rs.getString("counter_check_item_id") == null ){
itemEntries.setInStock(0);
}
else{
itemEntries.setInStock( rs.getInt(in_stock) );
}
Have a better solution? Post a comment! For those who does not. Hope that helps.
We were trying to upgrade an Wod 2003 template (dot) to 2007 template (dotm). This template has a custom toolbar and the toolbar still seemd to work in Word 2007. Problem was, the key tips ware all messed up like my buttons are being assigned key tips I didn't assign and there just doesn't seem to be a way to modify them. Me and a colleague suggested that we upgrade the old toolbar to a ribbon (i.e. complete overhau) but that just doesn't seem feasible for the project as of the moment. I did play with ribbon customization in Visual Studio 2008 a bit and I was able to do a little this and that like:
Call a macro inside an onClick method
Globals.ThisDocument.Application.Run("MyMacroFunction", ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
And check for an insertion point in word, still on an onClick method
Selection selection = Globals.ThisDocument.Application.Selection;
if (selection.Type == WdSelectionType.wdSelectionIP)
{
//do something fancy here
}
If you want to learn about creating your own ribbon using Visual Studio, there's a great video on how to do it.
UPDATE:
After a lot of searching, I found some interesting articles related to the dotm template file.
Hands on: Master the Office 2007 Ribbon
Introducing the Office (2007) Open XML File Formats
Explore an Office Open XML Format ZIP package
Document Interop Initiative
This thing is still such a pain in the %#2. Or maybe I just don't have enough UI designing experience. I had to make the UI flexible enough to fit on different screen resolutions, different font sizes and flexible enough even on form resize. I can't describe how I did it exactly but the major things that I added and made changes to were...
System.Windows.Forms.FlowLayoutPanel
- autosize=true
- Anchor=top,left
- FlowDirection=LeftToRight
- Dock to Parent Container
System.Windows.Forms.SplitContainer
- fixedPanel[Panel1 or Panel 2]
- splitterDistance={This is personal preference, keep to a minimum}
- Horizontal/Vertical splitter orientation
I had to make combinations of of vertical and horizontal splitter orientation to get the result I want.
I was trying out HSQLDB to run SQL scripts with ANT last night when I encountered java.lang.UnsupportedClassVersionError. Never encountered this in 3 years of coding. Recently, I tried to play safe and installed several JDK (and JRE) versions, and so it happened.
Quick diagnostics:
- Run java -version from commandline, you should be able to see the JRE that is in your %PATH% environment variable
- Run echo %JAVA_HOME%, this is what ANT would use if you try to run ant -diagnostics from the commandline, an entry like java.home : C:\Program Files\Java\jdk1.5.0_18\jre should be there so make sure JAVA_HOME also points to an updated JRE
Just wanted to share one of things I get busy with during my free time. This is like an array or Hashtable if you prefer. Whatever. Just copy and save this a batch file (.bat) and run from CLI
@ECHO OFF
SET __TEST.FNAME=Ray
SET __TEST.MNAME=Allen
SET __TEST.LNAME=Pierce
FOR /F "tokens=2* delims=.=" %%A IN ('SET __TEST.') DO ECHO %%A = %%B
Ok, some of you might find it bad that I'm triyng to relate Eclipse
with Visual Studio too much, feature to feature. But I can't help it,
having used Eclipse for the past 3 years.
So I was trying to find a functionality like "Open Resource"
(CTRL + SHIFT + R) in Eclipse. I've been using Visual Studio for a good
4 months now and I found myself searching by using ctrl + shift + f
(entire solution) and hope that something would match the keyword I
type in. The latter is useful if you want to fnd a particular occurence
of your search parameter, but I only wanted to find a file in our 10+
or more projects in one solution.
The solution was to append >of in the search box followed by a few words of the filename you're searching for.
>of <SPACE> <SOMETHING_THAT_THE_FILE_BEGINS_WITH>
A list of possible matches would appear below the search box.
Reference:
http://www.alteridem.net/2007/09/11/quickly-findopen-a-file-in-visual-studio/
I was asked to solve a problem of parsing a float value in dutch format (9,6 instead of 9.6). The former would always parse as a whole number, 96 instead of 9.6). I read on the
documentation from sun, http://java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormatSymbols.html and I saw that a method called setDecimalSeparator(char decimalSeparator) was
available. Lucky for me!
I then opened netbeans and came up with the code below.
Normal
0
false
false
false
MicrosoftInternetExplorer4
Normal
0
false
false
false
MicrosoftInternetExplorer4
package decimalformattest;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.Format;
import java.text.ParseException;
import java.util.Locale;
import java.util.logging.Logger;
/**
*
* @author lamia
*/
public class Main
{
Logger logger = Logger.getLogger(Main.class.getName());
public static void main(String[]
args) {
Locale locale = new Locale("nl-NL");
DecimalFormatSymbols dfSymbols = new
DecimalFormatSymbols(locale);
dfSymbols.setDecimalSeparator(',');
Format format = new DecimalFormat("#,###,###,##0.00#############", dfSymbols);
try {
Object parseObject = format.parseObject("9,5");
System.out.println(parseObject);
}
catch
(ParseException ex) {
ex.printStackTrace();
}
}
}
Output:
run:
9.5
BUILD SUCCESSFUL (total time: 0 seconds)
try removing dfSymbols.setDecimalSeparator(',') and you'll see that it parses differently.
Output without dfSymbols.setDecimalSeparator(',')
run:
95
BUILD SUCCESSFUL (total time: 0 seconds)
Now, I had to translate this to something that Spring would understand. Say, I have a Spring app called my-app. In myapp-servlet.xml we had an old reference to java.text.DecimalFormatSymbols which also had a reference to a Locale object
Normal
0
false
false
false
MicrosoftInternetExplorer4
<bean id="locale"
class="java.util.Locale">
<constructor-arg index="0">
<value>"nl-NL"</value>
</constructor-arg>
<constructor-arg index="1">
<value>"NL"</value>
</constructor-arg>
</bean>
<bean id="dfSymbols"
class="java.text.DecimalFormatSymbols">
<constructor-arg>
<ref bean="locale"/>
</constructor-arg>
</bean>
So I just added a new property
Normal
0
false
false
false
MicrosoftInternetExplorer4
<property name="decimalSeparator">
<value>,</value>
</property>
Which makes dfSymbols bean look like this:
Normal
0
false
false
false
MicrosoftInternetExplorer4
<bean id="dfSymbols"
class="java.text.DecimalFormatSymbols">
<constructor-arg>
<ref bean="locale"/>
</constructor-arg>
<property name="decimalSeparator">
<value>,</value>
</property>
</bean>
Hope that helps!
Hmm... I feel like I just had a de javu... But anyway.. I hate browsing through a long log file. Does the GREP command in Linux exist on Windows? No... But windows have something like this...
find "The String You're Looking For" SomeFile.txt
So say, I want to find all occurrences of the word "error" when I execute ant from my commandline, I would do something like this:
c:\>ant someTarget > someLog
c:\>find "error" someLog
You get the idea. :)
I'm pretty new to Test Driven Development and it's the first time I worked on an environment that adheres to its practices. Something I learned today is Write the Test first before you make any changes. This ensures that you know what you're writing your code against, and you make your solution fit the expected behavior, instead of the behavior trying to fit your solution.
I develop and maintain code. I didn't quite know that TDD can be used in the maintenance stage. I thought at first that it was only useful for new, ground up projects but I was wrong. It could also be, or maybe even more useful in maintenance projects. So again, why do you need to write the test first? Because your test must be able to fail if your designed solution is taken out, and pass if you put it back in.
In my work I work with different code branches and requires me to switch from one directory to the other. Wouldn't it be good if we could give a directory a drive letter of its own? The following batch code does just that.
#define the directory you want to assign a drive letter to
SET CURRENT_WORKDIR=C:\sourcecodes\theultimateapp1.0
#SET CURRENT_WORKDIR=C:\sourcecodes\theultimateapp2.0
#SET CURRENT_WORKDIR=C:\sourcecodes\theultimateapp3.0
#delete current assignment to the drive letter if there are any
SUBST z: /D
#assign the directory a drive letter
SUBST z: %CURRENT_WORKDIR%
I usually use just 1 drive letter, just commenting code if I want to switch from one to the other as needed. Type this in a text file, save this as a .bat file and run the batch file.
Now, you might want this behavior to persist every time you start your computer. Here's a very good resource to do just that.
http://www.freeweb.hu/wsh2/ch13e.html
I had a lot of things to blog during the past 3 months but I just couldn't get myself to write any of them online.
Well, since I've been using the Visual Studio.Net immediate window a lot lately so I thought it would be useful for fellow eclipse users to know that an equivalent tool exist in Eclipse.
I don't have to write what's already written, right? Just follow the link below, it's pretty much self-explanatory.
Update:
Alright! So I figured out I should try and write more information about this. So let's consider the following code:
Normal
0
false
false
false
MicrosoftInternetExplorer4
import java.util.ArrayList;
import java.util.List;
public class TestClass {
public TestClass(){
}
public static void main(String[]
args){
new TestClass().go();
}
public void go(){
List<String>
myFriendsNameList = new ArrayList<String>();
myFriendsNameList.add("Ray");
myFriendsNameList.add("Paul");
myFriendsNameList.add("Kevin");
}
}
1. First, make sure that you are in the Debug perspective
2. I would set a breakpoint to the line that says... Let's say,
Normal
0
false
false
false
MicrosoftInternetExplorer4
myFriendsNameList.add("Kevin"); .
3. Next, I would go to window->Show View->Other
4. Under the debug folder, choose Display
5. If you are in the Java perspective, choose Debug As Java Application
6. Once you stop on the breakpoint, type myFriendsNameList.get(0) in the Display view tab (commonly placed below your IDE), highlight the text you just typed and press CTRL + SHIFT + D and something like below should appear right below the code you typed.
(java.lang.String) Ray
You could also do other things like check the size() of the list. This is an alternative way of looking at the Variables window and is very, very useful throughout developement.
Reference:
http://askville.amazon.com/debugging-Eclipse-Visual-Studio-equivalent-Window-interactive-top-level/AnswerViewer.do?requestId=9072383
I was encountering the error below everytime I tried to invoke a WS client in RAD7. I was calling the WS through a console application using a generated client stub.
Deployment error:
java.io.IOException: FATAL ERRORS encountered by WSDL2Java tool.
at com.ibm.ws.webservices.wsdl.Parser.generate(Unknown Source)
at com.ibm.ws.webservices.wsdl.Parser.generate(Unknown Source)
at com.ibm.ws.webservices.tools.wsad.WSDL2Java._execute(Unknown Source)
at com.ibm.ws.webservices.tools.wsad.WSDL2JavaBase.execute(Unknown Source)
at com.ibm.etools.webservice.command.adapter.CommandToCommand.execute(Unknown Source)
at com.ibm.ast.ws.v61.consumption.j2ee14.stub.WSDeployStub.execute(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.ibm.ast.ws.v61.consumption.j2ee14.command.AbstractEmitterAdapterCommand.execute(Unknown Source)
at com.ibm.ast.ws.deployer.WASV61DeploymentModule.generateDeploymentCode(Unknown Source)
at com.ibm.etools.webservice.deploy.core.AbstractDeploymentModule.deploy(Unknown Source)
at com.ibm.etools.webservice.deploy.core.AbstractDeploymentModule.deployWebservice(Unknown Source)
at com.ibm.etools.webservice.deploy.core.AbstractDeploymentModule.execute(Unknown Source)
at com.ibm.ast.ws.deployer.WASDeploymentModule.execute(Unknown Source)
at com.ibm.ast.ws.deployer.WASDeploy.execute(Unknown Source)
at com.ibm.ast.ws.deployer.WSDeployer.runWSDeploy(Unknown Source)
at com.ibm.ast.ws.deployer.WSDeployer.processModuleComponent(Unknown Source)
at com.ibm.ast.ws.deployer.WSDeployer.execute(Unknown Source)
After searching google, I found one solution. I added the jar, in my classpath (buildpath/libraries). I found the jar in
<RAD_INSTALL>/SDP70/runtimes/base_v61/runtimes/com.ibm.jaxws.thinclient_6.1.0.jar
However, I was able to make it work without this before. For some weird reason it just pops out randomly, each time I do an update from SVN...
More Posts
Next page »