Skip to main content

DOJO DropDownDatePicker - How to get the value?

5 replies [Last post]
burghaus
Offline
Joined: 2007-04-23
Points: 0

I have searched a bit and cannot find the answer to this.

I have a simple JSP page with just a simple call to the dropdowndatepicker.

How do I get the value in my servlet?

I tried adding an Id="xyzDate" inside the tag but cannot find that as a parameter in my request.

Thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
djordjew
Offline
Joined: 2007-06-14
Points: 0

Hello all

I'm newbie to jMaki and AJAX, and am really struggling with dropdowndatepicker.

I tried to follow the instructions from this forum and also followed the instructions from article 'A practical guide to jMaki events', but still cant get selected value in my servlet.

Here are parts of my code:

in my jsp:

in my glue.js:
jmaki.addGlueListener("/dojo/dropdownDatePicker", "jmaki.listeners.getDate");
jmaki.addGlueListener("/matchDate","/jmaki/listener/getDate");

jmaki.listeners.getDate = function(args) {
var contentValue = args.value;
var contentId = args.id;
// send data back to server
jmaki.doAjax({method: "POST",
url: "Service.jsp",
content: {message: contentValue },
callback: function(_req) {}
});

}

Any help is much appreciated, dont know what I'm doing wrong here.

carlavmott
Offline
Joined: 2005-02-10
Points: 0

Hi,
with the latest release of jMaki (.9) you can do the following to glue.js:

jmaki.addGlueListener("/dojo/dropdownDatePicker","jmaki.listeners.getDate");


jmaki.listeners.getDate= function(args){
alert("getDate value " + args.value);
}

the JSP looks like

this works with .9 because we added code so this (and many other widgets) publish to a topic just so you can get the value easily.

Note that you can override the topic default topic name by doing the following:

and update the glue code as appropriate.
carla

burghaus
Offline
Joined: 2007-04-23
Points: 0

I saw an example of that. The script below will display the value selected back to the screen. To get the value to my java servlet, could I reference a parameter called "mytipoc" or would I need to change the script to set a hidden value?

carlavmott
Offline
Joined: 2005-02-10
Points: 0

I was updating the getwidgetdata sample to do just that. Not sure if I checked in my changes but here they are. To send data back to a JSP add the following in the glue code:

var contentValue = args.value;

// send data back to server

jmaki.doAjax({method: "POST",

url: "Service.jsp",

content: {message: contentValue },

callback: function(_req) {

jmaki.publish("xyzDate", {url: "DateContents.jsp"});
}
});

Here the value goes back to the server and also I send it to another JSP so I can display it there.

The entire Service.jsp looks like:

<%
String message = "request. getParameter("message");"
session.setAttribute("message", message);
%>

I'll post the sample soon so we can look at all the code.

sine_morbo
Offline
Joined: 2007-04-18
Points: 0

I'm also using the dropdowndatepicker in my JSF page, in a form. I was trying to modify your code that the dropdowndate value gets submitted to my ManagedBean with the other form components, but I couldn't succeed. Could you help some more?