Getting a background texture behind a UITableView

In many apps when you viewing the top of a UITableView and you pull down you get one of three things: a plain white background (i.e. YouTube), a pull to refresh (i.e. twitter), or a textured or differently colored background (i.e. contacts). By default when you have a UITableView, you will get the first option, a plain white background.

If however you would like to do something like contacts where the perceived “background” of the table view is something other than default. If that’s the case, it’s relatively easy to do. Here’s how.

In your UITableViewController (usually viewDidLoad:)

// This sets the lighter linen looking background.  see UIColor for more "System Colors"
[[[self navigationController] view] setBackgroundColor:[UIColor underPageBackgroundColor]];
// Make the background of the table view transparent.
[[self tableView] setBackgroundColor:[UIColor clearColor]];

Then implement this method in your UITableViewController:

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    [cell setBackgroundColor:[UIColor whiteColor]];
}

After playing around and failing in different ways, this seems to be the simplest solution by far. Simple, easy and does what it should.

05. December 2011 by Jason
Categories: Development, Mac, Objective-c | Leave a comment

Mac OS X Lion Clean Install Quirks

I decided to do a clean install on my development laptop with Lion to clean out the cruft. Not that it really needed to be done, but I was curious to see if there were any discernible differences between the Snow Leopard (SL) upgrade and a clean install.

For those who are wondering, you can find a plethora of resources on how to do it if you so choose, but I did want to point out a few quirks that I ran into after the install. I’m not sure if these are environmental differences that I had adjusted a some point in the past, but when I re-installed a clean version of Lion a few things changed.

  1. Mission Control – By default, there’s really only one space. If you upgraded an existing SL installation and used spaces, it created them by default in MC. Furthermore, Control-UP activates MC. Control-Down does the old Exposé routine.
  2. Tap to Drag – I don’t remember the actual starting state of this but I checked on another laptop and my desktop with the Magic Trackpad and they were configured the same so I’m working under the assumption that this may affect a few people like myself. If you were used to the whole tap to drag routine, it’s not there — well technical it’s there but not active. Once you activate the tap to click, tap to drag doesn’t. And it’s not in the Trackpad preference pane either. Strangely enough, it’s tucked away under Universal Access/ Mouse & Trackpad/ Trackpad Options…Universal Access Preference Pane

As I find more quirks I’ll update this post.

Enjoy.

29. July 2011 by Jason
Categories: Mac | Tags: , | Leave a comment

Selective Site Mirroring with wget

Since Cloudera doesn’t seem to support an rsync server for us to mirror against, I had to resort to using wget to mirror their CDH distribution. To save some time for those who are attempting to do something similar, here’s a wget one-liner to grab only the RPM’s (while maintaining the directory structure):


wget -N -r -nH -np --cut-dirs=3 -A rpm,xml http://archive.cloudera.com/redhat/cdh/3/

11. May 2011 by Jason
Categories: UNIX | Tags: | 2 comments

Create a Linux Boot ISO image to start via Kickstart

Getting tired of creating new VM’s, and don’t want to clone for a particular reason but want them standardized? Easy. By creating a boot image that immediately starts a kickstart installation, you can completely automate creating a VM regardless of virtualization solution your using.

To create the isolinux boot image:

Mount the DVD image.

mount -o loop /path/to/dvd.iso /mnt

Copy the data locally.

rsync -av /mnt/isolinux [where ever]

Edit the isolinux.cfg file to update and point to proper kickstart location, and make it auto start by setting prompt to 0.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
default linux
prompt 0
timeout 600
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
  kernel vmlinuz
  append initrd=initrd.img ks=nfs:192.168.0.1:/mnt/vg1/iso/kickstart/centos55_text.ks
label text
  kernel vmlinuz
  append initrd=initrd.img text
label ks
  kernel vmlinuz
  append ks initrd=initrd.img
label local
  localboot 1
label memtest86
  kernel memtest
  append -

Create a simple script in the isolinux directory to do the heavy lifting.

1
2
3
4
5
6
#!/bin/sh
ISO_NAME=centos55_boot.iso
# Remove the old iso.
rm -f $ISO_NAME
# Make the image.
mkisofs -o $ISO_NAME -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T $PWD

Kick it off and you should now have a viable boot image. Once you boot the newly created guest, just boot using the new image and it will automatically start your kickstart installation.

20. January 2011 by Jason
Categories: Linux, Virtualization | Tags: , , | 3 comments

OpenAM Apache Web Agent

Make sure you set the Encode Cookie Value to Yes or True. If it’s not able to be modified, it’s an inherited setting that you will need to change. If you don’t, you’ll get a 500 error once a successful login has occurred.

27. December 2010 by Jason
Categories: Java | Tags: | Leave a comment

Update Postgres in Ubuntu

The Postgres website download page doesn’t do a great job of documenting how to keep PG up to the latest release. Even for those of us who are using 10.10, the standard repositories still point to older 8.X versions. To ensure that you have access to the latest version of PostgreSQL in Ubuntu, install Martin Pitt’s backports PPA. If you are running Ubuntu >= 9.10 you can do this with one simple command:

sudo add-apt-repository ppa:pitti/postgresql

Once that is done, you may need to enable the updates to use backports. In Synaptic, open Settings -> Repositories and select the Updates tab. Make sure that “Unsupported updates” is checked.

Then just update as usual, and Postgres will be updated to the latest and greatest.

30. November 2010 by Jason
Categories: Linux | Tags: | Leave a comment

Regex Recipes

Since I went through the time to create these, I might as well document a few of them for myself and anyone else who might be looking for it. As I refine and author more, I’ll add them here.

Phone Number Validation

This would be useful to validate phone numbers of customers, clients or prospects. This only validates the 10 digit phone number that does not have parenthesis and dashes. Minor modifications would be necessary to validate with those formatting characters included. (via NANPA.)

^(8(?:00|88)|([2-9])(?!\2{2}|9[\d]|00|11)[\d]{2})([2-9&&[^5]][\d]{2}|(?:5(?!55)[\d]{2}))([\d]{4})$

[UPDATE: Didn't like what I had before and this should be a smaller, more optimized, version.]
This regex covers:

  • All ERC (Easily Recognizable Codes) which would include codes like 333,444,555, etc.
  • Allowance for toll-free numbers (800,866,877,888, etc.)
  • ERC Service codes 211,311,411,511,611,711,811,911.
  • Unallocated and/or premium codes (200,300,400,500,700,900, etc.)
  • Standard area codes from 201 to 989.
  • Removal of 555 Central Office prefix.

If you want to give these a try there are a number of online utilities, but RegExr is one of my favorites.

24. August 2010 by Jason
Categories: Development | Tags: | Leave a comment

Install VirtualBox Guest Additions on CentOS 5.x

This has been documented many times before, but for some reason installing VirtualBox guest additions on CentOS is a pain. To install them:

  1. yum install kernel-devel gcc
  2. either ln -s /usr/src/kernel/[current version] /usr/src/linux or
  3. export KERN_DIR=/usr/src/kernel/[current version]
  4. Then the usual ./VBoxLinuxAdditions-[arch].run

For whatever reason, the VirtualBox guest additions still expect to find the kernel headers in /usr/src/linux and not the location in which they are really installed to.

10. August 2010 by Jason
Categories: Virtualization | Tags: , | 1 comment

Really Using OpenSSO with Salesforce

This subject has been covered many times before, but one thing that is not easily identified in ANY of them is that for this to work properly, you must be using a version of OpenSSO express, not enterprise. You’ll bang your head against a rock looking for a solution.

The problem is that OpenSSO express doesn’t exist anymore. Well not in a form supported/provided by Oracle. ForgeRock now has it and it’s been rebranded to OpenAM. The good news is that all of these tutorials and documents still are valid — so long as you actually got the right piece of software.

I wish that when folks write documentation they include specifics about the software they are writing about. But then again, maybe it’s just me…

09. July 2010 by Jason
Categories: Salesforce | Tags: , | Leave a comment

SalesForce.com JAX-WS & Netbeans

The process for using SalesForce.com (SFDC) webservices in Netbeans isn’t as intuitive as you would think. Most of the SFDC documentation examples are built using Apache Axis vis-a-vis JAX-WS. The good news is that it’s possible to get Netbeans (and therefore JAX-WS) to properly build a WS client for SFDC.

Once you’ve downloaded your organizations enterprise or partner WSDL, in Netbeans, right-click on the project and select New -> Web Service Client (if it’s not there then New -> Other -> Web Services Category, and then Web Service Client). Select Local File and Browse to the location of your downloaded WSDL. Specify your package and leave the Client Style as JAX-WS and “Generate Dispatch Code” unselected.

Netbeans will attempt to do it’s thing and fail with an error – however, it’s not the only thing standing between you and a working web service client in Netbeans. Below is the error that I received.



In this case, it’s complaining about a ComplexType and element that share the same name. There are two different ways to solve the problem and really only one that works with Netbeans. To properly fix the issue (and have Netbeans “see” the fix) you need to create a JAX-WS binding document to prevent the naming collision from occurring. To do this create a new file and cut and paste this into it. You may have to adjust the @targetNamespace='urn:enterprise.soap.sforce.com' to whichever version (enterprise or partner) your using.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<bindings
  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns="http://java.sun.com/xml/ns/jaxws" wsdlLocation="../wsdl/enterprise.wsdl">
  <bindings
    node="//xsd:schema[@targetNamespace='urn:enterprise.soap.sforce.com']">
    <jaxb:globalBindings
      underscoreBinding="asCharInWord" />
    <jaxb:schemaBindings>
      <jaxb:nameXmlTransform>
        <jaxb:typeName suffix="Type" />
      </jaxb:nameXmlTransform>
    </jaxb:schemaBindings>
  </bindings>
  <enableWrapperStyle>false</enableWrapperStyle>
  <enableAsyncMapping>false</enableAsyncMapping>
</bindings>

But we’re not done quite yet. Even though the first attempt failed, Netbeans created a new “Web Service References” node in the Projects tree. If you expand that node, you’ll see your webservice. Right-click on the service and select “Edit Web Service Attributes”. Select the “WSDL Customization” tab and scroll all the way to the bottom section named “External Binding Files”. Expand it, and click “Add”. Answer “Yes” to the dialog and then find the xml file you created earlier that contained the binding changes.

Once you select “OK”, a dialog will appear indicating that a refresh of the client is underway. At that point, Netbeans will attempt to re-create the client. If all goes well you should have a working SFDC client in Netbeans.

[UPDATE 1]

The security model in the SFDC API is interesting. In order to properly utilize the service, you must do two things after logging in. One, re-point to a URL that actually contains your organization, and two, make all subsequent calls to that new URL with a session ID that is provided as a result of the login process. The good thing is it’s documented. The bad thing is it’s not documented well at all for JAXWS. What follows is a condensed version of what it took to make it really work.

Repoint to the correct URL

You log into one URL and as part of the LoginResponse you get the real URL of your organization. All subsequent calls made after logging in must use this new URL. It’s in the documentation and described well. However, the redirection of subsequent calls requires the user (caller) to change the ENDPOINT_ADDRESS_PROPERTY to the new URL. The SFDC documentation that uses Axis, shows that with Axis the ability to manipulate a SOAP binding property is relatively straightforward. Unfortunately it’s not quite so simple with JAXWS.

All of the documentation regarding using JAXWS in SFDC focuses on the use of the non-standard com.sun.xml.internal.ws.developer.WSBindingProvider to get access to the SOAP binding properties to insert the new endpoint URL once the login has successfully completed. For some reason, if you attempt to use this from glassfish, the downcast of the port to WSBindingProvider causes an exception preventing it from working properly and successfully getting the port to re-point to the proper endpoint URL. However, I was able to figure a way around the WSBindingProvider to get access to the SOAP header to set the proper endpoint address. I’ll detail that step in another post.

Provide the proper session ID

This workaround was somewhat simpler even though the reasons are just a complex. The short answer is that the SOAP headers are not implicitly defined in the Salesforce.com WSDL. Because the SOAP headers are defined in the WSDL binding section instead of the portType section, they don’t become available and you won’t be able to get set the proper session ID wihout getting really creative. The solution is very straightforward. In the WSImport Options tab where you set the jaxb options, set one more WSImport Option as well. Add in xadditionalHeaders and true.

When done successfully, the method signatures will now include a parameter for the SessionHeader (where you set the sessionID).

I’m going to show a full working example of all of this in a subsequent post for those who want/need more information.

[UPDATE 2]

Upon further testing it appears that wsimport will disregard the -XautoNameResolution if you also provide a mapping file because they’re actually attempting to do the same thing. Furthermore, if you just use -XautoNameResolution without the mapping, wsimport will work properly however Netbeans doesn’t “see” the fix and still complains even though you can compile and run. Removing the references for -XautoNameResolution for now.

Enjoy.

26. February 2010 by Jason
Categories: Development, Java | Tags: , , | 9 comments

← Older posts