Skip to main content

JSF JMaki and Netbeans Visual Web application

33 replies [Last post]
dinamlab
Offline
Joined: 2005-09-20

Hi im trying to do the exercise in this tutorial http://blogs.sun.com/divas/entry/using_the_dojo_combobox_in

But when I run the application on the server, I got this exception

javax.el.MethodNotFoundException: Method not found: (javax.faces.context.FacesContext, java.lang.String, java.lang.String, com.sun.jmaki.AjaxResult)

I think that this is on this line in the service parammeter

Can any one help me?
Thanks
Dinamlab

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
gmurray71
Offline
Joined: 2003-07-31

Did you re-install the visual web pack?

I'm not as familiar with the XML view of JSF in a VWP environment. I may need to forward you to some other engineers that are better with it.

I'm sorry about all the issues.

-Greg

dinamlab
Offline
Joined: 2005-09-20

Yes I have reinstaled Visual Web Pack.

I try with various versions of Glassfish and it does not work for me... :S

Thanks

jenniferb
Offline
Joined: 2004-04-02

Greg,

I updated my workspace and re-built, but I also get no values in the combobox.

I get the error, this._data has no properties, when trying to select a value.

The example seems to work in the v8.1 jmaki.war however, but it doesn't include the ApplicationBean.java file.

Jennifer

dinamlab
Offline
Joined: 2005-09-20

I got the same error. :p

.........................

I got it running, I dont know how but the script executes two times the countryService method.

add this to the above script:

private int k = 1;

public void countryService(FacesContext context, AjaxResult result) {
result.setResponseType(AjaxResult.JSON);
if((this.k%2)!=0){
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("]");

}
k += 1;
}

I dont know if its a good solution but its working... :)

dinamlab
Offline
Joined: 2005-09-20

Hi.... I update today the jmaki netbeans plugin, now I have an exception that saids to me to use the following method signature for countryService

countryService(FacesContext, AjaxResult)

Now the comboBox its all ready set up, but what about saving the value you selected in the combo box, I use this

jmaki.attributes.get('form1: panelGroup1:cb1').saveState();

But it does not change the value of country in SessionBean property.

I can get the value changing saveState for getValue(), but how do i save this value in the country property of SessionBean in the application.

Thanks

gmurray71
Offline
Joined: 2003-07-31

Try using the following for your country service. This will also save the state:

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 me know if this doesn't work.

dinamlab
Offline
Joined: 2005-09-20

Hi this work when use this on the browser. It said message:success

http://localhost:8080/VWJMaki/faces/ApplicationBean1-countryService.ajax...

but when i do a submit using the widget dojo.comboBox, some times it work and other times dont...

dinamlab
Offline
Joined: 2005-09-20

I think that maybe, the method dojo.io.bind its not working appropriately...

gmurray71
Offline
Joined: 2003-07-31

You could test this by using Firebug. If you open the Firebug options menu you can select "Show XMLHttpRequests" when a request is made you will see it appear in the log. This way you can see if the problem is on the client side or if the bean isn't working.

dinamlab
Offline
Joined: 2005-09-20

I installed Fire bug,

POST http://localhost:8081/VWJMaki/faces/ApplicationBean1-countryService.ajax...
value=Canada

But its the same thing...

gmurray71
Offline
Joined: 2003-07-31

Hi,

We are not exposing the service mapping to JSF developers any more.

Try using:

You can also set the selected value using a selected attribute and mapping it to a managed bean value.

Let us know if this doesn't work.

dinamlab
Offline
Joined: 2005-09-20

Hi I change the line for

[b][/b]

I run the application i I still got the same error

[b]javax.el.MethodNotFoundException: Method not found: vwjmaki.ApplicationBean1@13cfd6e.completeCountry(javax.faces.context.FacesContext, java.lang.String, java.lang.String, com.sun.jmaki.AjaxResult)[/b]

here is my ApplicationBean Its exactly like the example:

package vwjmaki;

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 int __placeholder;

private void _init() throws Exception {
}
//

public ApplicationBean1() {
}

public void init() {
super.init();
try {
_init();
} catch (Exception e) {
log("ApplicationBean1 Initialization Failure", e);
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
}

}

public void destroy() {
}

public String getLocaleCharacterEncoding() {
return super.getLocaleCharacterEncoding();
}

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

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);
System.out.println("date set to " + date);
}

public String getCountry () {
System.out.println("get country "+country);
return country;
}

public void setCountry(String country) {
System.out.println("set country "+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 completeCountry(FacesContext context, String[] args, AjaxResult result) {
result.setResponseType(AjaxResult.JSON);
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("]");
}

/**
*

Return a reference to the scoped data bean.

*/
protected SessionBean1 getSessionBean1() {
return (SessionBean1)getBean("SessionBean1");
}
}

gmurray71
Offline
Joined: 2003-07-31

Have you provided the mapping in the faces-config.xml file?

gmurray71
Offline
Joined: 2003-07-31

When I say faces-config.xml I mean a file in your WEB-INF directory containing the following:



ApplicationBean1
com.sun.jmaki.dojo.ApplicationBean1
application

dinamlab
Offline
Joined: 2005-09-20

I hav this


ApplicationBean1
vwjmaki.ApplicationBean1
application

dinamlab
Offline
Joined: 2005-09-20

I have in web.xml this:

javax.faces.CONFIG_FILES /WEB-INF/navigation.xml,/WEB-INF/managed-beans.xml

I have a faces-config.xml, but the are in managed-beans.xml.

dinamlab
Offline
Joined: 2005-09-20

Or It could be the signature of the method?, but I change it and does not throw the exception but it does not work, I can see the widget but it does not have contents.

vwjmaki.ApplicationBean1@1eb03f.completeCountry(javax.faces.context.FacesContext, java.lang.String, java.lang.String, com.sun.jmaki.AjaxResult)

mi method signature is:

completeCountry(javax.faces.context.FacesContext, java.lang.String[], com.sun.jmaki.AjaxResult)

I hope this help a little more..

gmurray71
Offline
Joined: 2003-07-31

Hi,

This method did get updated. The method we use to support completion is as follows:

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("]");
}
}

In essence the completeCountry is a minicontroller. Which you can pass in commands via the second argument. Currently the widget calls setCountry. We might make this more generic to cover more cases.

Please let us know if this doesn't work for you.

dinamlab
Offline
Joined: 2005-09-20

It seems like its working, but there is a problem yet. Now the application does not trhow an exception but, the widget its empty.

I look at the javascript code in the html code of the application, it have this.

[b]jmaki.addWidget({baseDir:'http://localhost:8080/VWJMaki/resources/dojo/combobox',widgetDir:'http://localhost:8080/VWJMaki/resources/dojo/combobox',name:'dojo.combobox',service:'http://localhost:8080/VWJMaki/faces/ApplicationBean1-countryService.ajax',uuid:'form1:groupPanel1:j_id_id11',script:'http://localhost:8080/VWJMaki/resources/dojo/combobox/component.js'});[/b]

I test the links and I got a JSON string in service, its working but I have an empty comboBox...

gmurray71
Offline
Joined: 2003-07-31

So just to make sure:

http://localhost:8080/VWJMaki/faces/ApplicationBean1-countryService.ajax

Will return the JSON string:

[["Canada","CA" ],["France","FR" ],["Uganda","UG" ],["Ukraine","UR" ],["United States of America","USA" ],["United Kingdom","UK" ],["Japan","JP" ],["Korea","KR" ],["Jamacia","JA" ],["Thailand","TH" ]]

When you click on the Blue Arrow you get no entries?

A blank box will occur if you don't use a selected attribute bound to one of the values.

You should see the values if you were able to see the JSON string.

What browser are you using and did you see any JavaScript errors messages?

dinamlab
Offline
Joined: 2005-09-20

Yes its like this:

[b]http://localhost:8080/VWJMaki/faces/ApplicationBean1-countryService.ajax[/b]

[["Canada","CA" ],["France","FR" ],["Uganda","UG" ],["Ukraine","UR" ],["United States of America","USA" ],["United Kingdom","UK" ],["Japan","JP" ],["Korea","KR" ],["Jamacia","JA" ],["Thailand","TH" ]]....]

Im using Firefox 2.

In the console error of firefox does not have errors.

dinamlab
Offline
Joined: 2005-09-20

Yes when i click in the blue arrow I does not have contents.

dinamlab
Offline
Joined: 2005-09-20

I use this:

selected="#{ApplicationBean1.country}" />

Now I have Uganda String in the comboBox, but when I click on the arrow it does not have entries

dinamlab
Offline
Joined: 2005-09-20

Message was edited by: dinamlab

dinamlab
Offline
Joined: 2005-09-20

I see this in the comoponent.js in this line

if (wargs.service) {
dojo.io.bind({
url: wargs.service,
method: "get",
mimetype: "text/json",
load: function (type,data,evt) {
_this.wrapper.dataProvider.setData(data);

}
});

I think the [i]data[/i] variable would be the JSON string i did an alert on Data but her value is [i]undefined[/i]

gmurray71
Offline
Joined: 2003-07-31

Could you do an alert and make tell me what wargs.service is equal to?

It should be:

http://localhost:8080/VWJMaki/faces/ApplicationBean1-countryService.ajax

Next could you put the string above in your URL bar and send me the response. I suspect the return value might now be properly formatted JSON. I know you pasted it in before but could you send the full string.

Also could you mail me your web application to gregory dot murray at sun dot com? I'll also need the Java source for your managed bean.

-Greg

dinamlab
Offline
Joined: 2005-09-20

I do an alert to wargs.service:

http://localhost:8080/VWJMaki/faces/ApplicationBean1-countryService.ajax

here is the complete JSON String:

[["Canada","CA"],["France","FR"],["Uganda","UG"],["Ukraine","UR"],["United States of America","USA"],["United Kingdom","UK"],["Japan","JP"],["Korea","KR"],["Jamacia","JA"],["Thailand","TH"]][["Canada","CA"],["France","FR"],["Uganda","UG"],["Ukraine","UR"],["United States of America","USA"],["United Kingdom","UK"],["Japan","JP"],["Korea","KR"],["Jamacia","JA"],["Thailand","TH"]]

dinamlab
Offline
Joined: 2005-09-20

I will send you the app

dinamlab
Offline
Joined: 2005-09-20

The application its executing countryService two times...

gmurray71
Offline
Joined: 2003-07-31

I've got the app and it runs on Glassfish version 9.1. What is your Java EE environment?

dinamlab
Offline
Joined: 2005-09-20

I think Im using Sun Application Server 9.0 update 1, Ill better download the latest version of glassfish and see what happen...

dinamlab
Offline
Joined: 2005-09-20

Now I have netBeans 5.5.1, to view Glassfish v2 build 31. All its working fine, but when i want to deploy the

Visual Web Application I got this. :S any Sugestions

deployed with moduleid = VWJMaki
registering: amx:j2eeType=X-WebModuleConfig,name=VWJMaki corresponding to com.sun.appserv:type=web-module,name=VWJMaki,category=config
registering: amx:j2eeType=X-DeployedItemRefConfig,name=VWJMaki,X-StandaloneServerConfig=server corresponding to com.sun.appserv:type=application-ref,category=config,ref=VWJMaki,server=server
Initializing Sun's JavaServer Faces implementation (1.2_03-b09-FCS) for context '/VWJMaki'
registering: amx:j2eeType=WebModule,name=//server/VWJMaki,J2EEServer=server,J2EEApplication=null corresponding to com.sun.appserv:j2eeType=WebModule,name=//server/VWJMaki,J2EEServer=server,J2EEApplication=null
registering: amx:j2eeType=Servlet,name=ThemeServlet,J2EEServer=server,J2EEApplication=null,WebModule=//server/VWJMaki corresponding to com.sun.appserv:j2eeType=Servlet,name=ThemeServlet,J2EEServer=server,J2EEApplication=null,WebModule=//server/VWJMaki
registering: amx:j2eeType=Servlet,name=Faces Servlet,J2EEServer=server,J2EEApplication=null,WebModule=//server/VWJMaki corresponding to com.sun.appserv:j2eeType=Servlet,name=Faces

Message was edited by: dinamlab

dinamlab
Offline
Joined: 2005-09-20

Or shoul I need to download an older version of Glassfish?