You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Val Blant <va...@yahoo.ca> on 2008/01/29 03:09:09 UTC

s:inputSuggestAjax dojo controls not working

Hello.

I've been trying to get s:inputSuggestAjax working for the last few hours,
but so far no luck. Maybe someone would be able to help me. 

I am trying to use it in the most basic way:
<s:inputSuggestAjax id="commodityIncomeDescription" 
suggestedItemsMethod="#{formsBackingBean.buildIncomeExpenseCodeSuggestionList}"
value="#{formsBackingBean.editCommodityIncomeItem.description}" />

This results in a call to buildIncomeExpenseCodeSuggestionList() as it
should. The response is properly sent back to the browser, which I have
verified with Firebug and a packet sniff. I can even observe the list of
completion options in the packets getting smaller and smaller as I type. It
looks like everything is working just fine. Except that absolutely nothing
happens in the browser. There is no drop down box appearing on my input
field and the field is acting like a perfectly ordinary text field (except
for the little image of a down arrow right beside it. The arrow does nothing
when clicked.)

Looking at the page source, it looks like the dojo code was generated, but
it doesn't seem to be doing anything (other than sending the requests, which
it is clearly doing). There are no javascript errors on the page according
to Firefox's console.

Here is the dojo code from the page source:

<script type="text/javascript"
src="/DPSV2/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/12015691/dojo.DojoResourceLoader/dojo.js">
<!--
//-->
</script>

<script type="text/javascript">
<!--
dojo.setModulePrefix('extensions', '../dojoextensions.ResourceLoader');
//-->
</script>

<script type="text/javascript">
<!--
dojo.require('extensions.FacesIO');
//-->
</script>
<script type="text/javascript">
<!--
dojo.require('extensions.widget.InputSuggestAjax');
//-->
</script>
<script type="text/javascript">
<!--
dojo.require('dojo.event.*');
//-->
</script>

  <input style="display: none;" tabindex="-1" name="undefined" value=""
dojoattachpoint="comboBoxValue">
  <input style="display: none;" tabindex="-1" name="undefined_selected"
value="" dojoattachpoint="comboBoxSelectionValue">
  <input style="" class="dojoComboBox"
id="operatingYearForm:commodityIncomeDescription"
name="operatingYearForm:commodityIncomeDescription" value="Scorzonera"
type="text">
  
/DPSV2/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/12015691/dojo.DojoResourceLoader/src/widget/templates/images/combo_box_arrow.png 
<div dojoattachpoint="containerNode" style="display: none; position:
absolute;" class="dojoPopupContainer dojoComboBoxOptions">
</div>

<script type="text/javascript">
<!--
var _id339_dojoControl =
dojo.widget.createWidget("extensions:InputSuggestAjax",{mode:'remote',textInputId:'operatingYearForm:commodityIncomeDescription',autoComplete:true,dataUrl:'/DPSV2/forms/operationDetails.jsf?affectedAjaxComponent=operatingYearForm:commodityIncomeDescription&charset=&operatingYearForm:commodityIncomeDescription=%{searchString}'},dojo.byId('_id339'));
//-->
</script>
<script type="text/javascript">
<!--
dojo.addOnLoad(function() {
_id339_dojoControl.comboBoxValue.value = "Scorzonera";
_id339_dojoControl.onResize();
});
//-->
</script>


What could I possibly be doing wrong?

I am using tomahawk, sandbox and core at version 1.1.5 and Facelets.

Any help would be greatly appreciated.
-- 
View this message in context: http://www.nabble.com/s%3AinputSuggestAjax-dojo-controls-not-working-tp15150699p15150699.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: s:inputSuggestAjax dojo controls not working

Posted by Gerald Müllan <ge...@gmail.com>.
Hi,

> ok, problem solved. Although I am still confused about how it works for other
> people.

This really seems to be a bug in MyFaces and is currently discussed on
the dev list.
But i am not sure of how it was itroduced, the examples still work.

> I solved this problem by overriding the StartupServletContextListener and
> removing the duplicate phase listeners from the lifecycle.
> <s:inputSuggestAjax> works fine now.

There should be a patch applied today evening; Try a nightly build
from the next few days.

Please report if it fixes the problem!?

cheers,

Gerald

-- 
http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Re: s:inputSuggestAjax dojo controls not working

Posted by Val Blant <va...@yahoo.ca>.
ok, problem solved. Although I am still confused about how it works for other
people. Here is what happened.

I tried to get my test page to look as close to
http://example.irian.at/example-sandbox-20080129/inputSuggestAjax.jsf as
possible, and it still didn't work even though the generated javascript code
was practically identical. After reading dojo.js for a few hours I found
that the responses are handled in the doLoad(e) function, where I placed a
breakpoint. 

This breakpoint finally showed me what the difference between the example
and my page was: my response was returned as two concatenated lists of
strings, rather than a list of strings! This caused
dj_eval("("+http.responseText+")") call in dojo.js to fail.

Why was I getting two identical lists from the component instead of one?
Well, turns out that AjaxDecodePhaseListener.beforePhase() was executed
twice in the APPLY_REQUEST_VALUES phase. For that matter all of my phase
listeners executed twice...

This brings me to my current question - why would this component work for
anyone else? The problem seems to lie in a JSF bug, so everyone should be
effected. Here is why:

The fault (in my opinion) lies in method feedClassloaderConfigurations() in
org.apache.myfaces.config.FacesConfigurator. This method is supposed to look
for "META-INF/faces-config.xml" resource in all classloaders and then parse
the found files. Now, if we have some jars, like let's say
tomahawk-sandbox.jar in WEB-INF/lib, this jar will be visible to the
WebAppClassloader AS WELL AS AppClassLoader. i.e. tomahawk-sandbox.jar will
appear twice in the list of found resources, b/c it is visible to both
classloaders. Since feedClassloaderConfigurations() does not check for
duplicates, we end up with all configuration in "META-INF/faces-config.xml"
resources applied twice.

I solved this problem by overriding the StartupServletContextListener and
removing the duplicate phase listeners from the lifecycle.
<s:inputSuggestAjax> works fine now.

Does this make sense or am I missing something?


Val
-- 
View this message in context: http://www.nabble.com/s%3AinputSuggestAjax-dojo-controls-not-working-tp15150699p15168506.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: s:inputSuggestAjax dojo controls not working

Posted by Gerald Müllan <gm...@apache.org>.
Did you have a look at our examples page:

http://example.irian.at/example-sandbox-20080129/inputSuggestAjax.jsf

Any differences in rendered html or the ajax-response?

Are you using client side state saving? (which should work anyway)

Try to build a very simple page in your app, without any proprietary code.

cheers,

Gerald


-- 
http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Re: s:inputSuggestAjax dojo controls not working

Posted by Val <va...@yahoo.ca>.
> But i am wondering, because you have observed that the list is
> returned correctly.
yeah, the method is definitely getting called the way it is. I can put
breakpoints in there and they always get hit when I type something into
my text box.

> Are there any js related errors?
Not according to the Firefox console or Firebug.

> Please also try to use the latest nightly build from sandbox, which
That is actually the build I started with. I downgraded in hopes of
changing something, but nothing did.


Does the dojo code in the page source look reasonable? Does it look
comparable for those people who have the component working?


Thanks.

On Tue, 2008-29-01 at 11:27 +0100, Gerald Müllan wrote:
> Hi,
> 
> normally you have to specify the suggestedItemsMethod  with the "get"
> as a prefix because the component does a methodBinding.
> 
> So, in your case it would be
> 
> suggestedItemsMethod="#{formsBackingBean.getBuildIncomeExpenseCodeSuggestionList}"
> 
> But i am wondering, because you have observed that the list is
> returned correctly.
> 
> Are there any js related errors?
> 
> Please also try to use the latest nightly build from sandbox, which
> can be found at
> 
> http://people.apache.org/builds/myfaces/nightly/
> 
> Does this change anything?
> 
> cheers,
> 
> Gerald
> 


Re: s:inputSuggestAjax dojo controls not working

Posted by Gerald Müllan <gm...@apache.org>.
Hi,

normally you have to specify the suggestedItemsMethod  with the "get"
as a prefix because the component does a methodBinding.

So, in your case it would be

suggestedItemsMethod="#{formsBackingBean.getBuildIncomeExpenseCodeSuggestionList}"

But i am wondering, because you have observed that the list is
returned correctly.

Are there any js related errors?

Please also try to use the latest nightly build from sandbox, which
can be found at

http://people.apache.org/builds/myfaces/nightly/

Does this change anything?

cheers,

Gerald

-- 
http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces