The best place to ask programming/development questions, imo. UPDATE: stackoverflow is 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 a great reference for finding answers.

My Music (Nickleus)

20130301

[SOLVED] jsf/richfaces can't set id dynamically for use in sahi test: java.lang.IllegalArgumentException

i'm currently writing sahi scripts to test our web app. i ran into a problem with our dynamic trip table where there was no identifier for the delete image:




the delete button code looks like this:
<a4j:commandLink id="removeTRQlink" title="#{msg['label.trip.confirmRemoveTRQ']}" action="#{listRequestsDM.tripBean.setCurrentTripAndTRQ(listObj, trq)}" oncomplete="#{rich:component('removeTRQPanelTrip')}.show()" reRender="removeTRQPanelTrip">
  <h:graphicImage value="/images/icons/delete.gif" style="border:0" />
</a4j:commandLink>


when i tried setting the a4j:commandLink id dynamically (using the transport request receiver ref id, like this:
<a4j:commandLink id="#{trq.receiverRefId}" title="#{msg['label.trip.confirmRemoveTRQ']}" action="#{listRequestsDM.tripBean.setCurrentTripAndTRQ(listObj, trq)}" oncomplete="#{rich:component('removeTRQPanelTrip')}.show()" reRender="removeTRQPanelTrip">
  <h:graphicImage value="/images/icons/delete.gif" style="border:0" />
</a4j:commandLink>


i would get the following error:
java.lang.IllegalArgumentException

eventually, after reading the sahi documentation, i noticed that images can also be identified by title. and jsf/richfaces also allows setting the title value dynamically :)
<h:graphicImage value="/images/icons/delete.gif" title="#{trq.receiverRefId}" style="border:0" />

and here's the sahi script code:
_click(_image($tr_id));

then we don't need any proximity qualifiers and we can precisely match any transport request in the subtable! :)

NOTE: trq.receiverRefId == $tr_id

pages that helped me:
http://sahi.co.in/forums/discussion/3870/identifying-image-buttons-uniquely/p1
http://sahi.co.in/w/all-apis

No comments:

Post a Comment