Scheduler, Java, User_ID, and DhtmlxCombo (oh my)

Team,

Two questions:
First: I’m using Java/MySQL on my backend with a variation on the Scheduler_units sample. I have the dynamo working and it’s sweet. Now, I want to make it so that only the user that’s logged in see’s his/her calendar. I can easily append the variable on the .load function:
e.g.:

scheduler.load("/scheduler.do?user_id=${currentFirmUser…id}&uid="+scheduler.uid());

Peachy, but I can’t for the life of me figure out how to get that value in my configure() java backend. How can I get to the request map from the servlet? I think I want to do something like:

String strSQL = “select * from schedule where firm_id=”+ req.getParameter(‘user_id’);
c.render_sql(strSQL, “id”, “start_date,end_date,text,firm_id,physician_id,patient_id”);

But I have no request object. I can use a behavior and attach it, but dont see a “select” behavior. I’ve scoured the docs and forums, so please forgive me if i missed the answer somewhere…

I’m sure this has been solved already, so just point me in the right direction, and I’ll be on my merry way.

Second (and probably harder question): I would really like to use a dhtmlxCombo in my New Event window. I have to have an easy way to select a user from a pool of thousands… A pulldown is not really the best option :slight_smile:

Is this possible?

Cheers,

Dan

Most simple way is override doGet method inside connector’s class, which will give access to request object

@Override public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { user_id = req.getParameter('user_id'); //or something similar super.doGet(req, res); }

Attached sample shows, how something similar can be done.
scheduler_combo.ZIP (56.2 KB)

Many thanks! I’ll work it up and report back with my success. You have a truly wonderful app here.

Dan

Worked like a charm – Thanks! The 2nd part to this is getting that ID into the POST on insert/update. I think there are several ways I could do this. The first involves putting firm_id into the widget and then making a new section in the lightbox…

		String strSQL = "select * from schedule where firm_id=" + getFirmId();
		c.render_sql(strSQL, "id", "start_date,end_date,text,firm_id,physician_id,patient_id");
var theFirm = [ {key:${currentFirmUser.firm.id}, label:${currentFirmUser.firm.id} }];		
scheduler.config.lightbox.sections=[	
			{name:"Firm", height:0, type:"select", options:theFirm, map_to:"firm_id" },
			{name:"Patient", height:23, type:"select", options:patients, map_to:"patient_id" },
			{name:"description", height:130, map_to:"text", type:"textarea" , focus:true},
			{name:"Physican", height:23, type:"select", options:physicians, map_to:"physician_id" },			
			{name:"time", height:72, type:"time", map_to:"auto"}
		]

The problem with this is that the client cant change the firm (and I dont want them to!) - So the question is how can i get this variable passed back into the insert/update without rendering it in the lightbox? Is there a hidden section?

An alternate way might be to override the beforeInsert/beforeUpdate methods…

What are your thoughts?

Thanks again!

Dan

I’m sooo close to getting this working.

I took the example you gave me which is 95% of what I needed (thanks!), but the lookup needs to be autocomplete not static XML (there could be tens of thousands of records). So, I hooked it up to a Connector servlet and made a few modifications.

The requests to the servet go off correctly, and it DOES return XML as expected, but it doesnt populate selection. (e.g. no autocomplete.) So the data part is working, but I must be missing something to tell the node that it’s an autocomplete or the like.

I did get rid of the references to the XML data since they were not used…

		scheduler.form_blocks["combo"]={
		    render:function(sns){
				var height=(sns.height||"23")+"px";
				var html="<div class='dhx_cal_ltext' style='height:"+height+";' id='"+scheduler.uid()+"'></div>";
				return html;
		    },
		    set_value:function(node,value,ev){
				if (!node.combo){
					node.combo = new dhtmlXCombo(node.id,"dummy",553);
					node.combo.enableFilteringMode(true,"/xmd/scheduler/firmUserConnector.do",true);
					node.combo.loadXML("/xmd/scheduler/firmUserConnector.do",function(){
	                	node.combo.setComboValue(value||"");
	            	});
	                return;
		        }
		        node.combo.setComboValue(value||"");
		    },
		    get_value:function(node,ev){
				return node.combo.getActualValue();
		    },

		    focus:function(node){
				node.combo.DOMelem_input.focus();
		    }
		}
		
		scheduler.locale.labels.unit_tab = "By Doctor"
		scheduler.locale.labels.section_Physican="Physican";
		scheduler.locale.labels.section_Patient="Patient";
		scheduler.config.details_on_create=true;
		scheduler.config.details_on_dblclick=true;
		scheduler.config.xml_date="%Y-%m-%d %H:%i";
		scheduler.config.lightbox.sections=[	
			{name:"Firm", height:0, type:"select", options:theFirm, map_to:"firm_id" },
			{name:"Patient", height:23, type:"combo", map_to:"patient_id" },
			{name:"description", height:130, map_to:"text", type:"textarea" , focus:true},
			{name:"Physican", height:23, type:"select", options:physicians, map_to:"physician_id" },			
			{name:"time", height:72, type:"time", map_to:"auto"}
		]

Again, looking @ firebug I see the request to the server when I start to type lettes, and it IS returning:

<?xml version='1.0' encoding='utf-8' ?><complete><option value='3' >Foo</option><option value='4' >Foo2</option></complete>

Any ideas?

Again, looking @ firebug I see the request to the server when I start to type lettes, and it IS returning:

Data, retrieved from server must be a valid auto-completion. So if you have “abc” typed in combo and as response from server Foo - it will not work , because only data which starts from “abc” will be shown in the list.

( this behavior is may be not-necessary in some cases, but the only way to change it , alter few lines in dhtmlxcombo.js - I can provide more details if necessary )

So the question is how can i get this variable passed back into the insert/update without rendering it in the lightbox? Is there a hidden section?

Actually, you need not section in the lightbox to retrieve some value back to server.
All properties of event will be sent back to server, so if you have some property in data xml, or set it through JS api
scheduler.getEvent(id).firm = 1;
it will be available on server side. ( if you are using connector, it will be mapped to the “firm” field by default )

… Well if I type in “j” into the box the XML looks like:

<?xml version='1.0' encoding='utf-8' ?><complete><option value='19' >Johnson</option><option value='60' >Jackson</option></complete>

But there is no UI of the autocomplete. No pulldown, nothing. I think the widget is work, but the way I mapped it on the page is wrong??

Or does the “value” need to start with “j” for the widget to work?

Ideally the value would be the ID of the user, and the label would be their name…

Thanks!

hi folks…im new here …i want use this on my java app
well i see very carrefully all info and this is the only solution for set options list to scheduler …

so i want to ask why this not have like on php …the method setOptions for schedulerconnector??

and if somebody can share an real sample for get options list for server side on java…just like you make on php localhost/dhtmlxscheduler/sample … tions.html

Manuel Rodriguez Coria
mavirroco@gmail.com
Tarija, Bolivia
chears

so i want to ask why this not have like on php …the method setOptions for schedulerconnector??
Actually it has.

The same technique as the next one, can be used with Scheduler
192.168.1.251/dhtmlx/docs/doku.p … ns_in_grid

thanks stanislav…but
the url not show nothing?? is really slow page

Sorry, was a my mistake, I have post local documentation URI, the correct one

docs.dhtmlx.com/doku.php?id=dhtm … ns_in_grid

Basically - you can use set_options exactly the same as in PHP
If by any chance it doesn’t work with your version of connector, try the attached one
dhtmlxconnector.zip (112 KB)

thanks i will check …
by the way you must to update your files with respect to the examples with java :slight_smile:

i let you know if goings well with your code…

bye bye

Manuel Rodriguez Coria
mavirroco@gmail.com
Tarija, Bolivia

[code]
<start_date>2010-07-31 00:00:00.0</start_date>
<end_date>2010-07-31 00:05:00.0</end_date>
ir a jugar basquet

aaaa
4 2010-07-28 00:00:00.0 2010-07-28 00:05:00.0 nuevo evento
aaasd
4 [/code]

well my coll_options for=“typeid” is empty ??

here is my java code

[code]import java.sql.Connection;
import com.dhtmlx.connector.ConnectorServlet;
import com.dhtmlx.connector.OptionsConnector;
import com.dhtmlx.connector.SchedulerConnector;

// TODO: Auto-generated Javadoc
/**

  • The Class SchedulerBasicConnector.
    */
    public class Scheduler_BasicConnector extends ConnectorServlet {

    /* (non-Javadoc)

    • @see com.dhtmlx.connector.ConnectorServlet#configure()
      */
      @Override
      protected void configure() {
      Connection conn= ( new DataBaseConnection()).getConnection();
      OptionsConnector options = new OptionsConnector(conn);
      options.render_table(“types”,“typesid”,“typeid(value),name(label)”);

           SchedulerConnector c = new SchedulerConnector(conn);
           c.set_options("typeid",options);
           c.render_table("events","event_id","start_date,end_date,event_name,details,typeid","","");
      

    }

}
[/code]

here my html code

[code] function init() {
scheduler.config.xml_date="%Y-%m-%d %H:%i";
scheduler.config.lightbox.sections=[
{name:“eventname”, height:43,type:“textarea”,map_to:“text”, focus:true},
{name:“details”, height:130, type:“textarea”, map_to:“details” },
{name:“time”, height:72, type:“time”, map_to:“auto”}
//,
//{name:“typeid”, height:21,map_to:“typeid”,type:“select”, options:scheduler.serverList(“typesid”)}
]
scheduler.config.first_hour=4;
scheduler.init(‘scheduler_here’,null,“month”);
scheduler.config.details_on_create=true;
scheduler.config.details_on_dblclick=true;

	scheduler.locale.labels.section_eventname="Event Name:";
	scheduler.locale.labels.section_details="Event Details:";
	scheduler.locale.labels.section_typeid = "Types:";
	
	scheduler.load("events.do?uid="+scheduler.uid());
	var dp = new dataProcessor("events.do");
	dp.init(scheduler);
}[/code]

also when i enable this line of code
{name:“typeid”, height:21,map_to:“typeid”,type:“select”, options:scheduler.serverList(“typesid”)}

this send me an error

scheduler.serverList is not a function
localhost:8094/ScheduleProject/r … le_db.html
Line 24

what im doing wrong??

chears

Manuel Rodriguez Coria
mavirroco@gmail.com
Tarija, Bolivia

scheduler.serverList is not a function
You are using old js files , update them to scheduler 2.2

As for empty list - it seems as you have not records in the “types” table.
You can try to

  • enable log
  • check the sql command which is used to get data from types table
  • try to run it against the DB