Karam Singh Badesha wrote:
I think I would like to go with the AJAX approach but need more
information on that. In the example on your blog, you used onClick of
button to fire AJAX request. What would be it for a dropDown (onSelect)?
Yes, I think that's the right event. Or perhaps onChange (I'd have to
check the documentation to see what the component supports).
And, for the database call I can call my handler from the "!command"
event, right. Is it possible to see a full sample handler file with
correct import statements. And also where does the handler code go in
the application directory structure?
Sure see the attached file which is directly from JSFTemplating's
source code. It contains several handlers related to getting / setting
values in various "scopes".
You will need to create a "src" directory with package structure and
all your .java files. You'll compile this source with the "apt"
utility (instead of javac). I'd recommend you take a look at
JSFTemplating's "demo" directory which serves as an example developer
environment with ant build scripts and everything. It even has an
example handler in the "src/org/example/handlers/" directory.
Ken
thanks,
Karam
Ken Paulsen wrote On 01/16/07 20:12,:
Hi Karam,
You can do this in a Bean if you'd like. Many people prefer doing it
this way.
You can also do this by putting your data in the scope manually.
JSFTemplating makes this convenient:
<sun:dropDown id="dd1" ...>
<!beforeCreate
getDropDownData(arg1="dd1" ... output=>$pageSession{dd1});
/>
</sun:dropDown>
You can also make a dropDown submit itself so that you can populate the
next dropDown. In JSFTemplating, you can take action on the that action
by doing the following:
<sun:dropDown id="dd1"...>
<!beforeCreate ... />
<!command
getDropDownData(arg1="dd2" ... output=>$pageSession{dd2});
/>
</sun:dropDown>
Where the handler(s) in the "!command" event populate the next drop down
with data. Doing this approach causes the whole page to refresh, which
isn't ideal. You can use Ajax techniques to avoid this. I wrote a blog
on how to do this in this environment. You can read about it here:
http://blogs.sun.com/paulsen/entry/jsftemplating_dynamicfaces_easy_ajax
I hope this helps.
Ken Paulsen
ken.paulsen@sun.com
Karam Singh Badesha wrote:
Hi,
We have a form which is basically database driven and I was wondering
what is the best way to do this. Here is the scenario:
dropdown1 -> dropdown2 -> dropdown3 -> Button
Database call to fill up dropdown1, then depending on dropdown1 value,
another database call to fill up dropdown2 ...
After all the fields are filled, user clicks on Button to go the next
page.
In the dropdown tag options, I don't see how I can specify the values
without using a bean:
<sun:dropDown items="#{MenuListBean.projectMenuOptions}" />
Now does that mean that I need to make these database calls inside the
MenuListBean? or is there another way to do this? Any sample code will
be helpful.
thanks,
-Karam