Hi Rajiv,

>>   Take a look into the generated html source if unclear about the
>>   generated id of the link.

Have you done this?


I don't have any experience with 'forceId' and i would disadvise to use
it unless ther are no other ways to accomplish what you want.

but your use of forceId is wrong, forceId should have a boolean value
the description on http://myfaces.apache.org/tomahawk/forceId.html is
wrong, just the example is correct.

   <t:commandLink forceId="searchLink" ...>
must be
   <t:commandLink forceId="true" id="searchLink" ...>

Without forceId your statement should work
  document.forms['myJSFForm'].elements['myJSFForm:searchLink'].click();
but i would prefer
  document.getElementById('MyJSFForm:submitLink').click()



Regards,
  Volker


JSFSter Smith wrote:
> Hi,
> 
> Thanks for your responses! Adding  the preserveDataModel=true did solve the
> commandLink problem inside the dataTable and I did not have to go the
> session bean route. I
> 
> I am still having problems with the javascript  to trap the enter key to
> submit the form using when a h:commandLink is clicked. I tried setting the
> forceID attribute (in an earlier version) as well as using the id explicitly
> in the java script.
> 
> My javascript :
>         function trapEnter(evt) {
>             var keycode;
>            if (evt)
>              ;
>           else if (window.event)
>             evt = window.event;
>           else if (event)
>             evt = event;
>          else
>            return true;
> 
>          if (evt.charCode)
>           keycode = evt.charCode;
>         else if (evt.keyCode)
>           keycode = evt.keyCode;
>         else if (evt.which)
>           keycode = evt.which;
>        else
>         keycode = 0;
> 
>       if (keycode == 13) {
>         document.forms
> ['myJSFForm'].elements['myJSFForm:searchLink'].click();
>         return false;
>     }
>     else
>         return true;
>  }
> 
> and my form is as follows:
>     <body onkeypress="trapEnter(event);">
>         <f:view>
>                 <f:loadBundle basename="ifmessages" var="msgs"/>
>         <h:form id="myJSFForm">
>           <h:panelGrid>
>             <h:panelGroup styleClass="bookSearchPanel">
>                         <h:inputText id="searchText" value="#{
> searchMain.searchTerm}" />
> 
>                     <t:commandLink forceId="searchLink" action="#{
> searchMain.searchUsers}">
>                         <h:graphicImage value="/images/submit.gif"/>
>                     </t:commandLink>
>                         </h:panelGroup>
>                    -----
> 
> 
>          </h:form>
> 
> The keypress event is trapped and I tested it using alerts. Is there
> anything I am missing here?
> 
> thanks,
> 
> Rajiv
> 
> 
> On 11/04/06, Volker Weber <[EMAIL PROTECTED]> wrote:
> 
>>Hi Rajiv,
>>
>>1: The model must the same on render and restore phase, afaik you can
>>   force this by using preserveDataModel="true" on t:datatable.
>>   Or you can use the t:saveState tag see:
>>       http://myfaces.apache.org/tomahawk/uiSaveState.html
>>
>>
>>3: the html ids are created by prefixing component ids with the ids of
>>   namingcontainer components
>>
>>   you should use sommething like
>>
>>   document.forms['MyJSFForm'].elements['MyJSFForm:submitLink'].click()
>>
>>   or
>>
>>   document.getElementById('MyJSFForm:submitLink').click()
>>
>>   Take a look into the generated html source if unclear about the
>>   generated id of the link.
>>
>>
>>Regards,
>>  Volker
>>
>>
>>JSFSter Smith wrote:
>>
>>>Hi,
>>>
>>>I have just started using MyFaces for a new project and had a couple of
>>>questions while I am on the learning curve. Any help/response is greatly
>>>appreciated.  Its been a pleasure to actually create  JSP pages with no
>>
>>java
>>
>>>code using JSF in them and I hope to keep them that way!
>>>
>>>
>>>1. <h:commandLink> tag does not work inside a <t:dataTable> tag
>>>     and ends up refreshing the same page from where the link was
>>
>>clicked
>>
>>>without any updates to the model. The get/set  methods for the
>>
>>corresponding
>>
>>>backing bean member are never called by the framework
>>>
>>>    I looked through the mail archives for myFaces as well as JSF RI.
>>
>>This
>>
>>>seems to be an issue faced by many users and the suggested work around
>>
>>is to
>>
>>>make the backing bean that contains the table data a session bean
>>
>>(currently
>>
>>>mine is a request). Is this a bug with the spec or am I missing
>>
>>something ?
>>
>>>2. <h:commandButton> with a request scope backing bean cannot be used to
>>>pass request parameters to the next page using <f:param> tags.
>>>    The <h:commandLink> tag has to be used instead. Again is this a bug
>>
>>or I
>>
>>>am missing something?
>>>
>>>Currently, I am using h:commandLinks for  my request param passing and
>>
>>it
>>
>>>works fine. But this leads me to my final question:
>>>
>>>3. I am trying to map the enter key to my command link (which is an
>>
>>image)
>>
>>>using javascript and have included a snippet below.
>>>
>>>   if (keycode == 13) {
>>>
>>>       document.forms['MyJSFForm'].elements['submitLink'].click()
>>>        return false;
>>>    }
>>>
>>>    I have explicitly given id's to my form and commandLink. The java
>>
>>script
>>
>>>object for the link is invalid
>>>
>>>Thanks in advance for your response!
>>>
>>>- Rajiv
>>>
>>
>>--
>>Don't answer to From: address!
>>Mail to this account are droped if not recieved via mailinglist.
>>To contact me direct create the mail address by
>>concatenating my forename to my senders domain.
>>
> 
> 

-- 
Don't answer to From: address!
Mail to this account are droped if not recieved via mailinglist.
To contact me direct create the mail address by
concatenating my forename to my senders domain.

Reply via email to