bookmark_borderindip: really cool type-ahead

this time just a link to share with you guys out there.

A REALLY, did I make this clear? REALLY REALLY cool fancy way to make type aheads the way I need them:

http://www.timtripcony.com/blog.nsf/d6plinks/TTRY-7XD5P9

kudos to Tim Tripcony


Summary:
1. in the outline of the editbox with type ahead you will find below the “ajax” component. Select it to see it’s properties in the appropriate pane.
2. select valueMarkup = true
3. add a function name (eg. getNames(searchValue) which returns an unordered list of elements and surround every part which should NOT be part of the value returned into the field with: <span class=”informal”>text you don’t want in the field after selecting the target value</span>
4. add searchValue in the var property

we use Managed Beans to return type aheads (which makes it WAY faster as the JavaScript does not need to be evaluated!)

bookmark_borderindip: making type-ahead easy as pie in 3 steps!!!

Did you ever use the Extension library names picker? Do you like it? I don’t!

Why? It requires the user to use his mouse and make too many clicks to get to what he wants.

I have a better way to achieve it and it can be adopted to any type-ahead you would like: in only 3 steps!!!

And the coolest thing is: you can actually “fine tune” it.

Just to give a clue:
We have a database regarding travels which requires the user to enter his flights, we have a huge list of airports worldwide. So the user has 3 options for type-ahead: 2 characters will search for all airports in the country with that ISO code, 3 characters will search for a specific airport by that identifier and if the user enters more characters a full text search is being conducted! Ain’t that cool?

Steps: (check out the color coding where each piece goes to)
1. Define the field, make sure the var attribute is the one used as parameter to the method call of your bean, make sure the Class name is the name you defined as bean name (see step 3)

<?xml version=”1.0″ encoding=”UTF-8″?>
<xp:view xmlns:xp=”http://www.ibm.com/xsp/core”>
<xp:inputText id=”airport”>
<xp:typeAhead mode=”partial” minChars=”2″ var=”searchValue
preventFiltering=”true”
valueList=”#{javascript:TypeAHeadBean.searchAirport(searchValue)}”
ignoreCase=”true”>
</xp:typeAhead>
</xp:inputText>
</xp:view>
2. Define the bean:
public class YourBean implements Serializable{

private static final long serialVersionUID = -4498155370434392583L; // this can be auto generated and is required for beans as they have to be serializable

public ArrayList<String> searchAirport(String searchValue){
try {
ArrayList<String> al = new ArrayList<String>();

Database db = (Database) DominoUtils.getCurrentDatabase();

                         // this is the part you may want to customize, ie with a creative view you might not need FTSearch (take a look at ($Users) in the names.nsf
View view = db.getView(“lupAirports”);
if( 2 == searchValue.length()){
view.FTSearch(“[AirportCountryCode]=”+searchValue, 0);
}else if(3 == searchValue.length()){
view.FTSearch(“[AirportCode]=”+searchValue, 0);
}else{
view.FTSearch(“*” + searchValue.toLowerCase() + “*”, 0);
}


Document doc = view.getFirstDocument();

while(null != doc ){
                                // the values you add here will be displayed in the type ahead
al.add(doc.getItemValueString(“AirportName”));

doc = view.getNextDocument(doc);
}
                        // maybe you wanna sort the result properly
Collections.sort(al);
return al;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}

}

// maybe you wanna add some “recycling of Notes objects”…

3. Setup the bean:
Add the bean to the faces-config.xml
  <managed-bean>
    <managed-bean-name>TypeAHeadBean</managed-bean-name>
    <managed-bean-class>com.acme.YourBean</managed-bean-class>
    <managed-bean-scope>view</managed-bean-scope>
  </managed-bean>
If you open the Package Explorer view you will find the faces-config.xml here:

Results:
more than 3 characters type-ahead conducting a fulltext search

3 characters type-ahead which looks up the specific airport

2 characters type-ahead which looks for all airports in the country denoted by the 2 character ISO code

I hope one again you enjoyed my blog.. any comments are welcome, don’t hesitate starting a discussion about an interesting topic

bookmark_borderquindip: use ctrl F8 to switch perspectives

so you read my article about how easy it is to debug xPages and now get stuck in the debug perspective all the time but you would like to checkout your code etc?

simple: use <ctrl><F8> to switch perspectives.

If you open first all those perspectives you don’t need and close them via WindowClose Perspective then it’s a simple matter of <ctrl><F8> to switch between Debug and xPages perspective

ah.. as a side note:

did you know that you can actually “debug” the building of the xPage component tree itself?
Open the Package Explorer view and inside your LN application open the Localxsp folder. There you will find the Java classes which have been created out of the XML in the xPages designer!

You can then set a breakpoint in the Java class for your xPage here:

    protected AbstractCompiledPage createPage(int pageIndex) {
        return new nameOfYourXPage();
    }

bookmark_borderquindip: accessing grouped values (checkbox/radio groups)

I was trying to get the selected values from a check box group, but I failed miserably…

Almost when I gave up I got an error and then I found this site:
the XPages Extensibility API Documentation

via the class XspSelectManyCheckbox I then figured I had to search for the JSF API.

There I found this:
java.lang.Object[] getSelectedValues() 
Return the currently selected values, or null if there are no currently selected values.

which basically means:

getComponent(“myCheckBoxGroupID”).getSelectedValues() will return an ARRAY!!! checkout the [] at the end the object.

so finally it was easy to parse the selected values:
var valueArray = getComponent(“myCheckBoxGroupID”).getSelectedValues();
// valueArray[0] contains the first value
// valueArray[1] contains the second value etc.

can you believe it how stupid I am? and how relieved to finally have found a way to read the selected values with SSJS?

bookmark_borderquindip: how to make extension library tooltips work properly

It’s really simple:

Drag’n drop a tooltip control from the extension library controls onto your page and set the appropriate properties:

XML source code:

<xe:tooltip id=”tooltip1″ for=”id_of_object_for_which_this_tooltip_displays” label=”text to display in the web page while hovering the target object”></xe:tooltip>

Result:

The only thing left is to add proper styling. As soon as I have themes working the way I require I will post more on this here

bookmark_bordercreating curved arrows in Illustrator (tutorial)

For my studies I had to create a nice little graphic with curved arrows and they should contain text in them. I thought Illustrator might be the tool to use. But admittedly I am not a hard-core Illustrator user and hence I had to dig a bit to find out more how to do this…

I found several suggestions but then at last I figured the most easy way is like this:

  1. Create a circle
  2. Divide the circle into how many parts as you need arrows around it:
    1. Add a line from center of the circle to its circumference
    2. Rotate that line, create a copy, with the rotate tool by the amount of angle you need, pay attention that the rotating center is put onto the center of the circle, do this by (on the mac) <option>clicking the center of the circle, then add the angle and click the copy button
    3. (on the mac) press <command>d to repeat (Transform again) until the circle has as many “pie pieces” as you need
    4. cut the circle with the scissors tool on the intersection points of the lines with the circle, to make this easier you may first “lock” the lines in the layers palette
    5. remove the lines again
  3. select all bows and add an arrow brush to your liking
  4. tweak the arrows in width: use the “Options for selected objects…” under the brushes palette menu and the width tool to adjust the arrows to your liking
    See Tutorial on the “variable width profile”
Screenshots:
Width tool to adjust the path width of the arrows

bookmark_borderquindip: debugging java in xPages made simple (four steps)

for some of you this might be the almost perfect XMas gift from me.

I finally figured how to debug Java code in an xPage application, and it’s DEAD SIMPLE…

if only more people would blog about it…

so here is how:

1. Create a debug configuration. The debug button might not always be visible, you will see it definetely by switching to the Java perspective.

2. add those 2 lines to your notes.ini and restart your notes client/designer
JavaEnableDebug=1
JavaDebugOptions=transport=dt_socket,server=y,suspend=n,address=8000
3. set any break point
4. do anything on an xPage which goes to Java, say using a Managed Bean or call a method from a normal Java class and voilà the debugger activates and you can check your code..
Most probably the first attempt will result not result in actually seeing code… you might get this result:
don’t desperate, click the button and then add your project and you will see your code… 
I wonder why IBM does not promote this VERY VERY VERY publicly… you have to again.. by accident stumble accross a video from Niklas Heidloff (kudos to him) 
this will save me soooooooooooooooooooooooooooooooooooooooooooooooo many headaches!!!

bookmark_borderquindip: prevent SameTime windows popping to the front

do you use SameTime? we use it a lot!
are you annoyed when someone sends you a message and the window pops to the front while you are typing something somewhere? I am!

here is the solution:

the setting “Bring chat window to front” is VERY hidden! You have to select the one-on-one chat notification to actually see that property!