suki2.jpg

26/07/2009

Back to fencing comps - 55 days to go

QuickImage Category Fencing
Due to a number of factors (Time, Money, Stress etc etc) I had stopped going to fencing comps (and thus deprived my self of the driving force for going to normal fencing), but with the Nationals being this weekend and thus the end of the Season, i think it is time to start to get ready for the next season, so the Bristol Open 19th of September will be the first comp i attend and i REALLY have to get in shape by then,

Exercise target (per Week)
2 x Nights of fencing.
1 x Lesson
3 x Gym Sessions

The Gym stuff is not really ideal (as Steve Paul Says "the best exercise for fencing IS fencing"), but i believe i have finally started to get my priorities in order in my life, fencing is fun and all and i believe the best way to keep fit but im not going to sacrifice personal relationships or work for it, strangely enough i think this might make me better at competitions as i wont be as stressed.

The gym sessions will initially consist of 40 mins sessions with

2k rowing (as level 10 in 8mins)
10 mins punch bag
10 mins Stepper (at level 13 random)
10 mins undetermined!! (yeah yeah)

I feel there may be pain ahead!!

12/07/2009

Oi, where's me config docs?, Oh bugger i don't have a nsf

QuickImage Category Java notes equivalent

Here we go with another example of what to do when cruelly ripped from the bosom of the notes server

This time its config docs, these as we all know are a happy doddle in notes, we just store them in what ever db (usually the current one) is suitable and pull then back with a view (personally i don't like profile documents as they are a swine to copy around in comparison to normal docs), when faced this same basic need in Java, and not wanting to use a relation database (feels like a bit of an over kill for some things) i went searching and found more wonderful people who have already done the job, this time at
http://commons.apache.org/configuration/

They have a nice little lib that lets you store stuff in xml docs (as well as many other things), here is an example (lets call it config.xml)


<?xml version="1.0" encoding="ISO-8859-1" ?>

<project-definition>
        <example1>
                <textexample>im a example</textexample>
        </example1>

        <example2>
                <intexample>15</intexample>
                <list1>
                        <name>item1,item2,item</name>
                </list1>
        </example2>
</project-definition>


Im going to save this in the root of my Java project, and now on to the code


import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;

public class EasyConfigDocs{
       public static void main(String[] args) {

          try {
                  XMLConfiguration config = new XMLConfiguration("Config.xml");
 
                   String textconfig = config.getString("example1.textexample");
               //Note: to get an indented value you separate with a "."  
                   
                  int numberconfig = config.getInt("example2.intexample");
                  List buttons = config.getList("example2.list1.name");
               //Note: on multivalue items the default separator is a "," if you want to use a "," in a text string you need to either do "\," or change the default delimiter (easy to do, its on the site)
                   
          } catch(ConfigurationException cex)        {
                    System.out.println("config file not found");
          }
       }
}

Nearly as simple as Notes (not that i did any work), it also does all the Edit and Add stuff, but you can get that off the examples at http://commons.apache.org/configuration/ if you need it, i just want to save you the pain on the initial search, Oh!, on that note keep a look out at http://www.benpoole.com hes on the same track as me and has some good blog tutorials for notes developers fighting with pure Java coming up.

10/07/2009

Doing Scheduled agents When not on a Domino server

QuickImage Category Second String to you Bow JAVA

When you step outside the warmth and comfort of a domino server a lot of things frighten the willies out of you, things you took for granted are suddenly not there, so i thought each time i have to do a notes equivalent in the cold hard world, i would share:

Today sprig of joy is scheduled agents in Java (on a JBoss server actually), this is all supplied thanks to the amazing people over at http://www.opensymphony.com/quartz/, its far more powerful than my example, but it easy to understand when you come from notes, and you can expand on it as you see fit (instruction are in the comments), have fun (oh, if the code looks cramped just copy it to a bigger text widow as i left all the proper indenting in)


import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.impl.StdSchedulerFactory;

public class JustLikeANotesAgent {
       
        public static void SetUpNotesTypeAgent(String CronTriggerPram) throws Exception {

        // setting up the scheduler which is basically the equivalent of agent manager
           Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();

        // setting up our "Agent" ie giving it a name and linking it to a chunk of code
        JobDetail NotesAgent = new JobDetail("NotesAgentName", null, AgentCode.class);

        // setting up our schedule ,there are "simple triggers" and "Crontriggers"
        // Crontriggers are more powerful and easy to get a handle on if your used to notes
        CronTrigger AgentSchedule=new CronTrigger("AgentScheduleName",null,CronTriggerPram);

        // linking the Agent to its schedule and "enabling" it
        scheduler.scheduleJob(NotesAgentName, AgentScheduleName);

        scheduler.start(); // and off we go, basically "load Agmr"
        }
       

        public static void main(String[] args) {
               
           //the following string is a Cron Trigger that runs every 5 mins
           // tutorial on crontriggers can be found HERE
                String CronTriggerPram = "0 0/5 * * * ?";
                                               
                try {
                        SetUpNotesTypeAgent(CronTriggerPram);
                } catch (Exception e) {
                        e.printStackTrace();
                }        
            //scheduler.shutdown(); this is commented out as its basically like "tell agmr quit"    
    }
}

03/07/2009

After the honeymoon, Tip 1

QuickImage Category Flex Domino

Its been about 2 months since i started using adobe flex in billable anger, and even the best platform looses some of its ability to escape criticism in that time, flex however is proving to be everything that I had hoped for, but you still bump into the odd thing that domino does much better, so I'm doing a series of tips and tricks to help you get everything from both systems (especially when used together).

Todays tip is sortable date columns in flex data grids

Flex data grids are a wonderful thing, with easy sorting and sizeable columns and such, but one thing sucks on them, and that's the fact that they only do TEXT sorting, dates are just treated like text which means that all of the common date formats wont sort correctly, Booooo!, but we can fix that surprisingly easily

First you want to output your date data from notes in YYYYMMDD format, why?? because this formats displays the same when sorted textually or chronologically

so in a view that would be (its a bit long as we need to pad the short days/months (thanks to Ben Poole for pointing this out))

***edited by popular vote to a shorted version***

@Text(@Year(LossDate)) + @Right("0" + @Text(@Month(LossDate));2) + @Right("0" + @Text(@Day(LossDate));2)

if your using a web service to return that value, the Java code would be

import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

Item dateitem = doc.getFirstItem("DateIWant");
DateTime notesdate = dateitem.getDateTimeValue();

DateFormat dateFormatordered = new SimpleDateFormat("yyyyMMdd");

String UpdDtSort=dateFormatordered.format(notesdate);

if you using lotusscript for you webservice then your on your own!!.

Now into flex and define a "Dateformater", this is my personal fav date format (is it sad that i have one) and produces dates like "Tue May 04 2009", which i find removes many problems with international formats causing confusion.

<mx:DateFormatter id="dateFormatternice" formatString="EEE MMM DD YYYY"/>

Next you will need your actual datagrid (which you will already have if you have discovered this problem).  

<mx:DataGrid width="740" height="126" x="10" y="34" id="datesortview" dataProvider="{mynotesview}" fontFamily="Arial">
        <mx:columns>
                <mx:DataGridColumn headerText="Description" dataField="Desc"/>
                <mx:DataGridColumn headerText="Updated Date" dataField="UpdDtSort" labelFunction="dateLabel"/>
                </mx:columns>                                        
</mx:DataGrid>

You will notice the "labelFunction" at the end of the date column, that calls the following function (and passes the parameters automatically).

private function dateLabel(item:Object, column: DataGridColumn) : String {
    if (item[column.dataField] != null) {
       var TempDate:Date = DateField.stringToDate(item[column.dataField], "YYYYMMDD");
            return dateFormatternice.format(TempDate);
    } else {
       return "";
    }
}

This basically just takes in each value in the column, converts it to a date using a mask, formats to a pretty format and returns it back to the column. it is MUCH faster than attempting a code based sort solution (as some people use in flex using "sortCompareFunction" on a datagrid).

your column now has 2 values the underlying data format in the happily sortable "20090504" and the label format that the user sees in the format "Tue May 04 2009", yet again a feature we took for granted in notes requires a bit of coding to get it in other platforms.

Avalable for on site contract in

 

Hire Me

Directly:

Curriculum Vitae

As a member of:
ldc_badge.gif

Contact My Grubby Hide

Skype Linkin Main Me Twitter

Fab to Goto

fotb_marmite_200x200.png