cannot resolve unit name 'xxxxx' error while using class - delphi-xe8

I am creating a unit Stringy and its type is TStringy = Class. I am then trying to use this class in my form. So in other file.pas, I am trying to use it. While doing uses Stringy; on Stringy I am getting red line error 'Can not resolve unit name 'Stringy'
//TStringy.pas file:
unit Stringy;
interface
type
TStringy = Class
//Code on form that is supposed to use it:
uses Stringy;

I changed my file name to Stringy.pas from TStringy.pas and issue resolved.

Related

Adding annotations with javassist removes previous code

I'm trying to add some annotations to classes while they are loaded.
For that I've wrote a java agent transformer which gets the class bytecode upon loading and can change it.
When I run the following code the new annotation apears on the class but all previous annotation and fields / methods are removed.
CtClass ctClass = classPool.makeClass(new java.io.ByteArrayInputStream(classFileBuffer));
ClassFile classFile = clazz.getClassFile();
ConstPool constPool = classFile.getConstPool();
AnnotationsAttribute attr= new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
javassist.bytecode.annotation.Annotation annotation = new javassist.bytecode.annotation.Annotation(type, constPool);
attr.setAnnotation(annotation);
classFile.addAttribute(attr);
classFileBuffer = ctClass.toBytecode();
Where classFileBuffer is the byte array which is returned to the class loader.
If anyone has an idea why the previous class annotations and code are removed it will be very helpful.
Thanks,
Avner
setAnnotation takes only one parameter which is of type Annotation, and it erases all the others annotations. If you want to add an annotation to the existing ones, use setAnnotations instead. It takes an array of Annotation so you have first to build the array by gathering all the existing annotations (using getAnnotations) then add the Annotation at the end, then call the method.
a setAnnotation(annotation) call is equivalent to setAnnotations(new Annotation[] { annotation })

<table:column> Roo-tag for property of referenced entity

I've got a two classes (pupil, class) in a Roo-project and their scaffolded views.
pupil and class have a 1:1 relationship
In the list.jspx of pupil I'd like to display a column for a property of class.
I don't know the correct attributes to give to the table:column-tag.
This following example gives the error:
SpelEvaluationException: EL1027Epos 4): Indexing into type 'com.pupil' is not supported
<table:table data="${pupil}" duplicate="true" id="l_com_pupil" path="/admin/pupil" z="user-managed">
<table:column id="c_com_pupil_pupilName" property="pupilName" z="user-managed"/>
<!-- I'd like to display the attribute teacher_name of the class 'class' here but it doesn't work -->
<table:column id="c_com_pupil_class_teacherName" property="teacherName" z="user-managed"/>
</table:table>
Instead of messing around with the jspx files, you can simply do this by implementing a converter for the Teacher entity within the ApplicationServiceFactoryBean.java.
See the below conversion method for an example.
static class com.mycompany.test.controllers.ApplicationConversionServiceFactoryBean.TeacherConverter implements org.springframework.core.convert.converter.Converter<com.mycompany.test.domain.master.Teacher, java.lang.String> {
public String convert(Teacher teacher) {
return new StringBuilder().append(teacher.getName()).toString();
}
}
By default, Roo generates these converters and they are stored within the ApplicationConversionServiceFactoryBean_Roo_ConversionService.aj file.
You can push in refactor the related method for the Teacher entity from this aspectJ file into the
ApplicationServiceFactoryBean.java file and then implement your own conversion which will be used to show the Teacher name across the application as in the above example.
Cheers and all the best with Roo!
This is how I did it, not for listing, but rather for showing the name of the teacher when you view the pupil entity:
Edit the controller and specifically the method show (in the java file, not in the aj file, of course).
Add an attribute to your UI Model, for instance "teacherName" (use Model.addAttribute), where you populate the teacherName with the desired name.
Add in the show.jspx file something like:
<div><label for="_pupilTeacher">Teacher Name:</label><div class="box">${teacherName}</div></div><br/>
(alternatively, you could create a new tagx file with your own parameters)
Hope it helped.
Radu

How do I edit the properties of controls made using QTCreator in Slot declaration?

I made a form using QTCreator. Then I change some of its properties in class constructor like
ui->cancelButton->hide();
It work. Now I declare a custom slot in header file & tried to use controls' properties in Slot implementation in class file (i.e .cpp) like
oldName = lineEDit->text();
but I get error msg
error: 'LineEdit' was not declared in this scope
then I tried like
oldName = ui->nameLine->text();
but it gives same error. How do I use controls' properties in Slots declaration or other functions when I made UI using Designer ??
EDIT: SLOT SOURCE
void addressbook::addContact()
{
oldName = ui->nameLine->text(); //nameLine->text();
oldAddress = ui->addressText->toPlainText(); //addressText->toPlainText();
nameLine->clear();
addressText->clear();
updateInterface(AddingMode);
}
if you creating class Test it would produce 4 files:
1) test.h - your class header
2) test.cpp - your implementation
3) test.ui - form descriptor
4) ui_test.h - file generated from form descriptor,
containing cpp code to create it.
test_ui.h has a class declaration inside, with the set of members with types and names of objects you put on form. Ui::TestClass
your main class will have it as private member
private:
Ui::TestClass ui;
so if you want to adress form elements do it as ui->ObjectNameFromForm
And - have a look onto your ui_*.h classes, it is normal cpp code, and after researching them you may understand much more clear how forms works.

How to assign variable as class in Flash Builder 4 Hero SDK

I am trying to assign a variable to a view navigation as follows:
protected function list_clickHandler(event:MouseEvent):void
{
var name1:String = list.selectedItem.vPage;
var name2:Object = list.selectedItem.vPage.valueOf();
navigator.pushView(list.selectedItem.vPage.valueOf(), list.selectedItem);
}
The variable is supposed to be the view for instance it works fine as follows:
navigator.pushView(IM, list.selectedItem);
As the View is presented as a static and not a variable. When you try to submit it as a variable in any format (String, Object) an error occurs.
Error #1034: Type Coercion failed: cannot convert "IM" to Class.
So if anyone has any ideas on how I can send the (View)Class as a variable or if this is a bug in the SDK
No, this is not a bug in the SDK. You pass in a class, and the viewNavigator will construct it for you. If you want to get the the Class of an instance of an object, you can do it like this:
var viewClass = Class(getDefinitionByName(getQualifiedClassName(IM)));
Then, you can pass viewClass into pushView() where it will create a NEW view for you.

Odd getDefinitionByName behaviour - not import related

Searching the web there are hundreds of answers to why getDefinitionByName doesn't work - because the class definition that you are trying to get is not included in the swf.
This is not that problem.
My app is loading a swc at run time, unzipping it, reading the xml and displaying a list of classes that were in that swc. You can then select a class and it will be added to the stage.
When I load the swc and try to use getDefinitionByName I get the following trace:
getting class: com.company.assets:AppFooterShadow
error: Error #1065: Variable assets:AppFooterShadow is not defined.
The com.company is stripped off the beginning!
From code similar to this:
try
{
trace( "getting class: " + definition );
var currentClass : Class = getDefinitionByName( definition ) as Class;
}
catch( e : Error )
{
trace( "error: " + e.message );
}
If I type a class name in a text input box and try to load that it works fine - with exactly the same string being passed to the function.
Anyone got any idea what is going on here? Seems very odd to me.
I can't believe how long I've been staring at this and not seeing what the problem was!
I had typed in this:
com.company.assets.AppFooterShadow
and this was in the list:
com.company.assets:AppFooterShadow
a colon instead of a full stop!
Ok I'll stop talking to myself - please ignore this!

Resources