PDA

View Full Version : [CLOSED] [beta3] Generics for AppEvent missing in View and Controller



jraue
21 May 2008, 6:00 AM
Hi,

am I wrong or shouldn't the class AppEvent be typized with inherited classes of Object in the definitions of:

protected void View.fireEvent(AppEvent event)
public abstract void Controller.handleEvent(AppEvent event)

Otherwise, it would not be possible to use typization in overridden methods of inherited classes of View and Controller.

Can you pls. confirm?

Thanks,

Joachim

jraue
21 May 2008, 7:14 AM
I think the same holds true for Validator.validate(final Field field, final String value), where Field should support generics in the class Validator.

Orion-
21 May 2008, 7:23 AM
StoreSorter.compare(Store store, ...should probably read
StoreSorter.compare(Store<M> store, ...

darrellmeyer
21 May 2008, 9:50 AM
First, these issues are not bugs. This post belongs in Open Discussion.


am I wrong or shouldn't the class AppEvent be typized with inherited classes of Object in the definitions of:

protected void View.fireEvent(AppEvent event)
public abstract void Controller.handleEvent(AppEvent event)No, you can define your data type in your listener. It does not matter that the event was created without specifying a type.

I think the same holds true for Validator.validate(final Field field, final String value), where Field should support generics in the class Validator.No, the validator validates the raw string value, not the typed value.


StoreSorter.compare(Store store, ...
should probably read StoreSorter.compare(Store<M> store, ...
Yes, I have made the change.

jraue
26 May 2008, 8:58 AM
Darell,

sure, we can continue the thread in Open Discussion. Let's use http://extjs.com/forum/showthread.php?p=173337#post173337 for that.

Frankly, I am not sure I understood your remark on AppEvent. Could you please elaborate on this?

I understand that I can override handleEvent for a non-typized AppEvent argument and then just cast it into a class. However, this would not be the ideal way IMHO and also gives a warning I would like to avoid if possible.

Thanks,
Joachim

darrellmeyer
26 May 2008, 1:51 PM
I think the same holds true for Validator.validate(final Field field, final String value), where Field should support generics in the class Validator.I have changed Validator to use generics:


public interface Validator<Data, F extends Field<Data>> {

/**
* Validates the fields value.
*
* @param field the field
* @param value the value to validate
* @return <code>null</code> if validation passes, otherwise the error
* message
*/
public String validate(F field, String value);

}

Frankly, I am not sure I understood your remark on AppEvent. Could you please elaborate on this?I am not sure I understand what you are asking. handleEvent needs to work with multiple events and data types. It does not make sense to have to pass the data type in the class declaration. Are you suggesting:


public abstract class View<Data> {
protected abstract void handleEvent(AppEvent<Data> event);
}

zaccret
28 May 2008, 10:28 PM
I suggest using wildcard for View and Controller handleEvent method. See http://extjs.com/forum/showthread.php?p=173337

jraue
29 May 2008, 4:00 AM
Darell,

thanks for your reply. No, I was not suggesting the code you provided, but rather wildcards as zaccret proposed, i.e.:

public abstract class View {
protected abstract void handleEvent(AppEvent<?> event);
}

zaccret
12 Jun 2008, 1:24 AM
It has been fixed in Controller class in beta5 but not in View class.

jraue
12 Jun 2008, 5:29 AM
I agree, a fix for View as well would be great. Thanks!

darrellmeyer
12 Jun 2008, 6:52 AM
View is fixed in SVN.

zaccret
12 Jun 2008, 7:18 AM
Thanks for View and for Controller.