Migrating OpenLaszlo application to 5.0: The tag xxx cannot be used as a child of view - migration

I want to know has anyone across a defect like this when upgrading open laszlo.
The tag xxx cannot be used as a child of view
The tag xxx cannot be used as a child of class
Why this error happens? Any Idea?

The error message xxx cannot be used as a child yyy of view simply means that you are using a tag inside a tag, and the child tag is not known. Simple example:
<canvas debug="true">
<view width="100" height="100" bgcolor="red">
<unknown_tag />
</view>
</canvas>
Compiler error message:
class_tag_error.lzx:4:48: The tag 'unknown_tag' cannot be used as a child of view
class_tag_error.lzx:5:20: Unknown tag
I remember that some people had a similar problem when upgrading from 4.0 to 4.2, here is the discussion in the laszlo-dev mailing list. Is the problem caused by a standard OpenLaszlo tag in your code, or by a custom class or tag you have added?
There is a schema file for all classes and tags the OpenLaszlo compiler knows, which can be found in
$LPS_HOME/WEB-INF/lps/schema/build/lfc.xml
If the compiler complains about a built-in LZX tag, you could - as a last resort - check that file if the class definition for that specific tag still exists in the OpenLaszlo version you are using. Here is - for example - the beginning of the class/interface definition for the <view> tag:
<interface extends="node" jsname="LzView" name="view">
<method args="who, self, prop, refView" name="$lzc$getAttributeRelative_dependencies"/>
<method args="who, self" name="$lzc$getBounds_dependencies"/>
<method args="who, self" name="$lzc$getCurrentTime_dependencies"/>
<method args="ignore" name="$lzc$getMouse_dependencies"/>
<method args="who, self" name="$lzc$getTotalTime_dependencies"/>
<method args="ignore" name="$lzc$isMouseOver_dependencies"/>
... (continued)
Although that's definitely not a comfortable way of finding out if a tag still exists.

Related

IFilter with Custom properties

I'm developing a custom filter to my file format. Everything works fine when I use any of system keys from <propkey.h> like PKEY_Search_Contents.
But now I need to have my custom properties to register and use with Windows Search. Imagine:
"SELECT * FROM SystemIndex WHERE scope ='file:C:/' AND Publisher.Item.CustomProperty LIKE '%Test%'"
I saw about Property Handlers and already tested. I used the RecipePropertyHandler project from Windows 7 SDK Samples. And when I searched with this code:
// get a property store for the mp3 file
IPropertyStore* store = NULL;
HRESULT hr = SHGetPropertyStoreFromParsingName(L"SomePath",
NULL, GPS_DEFAULT, __uuidof(IPropertyStore), (void**)&store);
hr = HRESULT_FROM_WIN32(GetLastError());
PROPVARIANT variant;
store->GetValue(PKEY_Microsoft_SampleRecipe_Difficulty, &variant);
//// very important undocumented method
store->Release();
CoUninitialize();
I receive the correct answer.
But I don't understand how to union IFilter with IPropertyStore to create my custom properties. To start my IFilter, I used the example from Windows 7 SDK Samples. I'm doing something like:
chunkValue.SetTextValue(PKEY_SearchContents, filtered.c_str(),CHUNK_TEXT, 1046, 0, 0, CHUNK_EOS);
I didn't found the link anymore anymore but I read a quote of msdn about you can't implement IFilter AND IPropertyStore together. It's that true? Talking in other words, I can't create a custom property?
I saw all links from msdn, like link, link2 or any other.
I can do separate things but I don't know how to union both.
Any ideia how to implement?
EDIT
Im trying yet implement the PropertyHandler. My .propdesc file have this content:
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schemas.microsoft.com/windows/2006/propertydescription"
schemaVersion="1.0">
<propertyDescriptionList publisher="Microsoft" product="SampleRecipe">
<propertyDescription name="Microsoft.SampleRecipe.Difficulty" formatID="{1794C9FE-74A9-497f-9C69-B31F03CE7EF9}" propID="100">
<description>This property indicates the preparation difficulty of a recipe.</description>
<searchInfo inInvertedIndex="true" isColumn="true" />
<typeInfo type="String" multipleValues="false" isViewable="true" />
<labelInfo label="Recipe difficulty" invitationText="Specify recipe difficulty" />
<displayInfo displayType="Enumerated" >
<editControl control="DropList"/>
<enumeratedList>
<enum value="Easy" text="Easy" />
<enum value="Medium" text="Medium" />
<enum value="Hard" text="Hard" />
</enumeratedList>
</displayInfo>
</propertyDescription>
<propertyDescription name="Microsoft.SampleRecipe.Keywords" formatID="{16D19FCB-7654-48AB-8057-DF8E51CC0755}" propID="100">
<description>This property indicates the preparation difficulty of a recipe.</description>
<searchInfo inInvertedIndex="true" isColumn="True"/>
<typeInfo type="String" multipleValues="true" isViewable="true" />
<labelInfo label="Recipe Keywords" invitationText="Specify recipe keyword" />
</propertyDescription>
</propertyDescriptionList>
</schema>
On Windows Properties:
I receive all informations from file... but when I try to search with Windows Search like:
SELECT Microsoft.SampleRecipe.Keywords FROM SystemIndex
Where directory='somedirectory'
I receive all lines empty... Any ideias why?
EDIT
I can see my properties on PropSchema:
I can use my Microsoft.SampleRecipe.DifficultyV2 on my WSSQL Query like:
SELECT Microsoft.SampleRecipe.KeywordsV2 FROM SystemIndex WHERE directory='C:\users\step\documents\rvffilter\'
But all the contents are empty

JSF2 custom component, parameter autocompletion with a local file path

My First Question, after years, thank you all and stackoverflow ;-)
I code a new Component for JSF2 and use it to include other templates.
It works perfectly for me.
<cc:interface>
<cc:attribute name="src" type="java.lang.String" required="true"/>
<cc:attribute name="addOption" type="java.util.List"/>
</cc:interface>
<cc:implementation>
<cc:insertChildren />
<ui:include src="#{BeanAnything.convert(cc.attrs.src, cc.attrs.addOption)}" />
</cc:implementation>
But i cant complete the Parameter src via auto completion in intellij or netbeans with "strg + space" or whatever other will use.
It should be used like the ui:include on src parameter.
Any Ideas ?
That's what I want to achieve only with my own componente gg:include
See Example

How to display data in struts form if object has another object

I'm working on struts 1.3 framework application.
I have one object which I'm setting in request attribute.
request.setAttribute("school",school);
And I'm trying to display that object through <bean:define> tag.
E.g.
School is Value Object
School school;
in school VO object I have another two object
Student student;
Teacher teacher;
And I'm trying to display value of student as well as teacher object
<bean:define id="summary" name="school" />
<bean:define id="StudentSummary" name="summary" property="student"/>
<bean:define id="TeacherSummary" name="summary" property="teacher"/>
And writing this element through tag
<bean:write name="StudentSummary" property="name" />
<bean:write name="StudentSummary" property="class" />
<bean:write name="TeacherSummary" property="name" />
But it is giving
javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE
what would be wrong in the code.
I have never done it using bean tag but you can do it using Expression language(EL). EL, I believe is a more standard way to do things.
Take a look at this previous post. I think it helps Link
I think in your case you can do something along the line of
<c:out value="${school.student.name}"/>
The above statement will print the value of "name", if you have a "name" property in your student object.

What is the suitable replacement for this.__LZtextclip.text in Open laszlo 5.0

I want to know what is the suitable replacement for this line.
this.__LZtextclip.text
I am using this to get the string present in the text node. This works fine in Openlaszlo 3.3 but in 4.9 and 5.0 it's giving a problem
I tried updating it to
this.sprite.__LZtextclip.text
And i am getting an error:
79: Error: Access of possibly undefined property __LZtextclip through a reference with static type LzSprite, in line: Debug.write(this.sprite.__LZtextclip.text);
Any idea why this problem is happening?
If you are trying to access the text content of a text field, why don't you just access the attribute text?
<canvas>
<text name="sample" id="gRead" />
<handler name="oninit">
gRead.setAttribute('text',"HI");
Debug.info(gRead.text);
</handler>
</canvas>
In OpenLaszlo 3.3 there is method getText(), which gives you the same value. Accessing mx.textfield in your code does not work for the DHTML runtime.
Edit: Added information regarding the stripping of HTML tags
The Flash Textfield class flash.text.Textfield provides an API to enable HTML tag content in a Textfield instance. There are two different properties, one called text, the other one htmlText. If you want to directly access the Flash Textfield object of an lz.text instance, it's a property of the display object of the lz.text instance:
// Flash Textfield instance
gRead.getDisplayObject().textfield
// Pure text content
gRead.getDisplayObject().textfield.text
// Formatted text
gRead.getDisplayObject().textfield.htmlText
You should be aware of the fact that Flash automatically adds HTML format to any textstring you set as content. When you do
gRead.setAttribute('text',"HI");
the textfield.htmlText value is
<P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="11" COLOR="#000000" LETTERSPACING="0" KERNING="1">HI</FONT></P>
For the DHTML runtime, the text content is added as the innerHTML of a <div> tag, and there is no standardized API to retrieve the pure text content of a DOM structure for a tag with content. You could write your own function to extract the text content, or use JavaScript functions from existing frameworks - like the jQuery text() function - to achieve the same result for the DHTML runtime.
I guess the reason is that Laszlo started using the Dojo based rich text editor for text input with HTML formatting since OpenLaszlo 4.0 or 4.1.
The best approach to have consistent behavior across runtimes when stripping tags is to do the conversion on the server-side. That's especially needed if you wan to have consistent whitespace treatment in multiline text, since there differences in how browsers treat whitespace. The question how to best strip tags from strings in JavaScript has been answered before on Stackoverflow, e.g. JavaScript: How to strip HTML tags from string?
Here is a cross-runtime example which works in DHTML with Firefox, Chrome, and it should work with IE9+:
<canvas>
<text name="sample" id="gRead" />
<handler name="oninit"><![CDATA[
gRead.setAttribute("text", 'Hello <b>World</b> OL');
Debug.info("gRead.text=" + gRead.text);
if ($dhtml) {
Debug.info(gRead.getDisplayObject().textContent);
} else {
Debug.info(gRead.getDisplayObject().textfield.text);
}
]]></handler>
</canvas>
I found what is the problem. The problem is that i have to declare a variable and have to refer the property from that.
<canvas>
<library>
<text name="sample" id="gRead">
<method name="getTextFrom">
Debug.write("this.text" , this.sprite);
var mx = this.sprite;
Debug.write("this.text" , mx.textfield.text);
</method>
</text>
</library>
<handler name="oninit">
gRead.setAttribute('text',"HI");
gRead.getTextFrom();
</handler>
</canvas>

XML configuration of Zend_Form: child nodes and attributes not always equal?

A set of forms (using Zend_Form) that I have been working on were causing me some headaches trying to figure out what was wrong with my XML configuration, as I kept getting unexpected HTML output for a particular INPUT element. It was supposed to be getting a default value, but nothing appeared.
It appears that the following 2 pieces of XML are not equal when used to instantiate Zend_Form:
Snippet #1:
<form>
<elements>
<test type="hidden">
<options ignore="true" value="foo"/>
</test>
</elements>
</form>
Snippet #2:
<form>
<elements>
<test type="hidden">
<options ignore="true">
<value>foo</value>
</options>
</test>
</elements>
</form>
The type of the element doesn't appear to make a difference, so it doesn't appear to be related to hidden fields.
Is this expected or not?
As it was rather quiet on here, I took a look further into the source code and documentation.
On line 259 of Zend_Config_Xml, the SimpleXMLElement object attributes are converted to a string, resulting in:
options Object of: SimpleXMLElement
#attributes Array [2]
label (string:7) I can't see this because
value (string:21) something happens to this
becoming
options (string:21) something happens to this
So, I hunted through the documentation only to find that "value" is a reserved keyword when used as an attribute in an XML file that is loaded into Zend_Config_Xml:
Example #2 Using Tag Attributes in Zend_Config_Xml
"..Zend_Config_Xml also supports two
additional ways of defining nodes in
the configuration. Both make use of
attributes. Since the extends and the
value attributes are reserved keywords
(the latter one by the second way of
using attributes), they may not be
used..."
Thus, it would appear to be "expected" according to the documentation.
I'm not entirely happy that this is a good idea though, considering "value" is an attribute of form elements.
Don't worry about this. The reserved keywords were moved to their own namespace, and the previous attributes were depricated. In Zend Framework 2.0 the non-namespaced attributes will be removed so you can use them again.