Skip to main content

dojo ComboBox

4 replies [Last post]
dinamlab
Offline
Joined: 2005-09-20
Points: 0

Hi, im trying again to use dojo combo box in Visual Web application.

The ajax services work fine, but the widget does not display. I think the problem its this line in javascript

jmaki.webRoot='http://localhost:8080/VWJMaki';jmaki.resourcesRoot ='/faces';

the resourcesRoot need to be '/resources'.... Why do i get '/faces'.?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
dinamlab
Offline
Joined: 2005-09-20
Points: 0

Here is my code for ApplicationBean

import com.sun.jmaki.AjaxResult;
import com.sun.rave.web.ui.appbase.AbstractApplicationBean;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.faces.FacesException;
import javax.faces.context.FacesContext;

public class ApplicationBean1 extends AbstractApplicationBean {

private String message = "Edit Me Please!";
private String country = "Uganda";
private Date date = new Date();
private Date time = new Date();
private SimpleDateFormat f, t;

public String getMessage() {
return message;
}

public void setMessage(String m) {
this.message = m;
}

public String getDate() {
if (f == null) {
f = new SimpleDateFormat("MM/dd/yyyy");
}
return f.format(date);
}

public void setDate(String ds) {
date = new Date(ds);
}

public String getTime() {
if ( t == null) {
t = new SimpleDateFormat("HH:MM");
}
return t.format(time);

}

public void setTime(String t) {
time = new Date(t);
System.out.println("time set to " + time);
}

public String getCountry() {
return country;
}

public void setCountry(String country) {
this.country = country;
}

private String[] countries =
new String[] {
"Canada", "France", "Uganda", "Ukraine", "United States of America", "United Kingdom", "Japan", "Korea", "Jamacia", "Thailand"
};

private String[] countryCodes =
new String[] {
"CA", "FR", "UG", "UR", "USA", "UK", "JP", "KR", "JA", "TH"
};

public void countryService(FacesContext context, String command, String value, AjaxResult result) {
result.setResponseType(AjaxResult.JSON);
if ("setCountry".equals(command)) {
setCountry(value);
result.append("[message:'success']");
} else {
result.append("[");
for (int loop=0; loop < countries.length; loop++){
result.append("[\"" + countries[loop] + "\",\"" + countryCodes[loop] + "\" ]");
if (loop < countries.length -1) result.append(",");
}
result.append("]");
}
}

}

dinamlab
Offline
Joined: 2005-09-20
Points: 0

And this is my jsp:


xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">









onClick="jmaki.attributes.get('form1:groupPanel1:cb1').saveState(); return false;"
style="left: 479px; top: 192px; position: absolute" text="Save State"/>
onClick="alert(jmaki.attributes.get('form1:groupPanel1:cb1').getValue()); return false;"
style="left: 575px; top: 192px; position: absolute" text="Get Value"/>








I hope some one can help me im been trying this for a while...

Im using JMaki version 8.3.1 and Glassfish V2 (b24)...

Thanks

gmurray71
Offline
Joined: 2003-07-31
Points: 0

Try the following for your backing bean country service (the API changed after versio .8.2).

public void countryService(FacesContext context, AjaxResult result) {
HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
// get the command
String command = request.getParameter("cmd");
result.setResponseType(AjaxResult.JSON);
if ("setValue".equals(command)) {
String value = request.getParameter("value");
setCountry(value);
result.append("[message:'success']");
} else {
result.append("[");
for (int loop=0; loop < countries.length; loop++){
result.append("[\"" + countries[loop] + "\",\"" + countryCodes[loop] + "\" ]");
if (loop < countries.length -1) result.append(",");
}
result.append("]");
}
}

Let us know if this does not work.

-G

Message was edited by: gmurray71

dinamlab
Offline
Joined: 2005-09-20
Points: 0

Now its working... Thanks

Message was edited by: dinamlab

Message was edited by: dinamlab