Jython Monthly Presents "Ask Frank"...a question and answer session with Frank Wierzbicki for the Jython community!
I've been in touch with Frank Wierzbicki of Sun Microsystems. In case you aren't aware, Frank is one of the top Jython developers, and earlier this year Sun Microsystems hired him to work on Jython full time!
He has agreed to answer questions from the community for our July 2008 newsletter. Gather your best questions and post them to the wiki at the URL below. If you have issues posting the questions on the wiki page, then please send them to me at juneau001@gmail.com so that they can be included. The deadline for posting questions is July 11th. After that time, Frank Wierzbicki will choose which ones he wishes to answer and we will include them in the next distribution.
Please post your questions to Ask Frank at: http://wiki.python.org/jython/JythonMonthly/Interviews/July2008/AskFrank and feel free to include your name/email address if you'd like.
Thanks in advance for your participation...this is a great opportunity for the Jython community.
Special thanks to Frank Wierzbicki for his time!
I am an application developer, database administrator, technical writer, and Java evangelist. Frequent this blog to learn from my experiences in Java, JavaEE, PL/SQL, and Python/Jython development. Follow my tweets @ http://twitter.com/javajuneau
Friday, June 20, 2008
JBoss Seam - Interceptors Using Groovy - Quick Tip
Quick Tip: If you are using Groovy in any of your Seam applications (particularly when deploying to Glassfish), be sure to update the @Interceptors annotation in your session beans as such:
From: @Interceptors([org.jboss.seam.ejb.SeamInterceptor.class])
To: @Interceptors([org.jboss.seam.ejb.SeamInterceptor.class])
From: @Interceptors([org.jboss.seam.ejb.SeamInterceptor.class])
To: @Interceptors([org.jboss.seam.ejb.SeamInterceptor.class])
Thursday, June 19, 2008
Using Groovy with Seam 2.0 in Netbeans 6.1
Of course, Seam 2.0 is ready to go with Groovy support which is great news! However, for someone who is not interested in using Seam Gen it is not very straight forward. This is true especially if one wishes to use Eclipse or Netbeans for their development environment.
A while back, I wrote a blog about developing Seam applications on Netbeans and deploying to Glassfish (http://jj-blogger.blogspot.com/2007/07/jboss-seam-configurations-jars-and.html). I need to post an update blog because I am now deploying Seam 2.0 apps to Glassfish Version 2 using Netbeans. I'd like to add a bit of syntactic candy into the process now and include Groovy support into my Netbeans Seam projects.
Simply add the following to your build.xml file (contained within the root of your Netbeans project) and modify paths accordingly. You will also need to package groovy-all.jar with your application. Once completed, you can add Groovy files suffixed with .groovy into your project Seamlessly. At compile time, they will be compiled into Java classes.
<target name="-pre-compile">
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpath="${classpath-to-groovy}" />
<groovyc destdir="${classes.dir}">
<classpath>
<pathelement path="${classpath-to-groovy}"/>
</classpath>
<javac source="1.5" target="1.5" debug="on"/>
<src path="${src.dir}"/>
</groovyc>
</target>
A while back, I wrote a blog about developing Seam applications on Netbeans and deploying to Glassfish (http://jj-blogger.blogspot.com/2007/07/jboss-seam-configurations-jars-and.html). I need to post an update blog because I am now deploying Seam 2.0 apps to Glassfish Version 2 using Netbeans. I'd like to add a bit of syntactic candy into the process now and include Groovy support into my Netbeans Seam projects.
Simply add the following to your build.xml file (contained within the root of your Netbeans project) and modify paths accordingly. You will also need to package groovy-all.jar with your application. Once completed, you can add Groovy files suffixed with .groovy into your project Seamlessly. At compile time, they will be compiled into Java classes.
<target name="-pre-compile">
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpath="${classpath-to-groovy}" />
<groovyc destdir="${classes.dir}">
<classpath>
<pathelement path="${classpath-to-groovy}"/>
</classpath>
<javac source="1.5" target="1.5" debug="on"/>
<src path="${src.dir}"/>
</groovyc>
</target>
Counting Rows in Oracle in a Generic Fashion
As a DBA, every once in a while it is useful to have the ability of searching through all of the tables within a particular database to find a value. This can be a useful thing to do if you need to find all references to a particular record in a database table. Most likely, this kind of operation would need to be performed in order to safely delete a record from a database that was not using referential integrity. I know that I administer at least one legacy database which does not utilize referential integrity much at all. One major downfall to not using referential integrity is that records can be unsafely deleted, potentially leaving dangling references throughout the database.
One could easily write a block of code to search for a particular value throughout all tables in the database by iteration using views such as USER_TABLES. I have done so myself on many occasions. So much, that I grew tired of coding new blocks of code to search for particular values each time I needed to do so. I finally took a few minutes to write a generic stored procedure which will load into any Oracle database schema, and it has the ability to perform a full table search any particular value. The procedure takes two parameters, column name (or value name) and value. By invoking the procedure and passing these two values, the database will search through all tables within a particular schema and find those values within the column name you have given. The one caveat is that some databases use different column names throughout the database for the same identifiers. For example, I work with a database that calls an employee id number ID in one table, and EMP_ID in another. You must account for such discrepancies when using this procedure.
The code for this generic counting solution is as follows:
create or replace
procedure check_object_counts(column_name_val IN varchar2,
column_value IN varchar2) is
cursor table_cur is
select table_name
from user_tab_columns
where column_name = upper(column_name_val);
row_count number := 0;
begin
DBMS_OUTPUT.PUT_LINE('THE ' || upper(COLUMN_NAME_VAL) || ' IS REFERENCED IN THE FOLLOWING TABLES:');
for table_rec in table_cur LOOP
EXECUTE IMMEDIATE 'select count(*) from ' ||table_rec.table_name ||
' where ' || column_name_val || ' = :THIS_OBJECT'
INTO ROW_COUNT
USING column_value;
if row_count > 0 then
DBMS_OUTPUT.PUT_LINE(table_rec.table_name || ' - ' || row_count || ' times ');
end if;
row_count := 0;
end LOOP;
end;
/
As stated previously, this procedure can be loaded into any schema which has CREATE ANY PROCEDURE privileges. You invoke it as such from within SQLPlus:
@check_object_counts('EMP_ID','10037E');
** By the way, be sure to use SET SERVEROUTPUT ON prior to running the script so that you see the output!
It may not be a catch all solution, but it does the trick 98% of the time! Best to you and happy DBA-ing!
One could easily write a block of code to search for a particular value throughout all tables in the database by iteration using views such as USER_TABLES. I have done so myself on many occasions. So much, that I grew tired of coding new blocks of code to search for particular values each time I needed to do so. I finally took a few minutes to write a generic stored procedure which will load into any Oracle database schema, and it has the ability to perform a full table search any particular value. The procedure takes two parameters, column name (or value name) and value. By invoking the procedure and passing these two values, the database will search through all tables within a particular schema and find those values within the column name you have given. The one caveat is that some databases use different column names throughout the database for the same identifiers. For example, I work with a database that calls an employee id number ID in one table, and EMP_ID in another. You must account for such discrepancies when using this procedure.
The code for this generic counting solution is as follows:
create or replace
procedure check_object_counts(column_name_val IN varchar2,
column_value IN varchar2) is
cursor table_cur is
select table_name
from user_tab_columns
where column_name = upper(column_name_val);
row_count number := 0;
begin
DBMS_OUTPUT.PUT_LINE('THE ' || upper(COLUMN_NAME_VAL) || ' IS REFERENCED IN THE FOLLOWING TABLES:');
for table_rec in table_cur LOOP
EXECUTE IMMEDIATE 'select count(*) from ' ||table_rec.table_name ||
' where ' || column_name_val || ' = :THIS_OBJECT'
INTO ROW_COUNT
USING column_value;
if row_count > 0 then
DBMS_OUTPUT.PUT_LINE(table_rec.table_name || ' - ' || row_count || ' times ');
end if;
row_count := 0;
end LOOP;
end;
/
As stated previously, this procedure can be loaded into any schema which has CREATE ANY PROCEDURE privileges. You invoke it as such from within SQLPlus:
@check_object_counts('EMP_ID','10037E');
** By the way, be sure to use SET SERVEROUTPUT ON prior to running the script so that you see the output!
It may not be a catch all solution, but it does the trick 98% of the time! Best to you and happy DBA-ing!
Wednesday, June 11, 2008
TinyMCE Basics
I spent a good deal of time searching the web yesterday. I was trying to remember how to make the TinyMCE WYSIWYG editor allow all HTML tags. If you've never heard of this editor, it is an excellent AJAX based editor for your websites. I use it to allow my clients the ability to edit and create HTML on-the-fly without any knowledge of Javascript. Basically, it displays HTML as an OpenOffice (or Word) document would. You can simply highlight text and make it bold, italic, or underlined. It also allows the ability to post photos (as long as the photo is on the web) and much more.
The key to allowing straight HTML is to include the following configuration at the top of your webpage. TinyMCE will take any textarea and make it into a nice editor.
Above is a basic configuration to allow certain html elements. In order to allow a more flexible amount of elements, just follow this link: http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/valid_elements
Simple, eh...too bad I wasted some time searching for it when the answer was right in front of me...
The key to allowing straight HTML is to include the following configuration at the top of your webpage. TinyMCE will take any textarea and make it into a nice editor.
tinyMCE.init({
...
valid_elements : "a[href|target=_blank],strong/b,div[align],br"
})
Above is a basic configuration to allow certain html elements. In order to allow a more flexible amount of elements, just follow this link: http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/valid_elements
Simple, eh...too bad I wasted some time searching for it when the answer was right in front of me...
Tuesday, June 10, 2008
JSF 2.0 Early Access Revew
Take a minute to download and read the JSF 2.0 Early Access Review doc. It looks like JSF will be getting better, I just hope that Seam will also continue to evolve into an even better (doesn't seam like it can get much better..it is great now) framework for JSF/EJB. Hopefully JSF 2.0 will have some added benefit in this process...
Subscribe to:
Posts (Atom)