You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Andy Pahne <ap...@net22.de> on 2008/02/21 13:28:16 UTC
[4.1.5] Suggest component
Hi,
I try to imlement a suggest feature with the Suggest component.
Unfortunatly the suggestions do not render properly. I had a look at the
TimeTracker demo and copied all relevant parts into my test application,
but the generated result looks different and the suggestions are not
visible.
My code and templates are copied from the TimeTracker demo (incl. CSS,
Border component and everything else). But if I inspect the DOM after
the suggestions should have been rendered, the result looks different.
It's no surprise that no suggestions are rendered at all because of
style="display: none;"
in the output of my test...
from the TimeTracker demo:
...
<input autocomplete="off" id="suggest" name="suggest" size="34"
value="" type="text">
<div style="position: absolute; left: 147px; top: 220px; width: 230px;
opacity: 0.999999;" id="suggestchoices" class="autocomplete"><ul><li
class="selected"><img
src="http://setiathome.free.fr/images/flags/ye.gif">Yemen</li></ul>
...
</div>
</td>
...
from my appilication:
...
<input autocomplete="off" id="suggest" name="suggest" size="60" value=""
type="text"><div style="display: none;" id="suggestchoices"
class="autocomplete"><script>
//<![CDATA[
dojo.require("tapestry.event");
//]]>
</script><script>
//<![CDATA[
tapestry.cleanConnect("eventListenerDemo", "onmouseover",
"event1975610136");
tapestry.event1975610136=function(e){
var content={beventname:"onmouseover"};
tapestry.event.buildEventProperties(e, content,
arguments);
if (!content["beventtarget.id"])
content["beventtarget.id"]="eventListenerDemo";
tapestry.bind("/oos/directevent.svc?page=test%2FAjaxTest&session=T",
content);
};
tapestry.connect("eventListenerDemo", "onmouseover",
"event1975610136");
//]]>
</script><ul><li><img
src="http://setiathome.free.fr/images/flags/si.gif">Slovenia</li>
...
</ul></div></td>
</tr>
...
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1.5] Suggest component
Posted by Ulrich Stärk <ul...@spielviel.de>.
The display:none style is removed as soon as you enter something into
the input field or change something there. It becomes hidden again when
the input field loses focus for example because you activated the DOM
inspector which explains why you always see display:none when you
inspect it.
As for your different behaviour in different browsers: I've got IE6 and
FF2 here and with both it works.
Uli
Andy Pahne schrieb:
> Ulrich Stärk schrieb:
>> Correct - everything. And it works here... I don't get it.
>>
>> It might be possible that your browser can't find ../css/demo.css
>> depending on your path layout but that would make it just look
>> different. The suggest list should still be rendered if you enter
>> something into the input field. I can't see why it works for me but
>> not for you.
>> Do you have any entries in your info log? Mine is full of entries like
>> listSource was called
>> List contains 3 items, filter is 'de'
>>
>
>
> The CSS is found, because the page looks just like the TimeTracker demo.
>
> For each request there are those entries in the log:
>
> 2008-02-21 16:05:35,937 INFO [http-8080-Processor25]
> (AjaxTest.java:170) - Suggest Listener was called. Filter is 'e'
> 2008-02-21 16:05:35,953 INFO [http-8080-Processor25]
> (AjaxTest.java:133) - listSource was called
> 2008-02-21 16:05:35,968 INFO [http-8080-Processor25]
> (AjaxTest.java:158) - List contains 36 items, filter is 'e'
> 2008-02-21 16:05:35,984 INFO [http-8080-Processor25]
> (AjaxTest.java:133) - listSource was called
> 2008-02-21 16:05:36,000 INFO [http-8080-Processor25]
> (AjaxTest.java:158) - List contains 36 items, filter is 'e'
> 2008-02-21 16:05:36,000 INFO [http-8080-Processor25]
> (AjaxTest.java:133) - listSource was called
> 2008-02-21 16:05:36,015 INFO [http-8080-Processor25]
> (AjaxTest.java:158) - List contains 36 items, filter is 'e'
>
> I don't have any idea why the "List contains 36 items, filter is 'e'"
> entry appears three times.
>
> As I wrote in my fist post, after the asynchronous page update the div
> with the suggestions looks like that:
>
> <div style="display: none;" id="suggestchoices"
> class="autocomplete">...</div>
>
> So, the div is there, it contains all the expected entries, but it is
> hidden (display: none;). My first thought was that the AJAX request does
> not work but a quick DOM inspection and a look into the logfile revealed
> that the AJAX part works perfectly.
>
> I have no idea...
>
> Andy
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1.5] Suggest component
Posted by Andy Pahne <ap...@net22.de>.
Damn, just found out that it works in IE 7, but not in FF 2. But that's
not the case with with the demo which is available at
http://opencomponentry.com:8080/timetracker/LocaleSuggest.html
That demo wors nicely in both browsers...
Andy
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1.5] Suggest component
Posted by Andy Pahne <ap...@net22.de>.
Ulrich Stärk schrieb:
> Correct - everything. And it works here... I don't get it.
>
> It might be possible that your browser can't find ../css/demo.css
> depending on your path layout but that would make it just look
> different. The suggest list should still be rendered if you enter
> something into the input field. I can't see why it works for me but not
> for you.
> Do you have any entries in your info log? Mine is full of entries like
> listSource was called
> List contains 3 items, filter is 'de'
>
The CSS is found, because the page looks just like the TimeTracker demo.
For each request there are those entries in the log:
2008-02-21 16:05:35,937 INFO [http-8080-Processor25]
(AjaxTest.java:170) - Suggest Listener was called. Filter is 'e'
2008-02-21 16:05:35,953 INFO [http-8080-Processor25]
(AjaxTest.java:133) - listSource was called
2008-02-21 16:05:35,968 INFO [http-8080-Processor25]
(AjaxTest.java:158) - List contains 36 items, filter is 'e'
2008-02-21 16:05:35,984 INFO [http-8080-Processor25]
(AjaxTest.java:133) - listSource was called
2008-02-21 16:05:36,000 INFO [http-8080-Processor25]
(AjaxTest.java:158) - List contains 36 items, filter is 'e'
2008-02-21 16:05:36,000 INFO [http-8080-Processor25]
(AjaxTest.java:133) - listSource was called
2008-02-21 16:05:36,015 INFO [http-8080-Processor25]
(AjaxTest.java:158) - List contains 36 items, filter is 'e'
I don't have any idea why the "List contains 36 items, filter is 'e'"
entry appears three times.
As I wrote in my fist post, after the asynchronous page update the div
with the suggestions looks like that:
<div style="display: none;" id="suggestchoices"
class="autocomplete">...</div>
So, the div is there, it contains all the expected entries, but it is
hidden (display: none;). My first thought was that the AJAX request does
not work but a quick DOM inspection and a look into the logfile revealed
that the AJAX part works perfectly.
I have no idea...
Andy
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1.5] Suggest component
Posted by Ulrich Stärk <ul...@spielviel.de>.
Correct - everything. And it works here... I don't get it.
It might be possible that your browser can't find ../css/demo.css
depending on your path layout but that would make it just look
different. The suggest list should still be rendered if you enter
something into the input field. I can't see why it works for me but not
for you.
Do you have any entries in your info log? Mine is full of entries like
listSource was called
List contains 3 items, filter is 'de'
Uli
Andy Pahne schrieb:
> Ulrich Stärk schrieb:
> > Almost no is not none :)
> >
> > Your code is absolutely correct and works perfectly. Please make sure
> > that you have a Shell and a Body component on your page. In your case
> > those would be included with your DemoBorder component, so have a look
> > at that template. Also make sure that you don't include some css or
> > javascript somewhere that might interfere with the suggest component. If
> > you do include something try leaving it out.
> >
> > Uli
>
>
>
>
> my Border:
>
> <html jwcid="@Shell"
> title="literal:Hello"
> browserLogLevel="DEBUG"
> consoleEnabled="true"
> debugEnabled="false" >
>
> <link jwcid="@Relation" href="../css/demo.css" media="all" />
> <body jwcid="@Body">
>
> <div id="header" >
> <span class="headertxt">AJAX-Demos</span>
> </div>
>
>
> <div id="content">
> <span jwcid="@RenderBody" />
> </div>
> </body>
>
> </html>
>
>
>
> It's copied from the TimeTracker demo. Only the header section is
> modified. I even use the same CSS, as demo.css is just a copy of
> timetracker.css.
>
> A.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1.5] Suggest component
Posted by Andy Pahne <ap...@net22.de>.
Ulrich Stärk schrieb:
> Almost no is not none :)
>
> Your code is absolutely correct and works perfectly. Please make sure
> that you have a Shell and a Body component on your page. In your case
> those would be included with your DemoBorder component, so have a look
> at that template. Also make sure that you don't include some css or
> javascript somewhere that might interfere with the suggest component. If
> you do include something try leaving it out.
>
> Uli
my Border:
<html jwcid="@Shell"
title="literal:Hello"
browserLogLevel="DEBUG"
consoleEnabled="true"
debugEnabled="false" >
<link jwcid="@Relation" href="../css/demo.css" media="all" />
<body jwcid="@Body">
<div id="header" >
<span class="headertxt">AJAX-Demos</span>
</div>
<div id="content">
<span jwcid="@RenderBody" />
</div>
</body>
</html>
It's copied from the TimeTracker demo. Only the header section is
modified. I even use the same CSS, as demo.css is just a copy of
timetracker.css.
A.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1.5] Suggest component
Posted by Ulrich Stärk <ul...@spielviel.de>.
Almost no is not none :)
Your code is absolutely correct and works perfectly. Please make sure
that you have a Shell and a Body component on your page. In your case
those would be included with your DemoBorder component, so have a look
at that template. Also make sure that you don't include some css or
javascript somewhere that might interfere with the suggest component. If
you do include something try leaving it out.
Uli
Andy Pahne schrieb:
>
>
> Ulrich Stärk schrieb:
> > This is the rendered code, could you please provide the corresponding
> > template and page class code?
> >
>
>
>
>
> There's almost no difference beetwenn the source of the TimeTracker demo
> and mine:
>
>
>
> <span jwcid="@DemoBorder">
>
> <style type="text/css">
> div.autocomplete {
> position:absolute;
> width:250px;
> background-color:white;
> border:1px solid #888;
> margin:0px;
> padding:0px;
> }
> div.autocomplete ul {
> list-style-type:none;
> margin:0px;
> padding:0px;
> }
> div.autocomplete ul li.selected { background-color: #ffb;}
> div.autocomplete ul li {
> list-style-type:none;
> display:block;
> margin:0;
> padding:4px 0 4px 4px;
> cursor:pointer;
> }
> div.autocomplete ul li img { border:none; margin-right: 10px;
> vertical-align:middle;}
> </style>
>
>
> <h2>Suggest Demo (Script.aculo.us)</h2>
> <form jwcid="@Form" class="container">
> <table width="90%" class="form" cellpadding="2" cellspacing="0" >
> <tbody>
> <tr>
> <td><label jwcid="@FieldLabel" field="component:suggest"
> /></td>
> <td><input jwcid="suggest" size="60" /></td>
> </tr>
> </tbody>
> </table>
>
> </form>
>
>
>
>
>
>
>
>
>
>
>
> @Component(bindings = {"value=inputLocale",
> "displayName=literal:Locale",
> "listSource=localeList",
> "listener=listener:suggestLocale",
> "listItemRenderer=itemRenderer"})
> public abstract Suggest getSuggest();
>
> /**
> * listSource
> */
> public List<Locale> getLocaleList() {
>
> LOG.info("listSource was called");
>
> String filter = getFilterString();
> Locale[] locales = Locale.getAvailableLocales();
>
> if (filter == null || filter.length() < 1) {
> return Arrays.asList(locales);
> }
>
> filter = filter.toUpperCase();
>
> List<Locale> ret = new ArrayList<Locale>();
> // used to ensure no duplicates are stored in the list as
> // java.util.Locale doesn't
> // provde an equals() method.
> List<String> temp = new ArrayList<String>();
>
> for (Locale locale : locales) {
> if (locale.getDisplayCountry().toUpperCase().indexOf(filter)
> > -1
> && !temp.contains(locale.getDisplayCountry())) {
> ret.add(locale);
> temp.add(locale.getDisplayCountry());
> }
> }
>
> LOG.info("List contains " + ret.size() + " items, filter is '"
> + getFilterString() + "'");
> return ret;
> }
>
> /**
> * listener
> * <p>
> * Invoked dynamically via XHR whenever input changes in the form
> input field. The method above - getLocaleList() -
> * is what actually filters the list of suggested options displayed
> based on the characters they typed in to the input field.
> */
> public void suggestLocale(String filter) {
> LOG.info("Suggest Listener was called. Filter is '"+filter+"'");
> setFilterString(filter);
> }
>
> /** value */
> public abstract String getInputLocale();
>
> public abstract String getFilterString();
> public abstract void setFilterString(String filter);
>
> static ListItemRenderer ITEM_RENDERER = new LocaleListItemRenderer();
> public ListItemRenderer getItemRenderer()
> {
> return ITEM_RENDERER;
> }
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1.5] Suggest component
Posted by Andy Pahne <ap...@net22.de>.
Ulrich Stärk schrieb:
> This is the rendered code, could you please provide the corresponding
> template and page class code?
>
There's almost no difference beetwenn the source of the TimeTracker demo
and mine:
<span jwcid="@DemoBorder">
<style type="text/css">
div.autocomplete {
position:absolute;
width:250px;
background-color:white;
border:1px solid #888;
margin:0px;
padding:0px;
}
div.autocomplete ul {
list-style-type:none;
margin:0px;
padding:0px;
}
div.autocomplete ul li.selected { background-color: #ffb;}
div.autocomplete ul li {
list-style-type:none;
display:block;
margin:0;
padding:4px 0 4px 4px;
cursor:pointer;
}
div.autocomplete ul li img { border:none; margin-right: 10px;
vertical-align:middle;}
</style>
<h2>Suggest Demo (Script.aculo.us)</h2>
<form jwcid="@Form" class="container">
<table width="90%" class="form" cellpadding="2" cellspacing="0" >
<tbody>
<tr>
<td><label jwcid="@FieldLabel"
field="component:suggest" /></td>
<td><input jwcid="suggest" size="60" /></td>
</tr>
</tbody>
</table>
</form>
@Component(bindings = {"value=inputLocale",
"displayName=literal:Locale",
"listSource=localeList",
"listener=listener:suggestLocale",
"listItemRenderer=itemRenderer"})
public abstract Suggest getSuggest();
/**
* listSource
*/
public List<Locale> getLocaleList() {
LOG.info("listSource was called");
String filter = getFilterString();
Locale[] locales = Locale.getAvailableLocales();
if (filter == null || filter.length() < 1) {
return Arrays.asList(locales);
}
filter = filter.toUpperCase();
List<Locale> ret = new ArrayList<Locale>();
// used to ensure no duplicates are stored in the list as
// java.util.Locale doesn't
// provde an equals() method.
List<String> temp = new ArrayList<String>();
for (Locale locale : locales) {
if
(locale.getDisplayCountry().toUpperCase().indexOf(filter) > -1
&& !temp.contains(locale.getDisplayCountry())) {
ret.add(locale);
temp.add(locale.getDisplayCountry());
}
}
LOG.info("List contains " + ret.size() + " items, filter is '"
+ getFilterString() + "'");
return ret;
}
/**
* listener
* <p>
* Invoked dynamically via XHR whenever input changes in the form
input field. The method above - getLocaleList() -
* is what actually filters the list of suggested options displayed
based on the characters they typed in to the input field.
*/
public void suggestLocale(String filter) {
LOG.info("Suggest Listener was called. Filter is '"+filter+"'");
setFilterString(filter);
}
/** value */
public abstract String getInputLocale();
public abstract String getFilterString();
public abstract void setFilterString(String filter);
static ListItemRenderer ITEM_RENDERER = new LocaleListItemRenderer();
public ListItemRenderer getItemRenderer()
{
return ITEM_RENDERER;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1.5] Suggest component
Posted by Ulrich Stärk <ul...@spielviel.de>.
This is the rendered code, could you please provide the corresponding
template and page class code?
Uli
Am Do, 21.02.2008, 13:28, schrieb Andy Pahne:
> Hi,
>
> I try to imlement a suggest feature with the Suggest component.
> Unfortunatly the suggestions do not render properly. I had a look at the
> TimeTracker demo and copied all relevant parts into my test application,
> but the generated result looks different and the suggestions are not
> visible.
>
> My code and templates are copied from the TimeTracker demo (incl. CSS,
> Border component and everything else). But if I inspect the DOM after
> the suggestions should have been rendered, the result looks different.
> It's no surprise that no suggestions are rendered at all because of
> style="display: none;"
> in the output of my test...
>
>
>
> from the TimeTracker demo:
>
> ...
> <input autocomplete="off" id="suggest" name="suggest" size="34"
> value="" type="text">
> <div style="position: absolute; left: 147px; top: 220px; width: 230px;
> opacity: 0.999999;" id="suggestchoices" class="autocomplete"><ul><li
> class="selected"><img
> src="http://setiathome.free.fr/images/flags/ye.gif">Yemen</li></ul>
> ...
> </div>
> </td>
>
> ...
>
>
> from my appilication:
>
> ...
> <input autocomplete="off" id="suggest" name="suggest" size="60" value=""
> type="text"><div style="display: none;" id="suggestchoices"
> class="autocomplete"><script>
> //<![CDATA[
> dojo.require("tapestry.event");
> //]]>
> </script><script>
> //<![CDATA[
> tapestry.cleanConnect("eventListenerDemo", "onmouseover",
> "event1975610136");
> tapestry.event1975610136=function(e){
> var content={beventname:"onmouseover"};
> tapestry.event.buildEventProperties(e, content,
> arguments);
> if (!content["beventtarget.id"])
> content["beventtarget.id"]="eventListenerDemo";
>
> tapestry.bind("/oos/directevent.svc?page=test%2FAjaxTest&session=T",
> content);
> };
> tapestry.connect("eventListenerDemo", "onmouseover",
> "event1975610136");
> //]]>
> </script><ul><li><img
> src="http://setiathome.free.fr/images/flags/si.gif">Slovenia</li>
> ...
> </ul></div></td>
> </tr>
> ...
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org