Skip to main content

How to use dojo combobox in JSF

4 replies [Last post]
kutlerc
Offline
Joined: 2003-07-09

Hello,

I am trying to rework this blog entry so that it works for 9.4.1: http://blogs.sun.com/divas/entry/using_the_dojo_combobox_in

I am able to fill up the combobox using the service method. However, I cannot figure out how to bind the selected value (the value that the user clicked/selected) to a bean property. There is no longer a selected attribute for the dojo combobox.

Carla tells me that there will be a selected args, but this is for setting selected and I don't think I will be able to bind this to a bean property.

Can anyone show me how to get the selected value saved so that I can access it from the server end?

Thanks,

Chris

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vinayat
Offline
Joined: 2007-07-26

Hi,

I am trying to get Dojo Combobox to work with JSF
I am running on Tomcat 5.x

I am getting a textbox when I implements this.
My jsp is as follows:

[code]
<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%@ taglib uri="http://jmaki/v1.0/jsf" prefix="a" %>


<%@include file="/app/inc/TopMenu.jsp"%>
columnClasses="headerpanels,headerpanels">





[/code]

I have copied the ajax-wrapper-comp.jar and jmaki-resources-dojo.jar in the lib directory.

Is there anything I need to add/include

Thanks
Vinaya

gmurray71
Offline
Joined: 2003-07-31

Hi,

The value attribute should be mapped to a method that generates content that conforms to the model at: http://wiki.java.net/bin/view/Projects/jMakiComboxModel
Also you should use either a service or value but not both. Using a service will asynchronously load the data after the widget has loaded. Using a value will inline the value when the page is rendered.

I recommend using the value.

carlavmott
Offline
Joined: 2005-02-10

Hi Chris,

I'll look into the selected value problem and report back.

To get the value the user has selected I did
jmaki.addGlueListener("/dojo/combobox", function(args){alert("combobox value " + args.value)})

in the glue.js file and see the correct value. Once you have the value look at the getwidgetdata sample to see how to get that back to your server.

hth,
carla

kutlerc
Offline
Joined: 2003-07-09

Thanks Carla,

I was already using getwidgetdata as my model. There were just some pieces missing when it comes to JSF. I am accustomed to simply binding the tag's args to backing bean properties to save off the data, such as:

(See https://widgets.dev.java.net/source/browse/widgets/trunk/code/tests/widg..., which is out of date but gives you an idea of how it used to be)

When I try the Glue way, I can't get the doAjax to work. I can't figure out what what to use for the URL. The response is always 404.

I have tried

url: "SessionBean1-comboboxSelection",
and
url: "SessionBean1.comboboxSelection",

jmaki.glue = {
eventComboboxSelected : function(args) {
var contentValue = args.value;
var contentId = args.id;
if ( typeof contentValue != 'undefined' ) {
// send data back to server
jmaki.doAjax({method: "POST",
url: "SessionBean1-comboboxSelection",
content: {message: contentValue },
callback: function(_req) {
// handle any errors
}
});
}
}

I have searched the tests at https://widgets.dev.java.net/source/browse/widgets/trunk/code/tests/widgets for some kind of clue as to how we can save the selected value in a JSF app, but no luck yet.