IT, computer and programming tutorials and tips that i couldnt find anywhere else using google, from my daily work as a Senior Developer of solutions using Java and Linux.

The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

if you have a button that opens a modal panel and you want to set the focus to the first text input field, then use the rich:modalPanel's onshow attribute:<rich:modalPanel onshow="document.getElementById('trq_det_form:hit_marking').focus()" ...

trq_det_form is the modaldPanel form id and hit_marking is the textfield input id.

20130924

the following code works both for single modal panels AND for multi-level modal panels (modal panels that open new modal panels, i.e. more than one modal panel open at the same time/on top of each other).

note: all rich:modalPanel tags must have a unique id attribute.

note: for some reason (1, 2), at least in our company's app, you have click the modal panel and then press escape in order for the "hide" functionality to work, so if anyone has a solution to this, i'd love to hear it. i tried generating a javascript click() event on the modalpanel to set focus to it, but it didn't help/work. but, despite that, it's still better and faster than having to mouse up to the "x" (close) icon or down to the cancel button at the bottom :)

every time a new modalpanel is opened, its id is placed at the beginning of the array and "older" panels (that are still open) get pushed further back in the array so that when you close the modalpanel on top, the code simply removes the id at the front of the array--index 0 (zero).

activeModalPanel is the modalpanel id that will get closed when you press the escape key

explanation of if(a && (a != "wait")):

during my testing of the code, i found out that the functions removeModal and addModal get run, no matter what, the first time ActiveModal gets initialized, and the "a" parameter is undefined (nothing). also, sometimes during processing, the parameter in to the functions has the value "wait". so, i don't want to do anything in the functions unless the parameter exists AND it isn't equal to "wait".

the parameter ('x') can be anything you want because the removeModal function simply removes the modal panel id at the beginning of the array (index 0), but we need some kind of text string sent in so we know that the function was called by the user and that it wasn't called during initialization of the ActiveModal object AND that it isn't a "wait" (see my explanation above).

the URL for the highest quality version of the video is the one that ends in "index_4_av.m3u8" (you can also see that in the comment above it, it says 1280x720).

now make sure you have avconv installed from ubuntu's repos:sudo apt-get install avconv

the portion of the news about Yassin begins at 04 minutes and 11 seconds and lasts for 5 minutes. I don't want the whole news report which is like 15 minutes long, so run the following command in a terminal window:cd

when the downloading and converting is done, the resulting video file will now be in your Downloads folder:/home/me/Downloads/yassin.mp4

if you want to download the whole video just cut out the time parameter parts, e.g.:avconv -i "http://nordond27a-f.akamaihd.net/i/wo/open/b5/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc/b59297a8dd562f58eb7a5f77d101b0a7eb4500dc_,141,316,563,1266,2250,.mp4.csmil/index_4_av.m3u8" -codec copy yassin.mp4

then specified the video and audio codecs to use, like this:avconv -i http://nrkclip3b-f.akamaihd.net/i/wo/open/84/84af95d37d4b5c59574b6d45589612e022d52762/84af95d37d4b5c59574b6d45589612e022d52762_,141,316,563,1266,2250,.mp4.csmil/index_4_av.m3u8 -c:v libx264 -c:a libvo_aacenc knaus2.mp4
then it worked :)

here's one way to access the element using regexp: _cell(/invFormremoveTRQPanel:removeTrqPnlTbl:0:*/+"[1]")

invFormremoveTRQPanel:removeTrqPnlTbl:0 == the row identifier/.../ == regular expression code* == match any auto-generated id string, e.g. j_id162, this will match every column in the first row
so to specify which column (0-based) we want we write [1]

i needed a simple way to generate a date string so i could set a rich:calendar textbox input field using a sahi script, so here's sample code for one solution to generating tomorrow's date as a text string:var $formattedDate = java.util.Calendar.getInstance();$formattedDate.add(java.util.Calendar.DAY_OF_YEAR, 1);$formattedDate = new java.text.SimpleDateFormat("dd.MM.yyyy").format($formattedDate.getTime());_alert($formattedDate);

20130910

i have a datatable that expands with a new row every time i click an "add new row" button, and only the new row will have an editable textfield input, so to generalize the sahi script code you can use a regex, so it will match whichever single row has a visible textfield input:_setValue(_textbox(/detailForm:agrSCFactorsTable:\d{1}:SCF_nameIn/), $name);

20130904

i noticed on the sahi "for loops" documentation page that the for loop variable "i" wasn't being declared with a dollar sign ( $ ):

for (var i=0; i<links.length; i++){...

so when i wrote a for loop in one of my tests i decided to insert a dollar sign for consistency purposes (so all variables used the dollar sign):function setTimeFutureHours($hrs) { ... for(var $i=0; i<$hrs; $i++) { ... }}

but when i ran the code, the for loop never ran. i quickly realized that i hadn't put a dollar sign next to the "i" in the middle, so i changed it and it ran perfectly:

just out of curiosity, i tried the code without dollar signs next to the "i", like the documentation said and that also worked; you just have to be consistent and either use dollar signs on all of the variables in the for loop phrase or don't use dollar signs ;)

the following sahi code ...
* opens this date+time setting modal panel
* gets the current hour value (originally "12")
* clicks the "up arrow" icon for hour ("Time" in norwegian) to make the hour "13"
* verifies that the hour got set correctly
* then clicks the "set time" submit button ("Sett tid" in norwegian)
* then verifies that the modal panel is closed--the submit button is no longer visible

var $currentHour = _fetch(_textbox("dateAndTimeSetterForm:hourSpinner").value);// clicks the first hour spinner based on class--there are two and "up 1
hour" is on top, i.e. first, so "down 1 hour" would be
"rich-spinner-btn rich-spinner-button[1]" _click(_imageSubmitButton("rich-spinner-btn rich-spinner-button", _in(_table("dateAndTimeSetterForm:hourSpinnerButtons"))));

20130902

we have some code that gets a URL parameter value:String savedSearchName = context.getExternalContext().getRequestParameterMap().get("name");

the URL looks like this:http://localhost:9001/pages/listTRs.jsf?a=li&name=testsøk1

so even though the parameter looked like it had the right norwegian encoding (testsøk1), when we got the parameter value for "name", in java, the String savedSearchName had the following value:testsÃ¸k1

to fix this we had to change the following file:/path/to/jboss/server/mydomain/deploy/jboss-web.deployer/server.xml