|
From: <et...@us...> - 2011-10-21 14:29:52
|
Revision: 4497
http://mxquery.svn.sourceforge.net/mxquery/?rev=4497&view=rev
Author: etterth
Date: 2011-10-21 14:29:46 +0000 (Fri, 21 Oct 2011)
Log Message:
-----------
- Updated history.html (hash synchronization with checkboxes is now working)
- Fixed a bug in fn:doc (reset was faulty)
- The mapping from DOM input element properties to attributes should now be more complete
Modified Paths:
--------------
trunk/MXQuery/xqib_samples/history.html
trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/fn/Doc.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/DOMImpl.java
trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Element.java
Modified: trunk/MXQuery/xqib_samples/history.html
===================================================================
--- trunk/MXQuery/xqib_samples/history.html 2011-10-21 07:09:22 UTC (rev 4496)
+++ trunk/MXQuery/xqib_samples/history.html 2011-10-21 14:29:46 UTC (rev 4497)
@@ -17,18 +17,18 @@
let $hashstring := (
let $doc := fn:doc('historysrc.xml')
let $newhash := '#'
- for $activefeature in b:dom()//input[@type=checkbox and @checked=true]
+ for $activefeature in b:dom()//input[@type='checkbox' and @checked='true']
let $activated := $activefeature/@groupid
group by $activated
return
- '#eouoeuoeu'
+ concat('#', $activated, '=', string-join($activefeature/following-sibling::text(), '='))
)
return
- b:setHash(if ($hashstring) then $hashstring else '#')
+ b:setHash(if (count($hashstring)) then string-join($hashstring) else '#')
};
declare function h:stateChanged(){
- 1
+ h:writeUrl()
};
declare updating function h:recalculate(){
@@ -38,11 +38,16 @@
return $featuregroup/@groupid/string-value
return replace node b:dom()//id('results') with <div id='results'>{
for $product in $doc/*:store/*:product
- where $product
+
return
- <div class=''>{
- 1
- }</div>
+ <div class=''>
+ <div>{
+ data($product/@name),
+ <div>{
+ 1
+ }</div>
+ }</div>
+ </div>
}</div>
};
@@ -59,7 +64,7 @@
let $checkbox := b:dom()//input[b:getClasses(.)='categorycheckbox' and @groupvalue = $value ]
where $checkbox
return
- replace value of node $checkbox/@checked with 'true'
+ insert node attribute checked { 'true' } into $checkbox
@@ -69,18 +74,19 @@
import module namespace h = "http://www.XQIB.org/history";
declare variable $doc := fn:doc('historysrc.xml');
- block {
for $featuregroup in $doc/*:store/*:feature-groups/*:feature-group
return insert node <div>{data($featuregroup/@name)}{
for $value in fn:distinct-values($doc/*:store/*:product/*:feature[@groupid = $featuregroup/@groupid]/@value)
return
- <div><input type="checkbox" class="categorycheckbox" groupvalue="{$value}" checked="no">{$featuregroup/@groupid}</input>{$value}</div>
+ <div><input type="checkbox" class="categorycheckbox" groupvalue="{$value}" >{$featuregroup/@groupid}</input>{$value}</div>
}</div> as first into b:dom()//body;
+ for $cb in b:dom()//input[@type='checkbox']
+ return b:addEventListener($cb, 'click', h:stateChanged#2);
h:readUrl();
- (:h:writeUrl();:)
+ h:writeUrl();
h:stateChanged();
h:recalculate();
-}
+
</script>
<script type="text/javascript" >
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/fn/Doc.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/fn/Doc.java 2011-10-21 07:09:22 UTC (rev 4496)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/functions/fn/Doc.java 2011-10-21 14:29:46 UTC (rev 4497)
@@ -162,10 +162,13 @@
public void setReturnType(int type) throws MXQueryException {
}
+
@Override
protected void resetImpl() throws MXQueryException {
- if (baseIterator != null)
+ if (baseIterator != null) {
+ baseIterator.setResettable(true);
baseIterator.reset();
+ }
}
public String getSystemID() {
if (current != null)
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/DOMImpl.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/DOMImpl.java 2011-10-21 07:09:22 UTC (rev 4496)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/DOMImpl.java 2011-10-21 14:29:46 UTC (rev 4497)
@@ -6,6 +6,7 @@
import java.util.List;
import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.dom.client.IFrameElement;
import com.google.gwt.dom.client.InputElement;
@@ -61,12 +62,13 @@
// elementattributes.get(attr.getLocalName()));
//
// }
+ //TODO more input element types
if ("input".equals(ownername)) {
String attrname = attr.getNodeName();
if ("value".equals(attrname)) {
return ((InputElement) owner.getAsGwtNode()).getValue();
} else if ("checked".equals(attrname)) {
- return nativeInputGetChecked(owner);
+ return Boolean.toString(((InputElement) owner.getAsGwtNode()).isChecked());
}
}
}
@@ -76,13 +78,6 @@
// }
}
- protected native String nativeInputGetChecked(Element input)/*-{
- return input.checked
- }-*/;
- // protected native String getSpecialAttributeValue(Element owner,
- // String string) /*-{
- // return eval(attr + '.' + string);
- // }-*/;
protected native String nativeNodeGetValue(Node node)/*-{
return node.nodeValue;
@@ -106,6 +101,20 @@
for (int i = 0; i < attrs.length(); i++) {
ret.add(attrs.get(i));
}
+ //TODO more input element types
+ if ("input".equals(el.getLocalName())) {
+ if ("http://www.w3.org/1999/xhtml".equals(el.getNameSpaceURI())) {
+ InputElement input = (InputElement)(JavaScriptObject)el;
+ if ("checkbox".equals(input.getType())
+ || "radio".equals(input.getType())) {
+ el.setAttributeNS("", "checked", Boolean.toString(input.getPropertyBoolean("checked")));
+ ret.add((Attribute) el.getAttributeNode("checked"));
+ } else {
+ el.setAttributeNS("", "value", input.getValue());
+ ret.add((Attribute) el.getAttributeNode("value"));
+ }
+ }
+ }
return ret;
}
Modified: trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Element.java
===================================================================
--- trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Element.java 2011-10-21 07:09:22 UTC (rev 4496)
+++ trunk/MXQuery/xqib_src/ch/ethz/mxquery/util/browser/dom/Element.java 2011-10-21 14:29:46 UTC (rev 4497)
@@ -36,9 +36,13 @@
if ("input".equals(this.getLocalName())) {
InputElement el = (InputElement) this.getAsGwtElement();
if ("value".equals(localName)) {
+ DOMImpl.impl.elementSetAttributeNS(this, namespace, localName, value);
el.setValue(value);
+ return;
} else if ("checked".equals(localName)) {
+ DOMImpl.impl.elementSetAttributeNS(this, namespace, localName, value);
el.setChecked("true".equals(value));
+ return;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|