I can't determine the difference between Element.setAttribute(String name, String value) and Element.setPropertyString(String name, String value). Is there a difference? Which is preferred when attempting to set, say, a placeholder on a text input? I've been doing getElement().setPropertyString("placeholder", "this is a placeholder"); and it works, but is that the appropriate way to do it?
In the documentation for DOM, setAttribute(Element, String, String) is deprecated, saying to use "the more appropriately named setElementProperty(Element, String, String) instead." Does that imply that one should be using the similarly named methods of Element?
There is a difference between Attributes and Properties. In short the attribute represents the initial state while the property always represents the current state.
See http://jquery-howto.blogspot.com/2011/06/html-difference-between-attribute-and.html for a detail explanation.
In GWT calling setAttribute calls the native javascript function setAttribute on the current element. Calling setProperty... set the property on the current element.
In the past this in most browsers this used to be the same, but with evolving standards this started to change ago.
I don`t really know all the small differences between browser implementations, but to track the difference one could rely on the different DOM Level Specs: http://www.w3.org/TR/DOM-Level-2-HTML/ http://www.w3.org/TR/DOM-Level-3-Core/
Also the Mozilla docs are on setAttribute are quite could and state the difference for firefox: https://developer.mozilla.org/en/DOM/element.setAttribute
So in summary: if you use setAttribute in GWT you rely on the browser setAttribute implementation which is somewhat setting the defualt value (on certain properties, and not updating a value), so normally you want setProperty...
The problem is that in IE6 and IE7 (and IE8 in compatibility modes), setAttribute actually sets the property (IE doesn't really make a difference; IE8 added an optional argument to getAttribute to allow retrieving the attribute as defined in the DOM spec; see http://msdn.microsoft.com/en-us/library/ms536429v=vs.85.aspx).
BTW, your JavaDoc reference should be http://google-web-toolkit.googlecode.com/svn/javadoc/latest/index.html (not the one for GWT 1.5, which is severely outdated), and you should use com.google.gwt.dom.client.Element rather than com.google.gwt.user.client.DOM. Element has a setAttribute that sets the attribute in every browser other than IE6/7 (or similar modes of IE8).
But most of time, you should just work with DOM properties, rather than attributes. For instance, you want to get the tab index as a number, not as a string. And you want the default value/state for a property in the absence of the attribute, not a null that you'd have to handle yourself (e.g. an input element defaults to type=text when there's no type attribute; getAttribute("type") would return null whereas getPropertyString("type") would return "text").
Related
Now as per termFilter and inFilter definitions, both are doing the same job, what is the difference ?
I think you are using the very old Elasticsearch version(As in latest version inFilter isn't present, and your link is pointing to Elasticsearch version below 1), But as mentioned in the documentation link you provided, termsFilter is useful to filter one value, while inFilter will work even if you pass many terms, and if it matches any one of them.
For ex: you have a name field, where three documents have foo, bar or baz, using termsfilter you can filter by only one value ie foo, bar, you will get only one document ,but if you use inFilter you can pass all the possible values, and get all the matching documents.
Consider them equivalent to sql statement.
name=foo (example of terms filter)
name in ('foo', 'bar', 'baz') // example of in Filter
I want to build an .ecore model. I am using Eclipse Neon. in Design mode, I have a class and inside the class I have few attributes. when I set type of the attribute to EEList<E> [org.eclipse.emf.common.util.EList], I can't set the Default Value Literal. I don't know what is the valid value.
To answer your question, it seems you cannot set a default literal value for ELists. Or at least I could find no reference to it in any documentation, nor in the code.
For what purpose are you defining an EAttribute of type EList ? If you simply want a multi-valued feature (e.g. List) you should instead have an EAttribute of type X with multiplicity [0..*].
I have an unusual use case.
In my left hand, I have a String value (say, "5001"). In my right hand I have an Annotation literal with some interesting information. It basically defines a named "slot" for which (in this example) "5001" is an appropriate value.
Let us now also say that I have some javax.validation.constraints Annotation (like Digits) in my...other hand. Note that I do not have any reference to any field or method or any other AnnotatedElement—just the javax.validation.constraints Annotation literal itself. This is the weird part, but take it as fact.
Armed with these bits, I can almost use ConstraintValidator to see if "5001" is a valid value for the "slot" defined by my annotation literal. But not quite, as I cannot acquire a ConstraintValidatorContext for use in the isValid() method.
(I have read this question on the subject, which suggests that I'm out of luck.)
I also cannot simply use the Validator API as I am not validating a bean instance but instead merely a value that, if everything goes well, may be used indirectly in an XSLT file, if you must know. :-) It's the determining if everything is going to go well part that I'd like to use javax.validation for here. But, as mentioned, I don't have a bean instance with an annotated element to validate—I just have the value that would go into that annotated element.
Is there a way forward here?
I have a particular question about the JavaFX library that might reveal a flaw in my understanding of the JavaFX-Framework in general.
Let us assume that there is an Entity class called Entity that has a BooleanProperty called checked. Furthermore, let there be a table column as follows:
TableColumn<Entity,Boolean> checkBoxColumn;
Then the setter for the cell value factory has the following signature:
setCellValueFactory(Callback<TableColumn.CellDataFeatures<Entity,Boolean>,ObservableValue<Boolean>> value)
The following code should suffice to enable a column with checkboxes bound to the checked properties of the corresponding Entity-objects:
setCellValueFactory(new PropertyValueFactory<Entity, Boolean>("checked"));
checkBoxColumn.setCellFactory(CheckBoxTableCell.forTableColumn(checkBoxColumn));
My question in its simplest form: How does a CheckBoxTableCell set the value of the backing property considering the fact that the cell value factory returns an ObservableValue<Boolean> and not, e.g., a BooleanProperty?
The only way how I can imagine how this is done is that the CheckBoxTableCell dynamically checks whether the reference returned by the cell value factory is actually a reference to a property and then binds this property to the checked property of the checkBox.
The only way how I can imagine how this is done is that the
CheckBoxTableCell dynamically checks whether the reference returned by
the cell value factory is actually a reference to a property and then
binds this property to the checked property of the checkBox.
That's exactly what it does. Nothing sophisticated: just uses a simple instanceof check. The source code is here if you're interested enough (look at the updateItem(...) method).
I have a basic doubt in struts 1.x
Is there any difference in getting the value from jsp using request.getParameter('name') and form.get('name'), in terms of efficiency.
I know that form.get() returns an object and the former a string.
I want to know in the action class is it worth to get the dynaActionForm from the form argument of execute method and use it to get the user entered values in jsp. Or request.getParameter is enough ? Is there any other use of form object, if I typecast and create one ?
It's better to use request.getParameter().