Author: francis

More fun with Oracle Java Portlets

The manual is incredibly opaque. I’m beginning to realise why paper manuals weren’t so bad, it was easier to work through things.

I can’t work out how to pass parameters into a porltet or default them in from the page (so you can pass them between portlets). Starting again with the noddy example from the manual to see where I’ve gone wrong.

This works … adding another parameter needed a refresh of the provider – of course – obvious. It looks like I needed to refresh the provider. Naively assumed that it was doing this on the fly when I reloaded the J2EE app. It must cache the provider.xml file in the portal (of course it does dumbo).

I now have the wrapper working after a fashion. I have no idea why this has to be so hard.

Letter to “spiked online”

This is in response to this article:

I always find myself a bit worried when people use words like progress and enlightenment like they’re in some sense automatic.

Another example is when people use “evolve” to mean things getting better, where “better” is a value judgement, when all it means is that they get better adapted to the prevailing conditions, which in themselves have no intrinsic value at all.

We haven’t progressed from anywhere. The project to better the human condition is a human construct, not an absolute, and so is enlightenment. This is laudable and I agree with it, but I don’t use progress in what is a naive Victorian way that makes it some sort of moral absolute (sorry Karl).

I did agree with the main thrust of the article’s attack on the silly self-serving abdication of personal responsibility, which is so much a part of life now. It also begs the question, that if I apparently know more than a journalist who specialises in something, what the hell does he or she do all day? If I were an editor I would get someone else! But the culture of “shut up, shape up or ship out” seems to have gone as well.

Seems like a charter for the work shy. Maybe I’m old fashioned.

Search and replace on a stream using 1.4 JDK CharSequence from an InputBuffer

My friend Roger informs me that this is a single library call in PHP. I once did this by using jtidy so I could get the html tags using an XML DOM, but that was very silly.

Been tearing my hair out – I want to be able to take the output from a URL and put it into a portlet. I therefore want to rewrite where the <form> tag sends back from one server so that I can put the portlet on the front of it.

1.4 JDK has a lovely regular expression thing so I don’t have to import the GNU RegExp libraries.

Great says I, only problem is that it uses the new CharSequence interface.

All of the examples are about reading files, not the contents of a URL, which I only seem to be able to get as an InputStream, which isn’t the same as a FileInputStream, and there’re all kinds of hoops you have to jump through that InputStream doesn’t have methods to deal with.

OK, have a look at the example in Java Examples in a Nutshell. It uses a byte[] buffer to read from the URL’s inputstream. Maybe I can put this into a StringBuffer and then use it because it implements the interface.

StringBuffer, quite logically, doesn’t have a way of appending arbitrary numbers of bytes from an array, only chars.

Then, dear reader, I realised that an InputStreamReader class will read chars. Finally, after about 2 hours googling my bonce off:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
public class RewriteURL 
{
  /**
   * 
   * @param in : the char sequence to replace
   * @param searchFor : what to search for
   * @param replaceWith : what to replace it with
   * 
   * Adapted from http://java.sun.com/developer/JDCTechTips/2002/tt0604.html#tip2
   */
  private static String replace
    ( CharSequence in
    , String searchFor
    , String replaceWith
    )
  {
    StringBuffer out = new StringBuffer() ;
    // Create a pattern to match search
    Pattern p = Pattern.compile(searchFor);
    // Create a matcher with an input string
    Matcher m = p.matcher(in);
    boolean result = m.find();
    // Loop through and create a new String 
    // with the replacements
    while(result) {
        m.appendReplacement(out, replaceWith);
        result = m.find();
    }
    // Add the last segment of input to 
    // the new String
    m.appendTail(out);
    
    return out.toString();
  }

  /**
   * 
   * @param args
   */
  public static void main(String[] args) throws Exception
  {
    
    URL url = new URL("http://some-server/someurl") ;
    InputStreamReader urlContents = new InputStreamReader(url.openStream());
    
    StringBuffer sb = new StringBuffer() ;
    
    char [] buffer = new char[4096] ;
    
    int bytes_read;
    while( ( bytes_read = urlContents.read(buffer)) != -1 )
    {
      sb.append(buffer,0,bytes_read) ;
    }
    
    System.out.println(replace( sb, "mvtest2.jsp", "someOtherForm.jsp" ));
}

I’m not sure how well this would work with a large file, but for trivial stuff it’s OK. There are some useful things on the GNU Regexp site as well

Firefox

I decided to try using Mozilla Firefox as my browser of choice. After I got the Java and Flash plug-ins installed it works fine. I like it a lot, particularly the tabbed interface, where you aren’t constantly going back to favorites over and over again.

I really like right-click, open in new tab!

One thing about tabs, though, there is a security vulnerability which is currently being fixed in that a naughty website can pop-up a confirm your password dialog box while you are in a secure tab. So, if you want to talk to your bank etc. then close all tabs or start a new window without them.

I hate these hacker bastards, wasting my time and energy.

Oracle JInitiator

Found this on another web site, you just need to go to c:program filesOracleJInitiatorx… (there’s one for each JInit you’ve installed) and copy the NPJinitXXXX.dll’s into the firefox plug in directory. These must be the JInitiatior files for NetScape, which Firefox understands.

Blog City

I’m quite happily using Firefox with the Java plug-in except for a minor thing with pressing the return key not inserting <p> tags. I’ve raised it but it’s not that much of a problem TBH.

Jon’s Birthday, writing projects

Was half way through a post when the Mac seized up. Hopefully the laptop will behave a bit better.

We had a birthday party for him on Thursday at a local sports centre. It was a football party and most of the kids joined in. It was a little weird where two of the kids wouldn’t because they don’t like football. I don’t get it myself in that why can’t you do the football thing for 20 minutes? It just goes to show that people are weird, even when they’re kids.

Birthday proper today. Gave him a kite from the Kite Shop. It’s an Orca and is good in relatively little wind. However there wasn’t quite enough on the beach today so we gave up after about 20 minutes.

Lots of cool presents.

I’m a bit skint at the moment, waiting for my other business to start paying and the job pays about 20% less that I was earning 2 1/2 years ago at the peak of the boom. Ah well, all the more reason to put my efforts into my other business.

Writing

I’ve decided to do another draft of Archive Fragments, play around with the formatting so it’s clearer what is happening in what time period. Also revise it some. I will start trying to tout it round in the next few weeks. The way to get published to be persistent. I have just been reading a book where the writer was rejected over a hundred times before making it into print. He didn’t bother counting the “failures”, just kept on asking the next guy. This is how you succeed.

Software projects

Done nothing for a while on my own projects. Suspect this is because I spend all day designing and writing software and I can’t face it later. Better payoff in other business anyway.

CSV export from oracle procedure, fun with CSS Styles

I remember doing this a long time ago and couldn’t work out what to put in the procedure to get the damn thing to tell the browser to start a CSV download. I was mixing up my protocols and couldn’t work out how to set the MIME type. Ultimately I needed to split it up and just put this at the beginning of the procedure:

htp.p(‘mime-type text/csv’);
htp.p(’’) ; — The blank like is mandatory

Then do ya thing.

Fun with CSS styles

This is a total pain.

Define a style, say, fred

<style>
.fred { color : white ;}
</style>

How do I pick up this style’s colour somewhere else? Inherit is simply to inherit from the containing style.

This doesn’t work:

<style>
.jim { color : inherit:fred }
</style>

Think I’ll have to do something in javascript

<script>
for ( var i = 0 ; i <= document.syleSheets.length )
// find my style jim (not sure how yet)
document.writeln(‘<style>’)
document.writeln(‘.fred { color : ’ + jim.color + ’}’
document.writeln(‘</style’);
</script>

Don’t know if this will work

October diary entry

Birthday

Birthday on the 8th, we went paddling in North Wales (Llangohlen and the Treweryn) that weekend with the club. Stayed at a nice pub called The Goat  where the kids had a good time. Poor Pete had a bit of an epic on the Trewy, but enjoyed it up until then. I drove us home in his Saab, which was a lovely drive. Piccies to follow if I can get hold of them.

Really fed up with being broke and also the work thing. Just not that interested, but keeping a professional attitude.

Birthday Meal

Excellent meal in Valpariso in Liverpool. Food cooked by a chef rather than assembled by a catering college graduate (no disrespect but you see what I mean?). Have the sea bass, or the rabbit, and the strawberry flambe!

Bristol

Odd place. Originally designed for pedestrians I think, cars just don’t work there. Went there for a couple of days’ meetings with customers. Really interesting how everyone’s needs were slightly different and we need to support them.

We went for a drink in the Coronation Tap (a dive, to be honest – didn’t like it a whole lot) and then on to an Indian restraunt called the Bombay Spice, food good but popadums were soft. Corrie Tap served stuff in plastic half pint glasses becuase apparently you can lose the ability to hold a pint if you drink too much of what the guys were drinking (Exhibition? something like that). I was drinking soft drinks and had a glass of wine with the meal. Don’t give a toss about this macho stuff, would rather not be ill.

Business

Still plugging away, making progress. This is not the forum to discuss it though.

Rownum in XSL

This is a special function in Oracle that allows you to get the number of the row you have retrieved, it can be used to manufacture a key or to restrict the number of rows you get in a query. XSL also has a rownum operator that tried to work because we had a string in a stylesheet that had the < character followed by rownum. Had to escape it and it startred working. Took several hours of head scratching to get to the bottom of it.

Portal

Doing some work with Portal 9.0.4. Yawn. Same as old portal but needs an enormous web server to get it going now. Not sure if this counts as progress.

IBS

My IBS is playing up again. Started about 5 a.m. with stabbing pains that kept waking me up. Sat on the throne: nothing.

All through the day at work about every 5-10 minutes it’s done it again. Taking my pills to no avail, haven’t had any tea today.

Took some Solpadine because it helps with pains.

Boring…

At least it isn’t once a month.

Friendly fire, anyone?

Quoting from this site:

Almost three years ago the naval systems arm of major UK defence contractor BAE Systems took the decision to standardise future development on Microsoft Windows. an immediate effect was to commit BAE’s joint venture CMS subsidiary, AMS, who specialise in naval Combat Management Systems, to implementing a Windows 2000-based CMS system for the new Type 45 Destroyer. But this prompted strong internal opposition from some of AMS’ engineers, who had a sound background in Unix and who had, despite resource starvation and a companywide policy to standardise on Windows, been investigating open source alternatives as a foundation for future combat systems.

… Click the link, it’s scary.

Holiday post

Went to a friends birthday party on 21st in Shrewsbury. Had a nice time there and drank some wicked punch. We sat and heard the fire works from the end of the flower show.

On the Sunday we went up to Lauder (Scotland). We arrived there in the afternoon to a very nice site (Caravan and Camping Club). The site had a little stream running around the back of it and Jon managed to get himself soaking wet inside about five seconds flat.

Floors castle took up most of Monday. Very pretty and we went for a walk down by the side of the river. River running very wide and fast.

Tuesday we went to Glentress Forest Trail to do some mountain biking. Rosie didn’t have a bike that would suit and thought hiring one a waste of money, which annoyed me for some reason. We went for a short ride to the training area where Jon went over some of the raised things etc. but I had a hard time staying on them. We then went down to where there was a reproduction of a stone-age building with some blurb on it. Jon tried to stop on the grassy bit with a flashy skid turn and lost it. He didn’t hurt himself much.

Wednesday we did Edinburgh. Got there in the rain and went round most of the way in a tour bus. We jumped off and had a nice meal in Rock City and then did the rest of the tour from the top of a bus in the dry. We got off at the castle, which was OK, but there was a lot of it. Then we walked the Royal Mile and watched a few street performances.

That evening we went for a pizza near the park and ride and watched the lightning go around the valley. There was no power at the campsite when we got back, there had been a direct strike on the transformer. It was restored at about 2 am, one of our neighbours had TV and everything set up and they all turned on when the power came back.

Thursday we went to North Berwick, which is a beautiful stretch of countryside, and had a look around the sea bird centre there. The weather was glorious and we went for a nice walk along the beach. It was raining everwhere else, but apparently North Berwick is next to one of the sunniest spots in the UK. It was interesting watching the weather move around the place. I suspect the Firth of Forth has its own microclimate.

Friday we went to a place called “Pot a Doodle Do”, the idea being that you get a piece of pottery and then paint it yourself. Jon got stung by a wasp on the neck but they had some magic stuff that sorted him out. To be honest, the place wasn’t worth more than one visit but Cocklawburn Beach nearby absolutely fantastic. We realised we were near my sister Liz so we popped round to see her, she made us very welcome and the kids went mad for her dog, Dougal.

Saturday spent watching some of the kids at our club compete in a Kayak slalom in Fernilee and then going to the barbie in the evening. We were going to stay there and decided not to because of the weather but in fact it was fine, ho hum.

Sunday travelled down the A68 to Teeside White Water centre where I managed to get a quick paddle in before it finished for the day. The Happy Eater ate me a couple of times but my roll was on song, fortunately.

Monday paddled with some of the guys from the club. Hannah discovered why the Riot Air has its name: unfortunately we don’t have a picture of her in mid air. I worked on my fear of the latter third of the course and successfully got down Valentines and the Acid Drop several times (to be fair the tide wasn’t far enough out to make the Acid Drop more than an interestingly big wave for about half an hour).

Had a nice meal in the Talpore – it was Roger’s birthday. The water was running at 2 pm or so in the afternoon on Tuesday so we decided to pack up.

Back at work for three days but paddling in the evenings.

We were due to go to Bala with the Canoe Camping club but the campsite was flooded so we tried a different site in central wales, see http://www.gwynant.com/.

The only real problem I’ve had recently is that my feet start to hurt after about 20 minutes of walking (and I mean hurt). Possibly something to do with the circulation? Need to see the doctor.

Will post photo album here when I can find the time.