GWT property with is-multi-valued already defined - gwt

While migrating from GWT 2.7.0 to 2.8.2 I came upon property:
<define-configuration-property name="CssResource.gssDefaultInUiBinder"
is-multi-valued="true" />
If this is left as it is, I get an error: The configuration property named CssResource.gssDefaultInUiBinder is already defined with a different 'is-multi-valued' setting.
Does that mean that I can't set attribute is-multi-valued to already defined property? Why would this work with GWT 2.7.0 then? Can anyone give me an explanation about this attribute? Because I am failing to find one...
Attribute set in GWT resources:
<!-- The default for GSS in UiBinder -->
<define-configuration-property name="CssResource.gssDefaultInUiBinder" is-multi-valued="false" />
gwt/user/src/com/google/gwt/resources/Resources.gwt.xml

Correct - you should not be trying to change is-multi-valued, it doesn't really make any sense. You can't re-define a property or configuration-property after it has been set, you can only set the value.
If you want to turn the gss-in-ui-binder flag on, use this:
<set-configuration-property name="CssResource.gssDefaultInUiBinder" value="true" />
If you want to turn it off, either do nothing, or do this:
<set-configuration-property name="CssResource.gssDefaultInUiBinder" value="false" />

Related

phing loadfile to property does not override previous value

<loadfile property="test-from-file" file="value.txt" />
<echo message="test-from-file = ${test-from-file}" />
<loadfile property="test-from-file" file="value2.txt" />
<echo message="test-from-file = ${test-from-file}" />
The second loadfile does not change the value of the test-from-file property.
Is there any way to get this working?
As stated in comments by Jawi, properties are not overridden by design. A property works as a constant in Phing. So if it is already defined, then it won't be changed by later property definitions.
I think that you should revert your <property> task call in order to define your preferred sources first.
Alternatively, you can also use <property override="true"> to alter default behavior and override existing values, changing properties from constant to variable.

Mybatis Generator's bug: configuration items should be ordered?

If I put "<commentGenerator>" after "<jdbcConnection>", MBG proposed an error that context content should match: blablabla...
But when I put "<commentGenerator>" before "<jdbcConnection>", everything is ok. Here I have something to complain to the official website that if the order of these items is need, why you do not tell us! What an important thing! You r kidding the freshmen. Maybe it is some where I do not know, but this is a key point to build the MBG's configuration file successfully, why not put this NOTE on the top of the tutorial or somewhere eye-catching?
<generatorConfiguration >
<classPathEntry location="D:\mariadb-java-client-1.1.7.jar" />
<context id="db" >
<commentGenerator>
<property name="suppressAllComments" value="true" />
<property name="suppressDate" value="true" />
</commentGenerator>
<jdbcConnection driverClass="org.mariadb.jdbc.Driver"
connectionURL="jdbc:mariadb://localhost:3306/dbname"
userId="root"
password="password"
/>
<javaTypeResolver >
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- Model Class -->
<javaModelGenerator targetPackage="org.infrastructure.model" targetProject="infrastructure\src\main\java">
<property name="enableSubPackages" value="false" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- XML Files -->
<sqlMapGenerator targetPackage="sqlMap" targetProject="infrastructure\src\main\config">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<!-- DAO -->
<javaClientGenerator type="XMLMAPPER" targetPackage="org.infrastructure.dao" targetProject="infrastructure\src\main\java">
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<!-- Tables -->
<table tableName="user" domainObjectName="User" ></table>
</context>
</generatorConfiguration>
First of all, in your xml configuration file, it doesn't contains a valid root element, which always should be like <!DOCTYPE .../>. About how to add a correct root element of mybatis generator configuration file, please see example from MyBatis GeneratorXML Configuration File Reference.
If you correctly specified root element such as following:
<!DOCTYPE generatorConfiguration PUBLIC
"-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"
>
This root element contains a typical DTD declaration located at http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd. This is the definition of the order of these items is need. And we are going to see what it looks like.
From line 47 of this document type definition, it defines element named context. The content is as following:
<!--
The context element is used to describe a context for generating files, and the source tables.
-->
<!ELEMENT context (property*, plugin*, commentGenerator?, jdbcConnection, javaTypeResolver?,javaModelGenerator, sqlMapGenerator?, javaClientGenerator?, table+)>
Which obviously defined the order of the element in context, that is:
property*, plugin*, commentGenerator?, jdbcConnection,
javaTypeResolver?,javaModelGenerator, sqlMapGenerator?,
javaClientGenerator?, table+
In this element, all children must occurs as following rules:
+ for specifying that there must be one or more occurrences of the item — the effective content of each occurrence may be different;
* for specifying that any number (zero or more) of occurrences is allowed — the item is optional and the effective content of each occurrence may be different;
? for specifying that there must not be more than one occurrence — the item is optional;
If there is no quantifier, the specified item must occur exactly one time at the specified position in the content of the element.
After we understanding its real meaning, why you could not change the order of commentGenerator and jdbcConnection should be clear.
Maybe you want to know how to make the element out of order, question How to define DTD without strict element order could be useful.
Wish it helpful.

Changing entry point class based on form factor

Im looking to load a different user interface in my GWT application if the user is accessing from a mobile web browser or desktop web browser. I was wondering how I would edit my Application.gwt.xml file change which entry point class is loaded based on the the form factor. I thought it might be something along these lines but i'm kind of just hacking so I was wondering if anyone had any ideas?
<entry-point class="webapp.client.WebAppEntryPoint">
<when-property-is name="formfactor" value="desktop"/>
</entry-point>
<entry-point class="webapp.client.MobileAppEntryPoint">
<when-property-is name="formfactor" value="mobile"/>
</entry-point>
Cheers.
Its almost as easy as you describe it -- that is, once you have worked out the formfactor property and how to pick a value for it.
It turns out that when you create an entrypoint and declare it in your module, the compiler uses GWT.create to actually make an instance of it. This leaves it subject to the rebind rules declared in your module. So if both WebAppEntryPoint and MobileAppEntryPoint inherit from some common superclass, you can declare that entrypoint in the module, and a slight varient on the rules you made to trigger them to be selected:
<entry-point class="webapp.client.AbstractAppEntryPoint" />
<replace-with class="webapp.client.WebAppEntryPoint">
<when-type-is class="webapp.client.AbstractAppEntryPoint" />
<when-property-is name="formfactor" value="desktop"/>
</entry-point>
<replace-with class="webapp.client.MobileAppEntryPoint">
<when-type-is class="webapp.client.AbstractAppEntryPoint" />
<when-property-is name="formfactor" value="mobile"/>
</entry-point>
These rules state: "When GWT tries to start the app, use AbstractEntryPoint (which implements EntryPoint) to do so. When someone invokes GWT.create(AbstractEntryPoint) and formfactor is desktop, give them a WebAppEntryPoint instance. When someone invokes GWT.create(AbstractEntryPoint) and formfactor is mobil, give them a MobileAppEntryPoint instance.
This then leaves the hard part - how do you build the formfactor property, define the possible values, and let the app pick the right one on startup?
To help answer this, lets look at two standard properties that already existing in GWT - locale and user.agent. Useragent detection is managed in the com.google.gwt.useragent.UserAgent module - properties are defined, a way to select a property is listed, and some helpful 'make sure that this wiring worked' bits are added to the app. Possible locales are started in com.google.gwt.i18n.I18N, but are designed to be extended within your own app. There is lots of extra stuff in here as well, defining how to pick which locale should be activated. We'll want to steal the idea of pre-defining the possible formfactors from user.agent, and will want the idea of reading the right formfactor from the locale code.
First, define the property.
<define-property name="formfactor" values="desktop, mobile" />
In this example, we'll only allow these two possible values - in reality, you might want desktop (i.e. large and mouse/keyboard), tablet (large and touch), phone (small and touch), or some other variation on this.
Next, decide how to read the right property value. There are two basic ways to do this - via a simple snippet of javascript, written in your module file, and by writing a class that generates JavaScript, based on some configuration settings. I'm going to go with the simplest one first, and let you work out how to actually detect this detail in javascript (update the question or comment if you can clarify further what you have/need/expect):
<!-- borrowing/adapting from
http://code.google.com/p/google-web-toolkit/wiki/ConditionalProperties -->
<property-provider name="formfactor"><![CDATA[
{
var ua = window.navigator.userAgent.toLowerCase();
if (ua.indexOf('android') != -1) { return 'mobile'; }
if (ua.indexOf('iphone') != -1) { return 'mobile'; }
return 'desktop';
}
]]></property-provider>
Again, this goes in the module, and defines some simple JavaScript to pick the value for formfactor - if the useragent contains the string 'android' or 'iphone', activate the mobile value, otherwise activate desktop. This code will be placed in your .nocache.js file, and used to pick the right permutation (with the right entrypoint, as defined above).
Apart from Colin's detailed answer you might have a look at GWT's standard example for mobilewebapp - http://code.google.com/p/google-web-toolkit/source/browse/#svn%2Ftrunk%2Fsamples%2Fmobilewebapp
The example FormFactor.gwt.xml - http://code.google.com/p/google-web-toolkit/source/browse/trunk/samples/mobilewebapp/src/main/java/com/google/gwt/sample/mobilewebapp/FormFactor.gwt.xml
You can use replace with
<replace-with class="webapp.client.MobileAppEntryPoint">
<when-type-is class="webapp.client.WebAppEntryPoint" />
<any>
<when-property-is name="formfactor" value="mobile"/>
</any>
</replace-with>
NOTE :i am not tried with entry point class ..but working fine for some Widget classes
For details refer Gwt differed binding
SOLVED:
Okay, thanks to everyone who replied. I used a little bit of everyones answer to get to the solution! Firstly I followed SSRs and had a look at the example FormFactor.gwt.xml file. I copied this into my project and referred to it in my App.gwt.xml file. I then followed Colins and added the following code to my App.gwt.xml file in order to load a different EntryPoint based upon form factor:
<entry-point class="webapp.client.AbstractEntryPoint" />
<replace-with class="webapp.client.WebAppEntryPoint">
<when-type-is class="webapp.client.AbstractEntryPoint" />
<when-property-is name="formfactor" value="desktop"/>
</replace-with>
<replace-with class="webapp.client.MobileAppEntryPoint">
<when-type-is class="webapp.client.AbstractEntryPoint" />
<when-property-is name="formfactor" value="mobile"/>
</replace-with>

jodd.bean.BeanException: Simple property not found: cId Invalid property: 'TradingCategoryImpl#cId'

I meet the following problem
I am using AlloyUI to implement a portlet in Liferay
with the following code
<liferay-ui:search-container-row
className="com.handysoft.tp.model.TradingCategory"
keyProperty="cId"
modelVar="category">
<liferay-ui:search-container-column-text
name="category-name"
value="<%= category.getCName() %>" />
<liferay-ui:search-container-column-jsp
path="/admin/action.jsp"
align="right" />
</liferay-ui:search-container-row>
Portlet still works but I meet the following error
jodd.bean.BeanException: Simple property not found: cId Invalid property: 'TradingCategoryImpl#cId'
If I change one small section to
<liferay-ui:search-container-column-text
name="category-name"
property="cName" />
The error happen in with both cName and cId. Nothing is appear, could u help me to solve this
FeinesFabi is right. It seems that Liferay Search container doesn't take the property names which has more than 1 capital letters in it.
For ex. if a property is tClassId then it won't work but tclassId will work fine.
I've had the same problem.
Renaming the primary key from gID to glossarId an re-running the service builder fixed it for me. I don't understand why, though.

Does Castle Windsor allow the resolution of value types?

I'm trying to pass a parameter into a component that requires a System.TimeSpan. I'm only able to get the 'long ticks' ctor to resolve.
Here's a snippet of the config file:
<component id="timeInForce" type="System.TimeSpan, mscorlib">
<parameters>
<hours>0</hours>
<minutes>15</minutes>
<seconds>0</seconds>
</parameters>
</component>
<component id="FooSettings" type="Foo.FooSettings, Foo">
<parameters>
<tif>${timeInForce}</tif>
</parameters>
</component>
This is the exception:
Castle.MicroKernel.Handlers.HandlerException : Cant create component 'timeInForce'
as it has dependencies to be satisfied.
timeInForce is waiting for the following dependencies:
Keys (components with specific keys)
- ticks which was not registered.
Passing a tick value for the component parameter works, as in:
<parameters><tif>0</tif></parameters>
but this defeats the purpose.
What's happening (from what I can see) is that the ticks property is being incorrectly identified as a compulsory parameter (because it belongs to the constructor with the least number of arguments) even though all value types have a default parameter-less constructor.
However the constructor candidate matching the most parameters will still be selected even if you supply additional parameters (i.e. ticks) so you can work around this by just including ticks in the list of parameters:
<component id="timeInForce"" type="System.TimeSpan, mscorlib">
<parameters>
<ticks>0</ticks>
<hours>0</hours>
<minutes>15</minutes>
<seconds>0</seconds>
</parameters>
</component>
Here is a quick test to verify it works (which passes for against the castle trunk):
string xml = #"<?xml version=""1.0"" encoding=""utf-8"" ?>
<castle>
<components>
<component id=""timeInForce"" type=""System.TimeSpan, mscorlib"">
<parameters>
<ticks>0</ticks>
<hours>0</hours>
<minutes>15</minutes>
<seconds>0</seconds>
</parameters>
</component>
</components>
</castle>";
WindsorContainer container = new WindsorContainer(
new XmlInterpreter(new StaticContentResource(xml)));
TimeSpan span = container.Resolve<TimeSpan>("timeInForce");
Assert.AreEqual(new TimeSpan(0, 15, 0), span);
However, what I would suggest rather then the approach your using is to implement your own type converter, as discussed in the castle documentation.
That way you could develop your own shorthand form for a timespan i.e. "15m" or "2h15m" or whatever takes your fancy - making your config a little easier to read and maintain and working round the issues you're currently experiencing.