Hello Jason,

I guess we (the proponents of an XML server-side solution) should be writing code instead of talking, but maybe just a few points, the main being that using QxBuilder has been great so far and did not pose any of the problems you are talking about except that it was... SLOW. If indeed I should find out that client-side XML parsing is not the problem, I will not invest so much time into server-side parsing. I am NOT talking about javascript generation by PHP, which I find very unappealing

Priebe, Jason schrieb:
  - specifying event handlers is horrible -- you have to include big
    blocks of Javascript code in your PHP (or in the proposed system,
    in the XML).  Coding Javascript is tough enough with the current
    tools, and doing it inside of another language's development
    environment doesn't make it easier.  The bulk of my application's
    code is event handlers, Sajax calls, and callbacks.
Have a look at the QxBuilder solution: very elegant and simple:
       <qx:textField
           id="bg_search_replace_search_text"
           top="30" left="150" width="250">
           <qx:eventListener type='input' >
               bg.getWidget("detailview").matchEntry ( event.getTarget(),
bg_search_replace_dropdown_search.getList().getSelectedItem().getValue(),
                    event.getNewValue() );
</qx:eventListener> </qx:textField>

( I attach the whole widget)
  - managing variable names of the widgets is pretty awful, too --
    your events will presumably want to modify or add data to the
    widgets -- how will they refer to the widgets?
well, each widget has a unique id. Where is the problem? ;-)
  - you can't make a layout property of a QX widget dependent on a
    layout property of another widget, because the actual Javascript
QX widgets (and their layout behaviors) don't really exist yet.
I would think that using creation events solves this problem. You can always redraw widgets when a layout property of another widget changes, since the ingenious event system of Qx monitors all changes.
I don't think that these issues are insurmountable -- I just think you
should give a lot of consideration to them before investing too much
time.
As I said, the mere existence and usefulness of QxBuilder has shown that these issues don't really pose a problem. All I want is to move the parsing to the server and extend the idea of QxBuilder to use XML not only to describe single widgets, but a whole application.

Christian
<?xml version="1.0" encoding="utf-8"?>
<qx:widgets xmlns:qx="http://qooxdoo.sourceforge.net";>


	<tal:block define="config this/getConfig; 
							 fields php: config.getKeys('field_definition.fields')"/>
							 
	<qx:window  id="bg_search_replace"
                left="100" top="100"
                width="410" height="130"
		allowMinimize="false" showMinimize="false"
                tal:attributes="caption php: __('Search and Replace')">
		
		<qx:atom top="5" left="5"
			tal:attributes="text php: __('Field to search in') "/>

		<qx:comboBox
            id="bg_search_replace_dropdown_search"
            top="5" left="150"  right="5" width="250">
			<qx:listItem tal:repeat="field fields"
				tal:attributes="value field; text php:__( field ) "/>
			<qx:eventListener type='changeSelected' >
				bg_search_replace_search_text.setText("");
				bg_search_replace_replace_text.setText("");
			</qx:eventListener>  				
		</qx:comboBox>
		
		<qx:atom top="30" left="5"
			tal:attributes="text php: __('Text to search for') "/>

		<qx:textField
			id="bg_search_replace_search_text"
			top="30" left="150" width="250">
			<qx:eventListener type='input' >
				bg.getWidget("detailview").matchEntry ( event.getTarget(), 
					 bg_search_replace_dropdown_search.getList().getSelectedItem().getValue(), 
					 event.getNewValue() );
			</qx:eventListener>  
		</qx:textField>
		
		<qx:atom top="55" left="5"
			tal:attributes="text php: __('Text to replace with') "/>

		<qx:textField
			id="bg_search_replace_replace_text"
			top="55" left="150" width="250">
			<qx:eventListener type='input' >
				bg.getWidget("detailview").matchEntry ( event.getTarget(), 
					 bg_search_replace_dropdown_search.getList().getSelectedItem().getValue(), 
					 event.getNewValue() );
			</qx:eventListener>  
		</qx:textField>

        <qx:atom
            bottom="0" left="5" height="22"
            tal:attributes="text php: __('Leave search text empty to replace the whole field.')"/>

        <qx:button
            bottom="0" right="5" height="22" width="60"
			id="bg_search_replace_submit_button"
            icon="icons/16/ok.png" 
            iconPosition="left"
            text="Send">
			<qx:eventListener type='click' >
				bg_search_replace.execute();
			</qx:eventListener>  
			<qx:eventListener type="canEditFolderContents">
				this.setEnabled ( event.getNewValue() );
			</qx:eventListener>
		</qx:button>
		
		<qx:script>

			bg.listview.getIds = function (){return this.data.ids;}
			
			bg_search_replace.open();
			
			
			bg_search_replace.execute = function () {
				var sItem 	= bg_search_replace_dropdown_search.getList().getSelectedItem();
				if ( ! sItem ) return;
				
				var field 			= bg_search_replace_dropdown_search.getList().getSelectedItem().getValue();
				var search 			= ( bg_search_replace_search_text.getText() );
				var replace 		= ( bg_search_replace_replace_text.getText() );
				var referenceIds 	= bg.listview.getIds();
				
				if ( ! referenceIds.length ) {
					alert ( _("No references to operate on.") );
					return;
				}
				
				if ( ! search && ! replace ) {
					alert ( _("Please provide values either for search or replace." ) );
					return;
				}
				
				if ( ! search ) search="";
				if ( ! replace ) replace="";
				
				var confirmMsg = "Are you sure you want to " + 
								 ( search ?  
									( "replace '" + search + "' by '" + replace + "' in " + "field " + _( field ) ) : 
									( "overwrite field " + _( field ) + " with '" + replace + "'" ) 
								 )  + "?";
				
				if ( ! confirm ( confirmMsg ) ) return; 
				var _alert = bg.alert ( _("Please wait"),false, "history" );
				dojo.io.bind({
					url: bg.url + "/data/search_replace",
					content : { datasource   : bg.listview.datasource, 
								referenceIds : referenceIds.join(","),
								field        : field,
								search       : search,
								replace		 : replace },     
					method : "post",                            
					handler: function(type, response, evt){ 
								bg.endRequest();
								_alert.setVisible(false);
								try {
									data = eval(response);
								} catch (e) {
									alert ( response );
									return false;
								}
								bg.listview.reload();
								bg.detailview.reload();
								//alert ( data.number + " references updated." );
							},
					mimetype: "text/plain"
				});				
			}
		</qx:script> 
    </qx:window>
</qx:widgets>

Reply via email to