Tuesday 25 September 2012

Check All check boxes in oracle apex report

If you have a report that contains check boxes (to do this see the APEX_ITEM API) you may want add a function to check or uncheck all of the boxes at once.

To do this in a standard report change the name of the column in the report attributes to

"<input type="Checkbox" onclick="$f_CheckFirstColumn(this)"><span>Column name here</span>"

This creates a check box in the title that when checked will check all of the boxes. However if you have an interactive report this solution is not suitable as clicking on this top check box will bring up the column sorting and filtering options.

In this case the solution can be found in an Apex Njnja's white paper on page 17

The solution from this paper is quoted here


Select/unselect all

Another functionality that is a must, especially when working with many rows, is a select/unselect all.
This can be done by creating an item situated in the IR region, located above the region. Create the item
as display as text,without any label. Then, in the Pre Element Text region, paste this code:

"<input type="button" name="CheckAll" value="[+]"
onClick="checkAll(f01)">
<input type="button" name="CheckAll" value="[-]"
onClick="uncheckAll(f01)">"

This will add the two buttons on your screen:

Now, add the two javascript functions inside you page HTML  Header :

"<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkAll(field)
{
for (i = 0; i < field.length; i++)
{field[i].checked = true;}
}
function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
{field[i].checked = false ;}
}
</script>"

These functions will be called when clicking the two buttons created before and will check/uncheck all
of the checkboxes from the IR.



Friday 17 August 2012

APEX_ITEM not displaying properly in oracle APEX 4.1

Hi all,

I just experienced this problem and thought I'd share it in case anybody else runs into it. The problem is that after upgrading to apex 4.1 my reports that use the APEX_ITEM API were no longer displaying properly. They were displaying like as the actual html code

e.g. "<input type="text" name ="f02" size="10", maxlength ="10", value = "Test" />"

I don't know why the upgrade changed these columns but if this has happened to you here's how to fix it.
1. go to the region settings
2. go to the report attributes tab
3. click on the little pencil icon which indicates column attributes (for the column using the apex_item api)
4. change "Display As" under column attributes to "Standard Report Column"

Not a very difficult problem but if like me you were unaware that this attribute would be changed by the upgrade this will hopefully be helpful to you.

Tuesday 31 July 2012

Some useful links for creating cron expressions

If you ever have to create cron expressions (I do while working with the Quartz Scheduler) these links may be helpful to you.

Firstly a basic cron expression tutorial for quartz (what they are, the basics and some examples)
http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger

some more examples of working with the cron format
http://www.nncron.ru/help/EN/working/cron-format.htm

And finally a useful website which can generate basic cron expressions for you and can be used to check that cron expression you have written do what you think they do.
http://www.cronmaker.com/

Hope this helps

Tuesday 24 July 2012

Using Anchors in oracle apex


When creating an apex chart I put in a feature where the user could refresh the page after changing a select list value. This left me with a problem as the chart was at the bottom of the page and when the page reloaded  the focus was repositioned at the top meaning the user would have to scroll down. To fix this I used an anchor in the page and then navigated to the anchor in the branch of my page.
   I thought I'd blog this as I only saw how to do it as a throw away comment on a forum post and if like me you didn't know how to do this you may find this entry useful.

The technique is simple really create an anchor in the location I want the page to scroll to. In apex this would most likely be the top of a region so you can put it in the title of the region e.g.


<a name ="CHART" ></a>Hourly Report

CHART will be the anchor and Hourly Report the title of your region

Now if you have a branch that submits the page to refresh the graph then you can use the value of the anchor to navigate to that region.

To do this add #CHART (or # followed by your anchor value) to the "with these values" field under actions (branch to page in this application with the page set to the current page). Now that branch will take you to the anchor. this technique will work for anchors on other pages as well.

Note: if you look at the branch later it will redirect to a url like
f?p=&APP_ID.:39:&SESSION.::&DEBUG.:::#CHART

Hope this helps





Wednesday 11 July 2012

Finding Duplicate and similar records in Oracle Table

One of the things I have recently learnt is a way to find duplicates in Oracle tables. I have seen ways to do this but have not come across the method I am going to put in this blog so hopefully some of you will find it useful.

The technique is to use aliases rather than counts (which I have seen on other forums) to select from the table twice.

The basic query is


  SELECT t1.column_name,
FROM table t1, table t2
where t1.column_name = t2.column_name,
and t1.column_ID <> t2.column_ID

This means that we are checking if there exist records that share the column value we are testing (column_name) but have a different ID/primary key.

The real problem I faced however was finding records where part of the value was a duplicate. In this case I needed to identify values such as example_xxx and example_yyy with the yyy ending being an incorrect entry.

To do this I used the replace function so the query looks like this


  SELECT t1.column_name,  t2.column_name
FROM table t1, table t2
where replace(t1.column_name, '_xxx', '') = replace(t2.column_name,'_yyy',''),
and t1.column_ID <> t2.column_ID






Friday 1 June 2012

how to stop skype sound transferring from headphones to speakers

While working I like to use my headphones to listen to music etc. It can be quite annoying however when I receive a skype message or call and the sound transfers to my computers loud speakers . In order to resolve this go to

Tools > Options > Audio settings
set Speakers to  Speakers/Headphones
set Ringing to use selected speakers
save the settings

This worked for me, hope it helps

Thursday 17 May 2012

No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 0

If you come across the error
No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 0
while using rest web services add the configuration
<import resource="classpath:upgrade-downgrade-business-context.xml"/>

to your servlet.xml file

hope this helps, it worked for me

@RequestMapping - A quick tutorial on Multiple and Conditional Parameters

I've been doing some work with recently creating Java rest web services. In doing this I've learnt a couple of nifty things about the @RequestMapping annotation. This information seems to be spread around quite a lot of forums etc so I thought it would be good to compile it into one tutorial.

The @RequestMapping annotation is used to define the URL pattern that will trigger your code when the web service is called.

So an annotation Like this
@RequestMapping(value = "/example/{id}", method = RequestMethod.GET)
public Example exampleMethod(@PathVariable("id") Long id){
...Code goes here
}

means that the method exampleMethod will be triggered by a URL like this
http://llocalhost:8080/example-ws/example/13

Two things I've seen asked on the internet quite a lot is how can I have multiple mappings and conditional mappings.

Multiple Mappings
The value parameter of @RequestMapping is of type String [] so an annotation of the form

@RequestMapping(value = {"/example", "/example/{id}"}, method = RequestMethod.GET)

Will allow both the urls
http://llocalhost:8080/example-ws/example/13 and http://llocalhost:8080/example-ws/example
to execute the code that follows the annotation.

Conditional Mappings
If you want to execute different code based on what url is sent then simply have multiple methods using different @RequestMapping parameters

so in the same class you would have

@RequestMapping(value = "/example1/{id}", method = RequestMethod.GET)
...Method 1 goes here

and


@RequestMapping(value = "/example2/{id}", method = RequestMethod.GET)
...Method 2 goes here


this would allow you to call method 1 with
http://llocalhost:8080/example-ws/example1/13

and method 2 with
http://llocalhost:8080/example-ws/example2/13


Hopefully you find this tutorial helpful as it took me a while to find this information

Monday 9 April 2012

Scenario Workflow Failure [cor:999995] - sky go

The error Scenario Workflow Failure [cor:999995] seems to occur if your computer loses power while watching sky go.

If anyone has experienced the error
Scenario Workflow Failure [cor:999995] on sky go here's how to fix it


  1. Right click on the video play area
  2. Click silverlight then go to the application storage tab
  3. Delete all lines that reference sky
  4. Make sure the download check box under the play back tab is checked
  5. refresh the browser


http://helpforum.sky.com/t5/Using-Sky-Go/Scenario-Workflow-Failure-cor-999995/td-p/238639/page/2

hope this helps.

Also Sky go won't work with ad block enabled.

Thursday 5 April 2012

Google Goggles

Not a problem but something cool I'd just like to share.

So google are looking transform our world and believe that augmented reality goggles can replace smart phones. It looks like an idea that could work amazingly well and I'm interested to see how it progresses.

See the video below and comment and tell me what you think