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.

My Music (Nickleus)

20140331

sahi, suggestion: "_wait(maxTime, condition)" with "AND" functionality, not just "OR" -- stop execution if "condition" returns false

i wish there was an additional "_wait(maxTime, condition)" function that would stop execution if condition returns false.

as of now, it seems as if "wait + condition" continues execution no matter the outcome of "condition", which makes it an "OR" test, but my suggestion would be for an "AND" test, i.e.:
wait, up until maxTime is reached, and if condition is still false, then stop execution.

i want this because of network/server response timing issues, specifically related to ajax operations.

UPDATE
i just posted this as a discussion in the sahi forums:
suggestion for _wait: stop execution if condition returns false

UPDATE, WORKAROUND
to achieve the same thing today, it looks like you'd have to code it like this:
_wait(10000, _assertTrue(_isVisible(_link("detailsForm:saveAgreementBtn"))));
_assertTrue(_isVisible(_link("detailsForm:saveAgreementBtn")));

and this gives the same functionality, but with less code, but also may look potentially confusing:
_wait(10000, _isVisible(_link("detailsForm:saveAgreementBtn")));
_assertTrue(_isVisible(_link("detailsForm:saveAgreementBtn")));

20140321

[SOLVED] sahi, primefaces: p:dataTable no rendered table tag id

i'm updating our sahi test scripts for our new primefaces frontend and ran into a difficulty when trying to select a specific table row cell.

this page gives a hint as to how to select specific table cells:
http://sahi.co.in/docs/faq/get-cell-data.html

using this format:
_cell(_table("<table_identifier>"), x-1, y-1)


but the problem is that when a primefaces p:dataTable gets rendered to HTML, the table is enclosed in a div tag, and that div tag gets the id value set in the p:dataTable code, and the actual table tag doesn't have an id.

i solved my problem like this:
_cell(_table(1, _in(_div("selectMember:selectMemberTable"))), 1, 1)

here i specify the *second* table (there's a table in the header too), which is the actual dataTable table (0-based indexing, so value "1").

however, from what i can see, the sahi documentation is confusing concerning "x" and "y", if you interpret "x" to mean column (left<->right position), like i do.

"...1, 1)", in reality, means "row 2 (x), column 2 (y)" (0-based indexing, so "1, 1")

------------

as a side note, i found this sahi script code useful/interesting too:
_table(0, _in(_div("selectMember:selectMemberTable"))).rows[0].style='background-color:red'

which changes the background color of the first row of the first table to red.

sahi, primefaces: "ReferenceError: PrimeFaces is not defined". solution: just rerun the sahi script

sometimes when i run a sahi script to test our primefaces ui, the script times out with the following error:

ReferenceError: PrimeFaces is not defined (http://localhost/pages/listTransportAgreements.jsf:278)

when i rerun the script, it usually goes away, so i'm not quite sure why it works sometimes and other times it doesn't.

20140320

primefaces p:commandLink oncomplete attribute referencing non-existent ID was messing up table filter and sort functions


i had this primefaces delete-icon code in a table row:
<p:commandLink id="deletelink" title="#{msg['label.delete']}"
    action="#{ta_mappingObject.setCurrentItemAndPanelToShow(agreement, 'deleteTA')}"
    rendered="#{!ta_mappingObject.createFromRequestDetails and userMenuBean.canEditAgreement()}"
    oncomplete="PF('confDeleteAgreement').show();">
    <h:graphicImage value="/images/icons/delete.gif" style="border:0" />
</p:commandLink>


and stuff on the page like filtering and sorting wasn't working, so i figured out that because that link was referencing a dialog ID that didn't exist, it was messing up the whole page, so i changed it to this:
<p:commandLink id="deletelink" title="#{msg['label.delete']}"
    action="#{ta_mappingObject.setCurrentItemAndPanelToShow(agreement, 'deleteTA')}"
    rendered="#{!ta_mappingObject.createFromRequestDetails and userMenuBean.canEditAgreement()}"
    oncomplete="PF('andIdThatExists').show();">
    <h:graphicImage value="/images/icons/delete.gif" style="border:0" />
</p:commandLink>



and everything started working again.

20140319

primefaces - show p:modalPanel from java backing bean / controller class and update specific id or collection of id strings

here's how you show a p:modalPanel from a java backing bean call:
org.primefaces.context.RequestContext.getCurrentInstance().execute("myModalPanelWV.show()");

"modalPanelWV" is the widgetVar value, e.g.:
<p:modalPanel id="myModalPanel" widgetVar="myModalPanelWV" ...

update an id from backing bean:
org.primefaces.context.RequestContext.getCurrentInstance().update("growl");

OR update a Collection<String> of IDs:
org.primefaces.context.RequestContext.getCurrentInstance().update(myCollectionOfStringIds);



20140317

[SOLVED] jboss 7 jdk 6 startup in debug opens FileNotFoundException.class: Suspended (exception FileNotFoundException) jdk/jre/lib/zi/UTC

i started to encounter something weird when i was starting up my local jboss 7 instance in debug mode (using jdk 6):
FileNotFoundException.class would open in the eclipse debugger

with this error message in the console:
Suspended (exception FileNotFoundException) ~/workspaceEclipse/tcTrunk/jdk/jre/lib/zi/UTC


i figured out that "zi" means "ZoneInfoFile"

i can see that there's a UTC file in zi/Etc/:
~/workspaceEclipse/tcTrunk/jdk/jre/lib/zi/Etc/UTC

SOLUTION

all i had to do to fix this was copy the file to the expected folder:

cp ~/workspaceEclipse/tcTrunk/jdk/jre/lib/zi/Etc/UTC ~/workspaceEclipse/tcTrunk/jdk/jre/lib/zi/




20140311

[SOLVED] sahi include script does not exist

today's problem started out like this:

### verify_any_transport_requests.sah ###

_include("functions/common_functions.sah");
_include("functions/common_vars.sah");
_include("functions/transport_request_functions.sah");

tc_login($buyer_user_unil, $buyer_pass_unil);

listAllTRQsUnfiltered();

tc_logout();


###########################

every time i'd try running this script i'd get the following error in the sahi log:
ERROR
Script: /home/nick/workspaceEclipse/tcTrunk/testing/functional_testing/stage_1/sahi/functions/transport_request_functions.sah does not exist.



since i knew that the include file indeed did exist, i figured it had to be something wrong with the code. then i saw this code in transport_request_functions.sah:

_link("filtermenubarForm:filterBtn");

it should have been:
_click(_link("filtermenubarForm:filterBtn"));

it seems like that was the problem.

20140304

web.xml jsf setting to treat empty string values in form submit as null so they're not saved in the database, but also comply with notnull constraints

the following setting in web.xml is quite useful:

...
<context-param>
    <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
    <param-value>true</param-value>
</context-param>

...

which means that when a user submits a form then no empty fields of type string will get saved in the database. having it set to true will also force compliance with @NotNull constraints, with regards to validation.

on a related note, there's a jboss startup setting called org.apache.el.parser.COERCE_TO_ZERO, which when set to true (default) will turn number field form values of "" (empty string) and null into the number 0 (zero) before the form is submitted, e.g.:

-Dorg.apache.el.parser.COERCE_TO_ZERO=true

setting it to false would mean that empty strings and null values for number fields in forms will be submitted "as is" and NOT get converted to the number 0.

20140303

when and why facelets.DEVELOPMENT was replaced by javax.faces.PROJECT_STAGE

was trying today to figure out when and why facelets.DEVELOPMENT was replaced by javax.faces.PROJECT_STAGE and i think i finally found the answer in the following article by IBM:

Changes to XHTML and Java sources of a JSF 2.0 web project not refreshed on publish to the WAS V8 server

facelets.DEVELOPMENT was used in JSF 1.2 (Facelets 1.x)
web.xml:
...
<context-param>
    <param-name>facelets.DEVELOPMENT</param-name>
    <param-value>true</param-value>
</context-param>
...


javax.faces.PROJECT_STAGE has been used since JSF 2 (Facelets 2.0 VDL, Facelets 2.0 API [specifically javax.faces.application.ProjectStage])(see "*** NOTE" below).

web.xml:
...
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>
...




*** NOTE
"
In JavaServer Faces (JSF) 2.0, Facelets is the default view declaration language (VDL) instead of JavaServer Pages (JSP). With Facelets, you don’t need to configure a view handler as you used to do in JSF 1.2. Facelets is a JSF-centric view technology.
"