In wicket 1.4.9 setModelValue("") was accepting string as a parameter, but in 1.5 it need String Array,
I have code as shown below, anybody knows how to modify setModelValue("") to 6.x or 7.x.
if (!onlineVerfStatus) {
TextField captcha = class.getValue("captcha");
captchaDisplayTxt.setModelObject(generateCaptcha());
captcha.clearInput();
captcha.setModelValue("");
return;
}
captcha.setModelValue(new String[] {""});
Related
I have created an extension point, and i am trying to implement that extension in some other plugin. After certain point of time i need to remove that extension in runtime. So currentlt i am using the below to code(Reflection call)
My Code Here :
IExtensionRegistry reg = Platform.getExtensionRegistry();
Field privateStringField = ExtensionRegistry.class.getDeclaredField("masterToken"); //$NON-NLS-1$
privateStringField.setAccessible(true);
Object masterToken = privateStringField.get(reg);
IConfigurationElement[] config = reg.getConfigurationElementsFor("com.temp.rcp.product");
for (IConfigurationElement configElement : config) {
if (configElement.getAttribute("name").equals("Temp")) {
reg.removeExtension(configElement.getDeclaringExtension(), masterToken);
}
}
I looked into the code and found a solution, but this is totally not acceptable, because it could/will break, when i update my eclipse target platform, because of the reflection call.
Can anyone of you help me to solve the above issue.
Is it possible to get the label of my component inside a validation? I need this label for a custom error message in my validation. It looks like:
"The value may not be less than {0}."
If my component has a label then i want to write it before like:
"LabelName: The value may no be less than {0}."
My component BigDecimalValidator doesn't know the BigDecimalTextfield.
tfiGV = new BigDecimalTextField("tfiGV", new Model<BigDecimal>());
tfiGV.setLabel(Model.of(Const_Labels.GV));
tfiGV.add(BigDecimalValidator.minimum(0));
The validatable of BigDecimalValidator can't reach the necessary label.
#Override
public void validate(IValidatable<BigDecimal> validatable) {
// Doesn't work ((FormComponent<BigDecimal>) validatable).getLabel();
if (((BigDecimal) validatable.getValue()).compareTo(BigDecimal.valueOf(minimum, 3)) == -1) {
ValidationError valError = new ValidationError();
valError.setMessage(getErrorMessageMin(minimum));
validatable.error(valError);
}
}
I know that the label can be reached by a constructor for BigDecimalValidator but this isn't a nice solution.
You can use {label} in your i18n message and Wicket will replace it with the form component's label.
E.g. {label}: The value may not be less than {0}.
I'd like to set the background colour of fields and methods (on the first level) according to their visibility modifier in Eclipse.
For example private fields and methods should get a red background, while public fields and methods get a green background:
Is there a way to configure this in Eclipse?
To get this sort of a colored background, you need to use Markers and MarkerAnnotationSpecification. You will find how to use them here: http://cubussapiens.hu/2011/05/custom-markers-and-annotations-the-bright-side-of-eclipse/
As for how to find the private, public fields, you need to use the JDT plugin and the AST parser to parse the Java file and find all the information that you want. I am adding a small code snippet to get you started on this.
ASTParser parser = ASTParser.newParser(AST_LEVEL);
parser.setSource(cmpUnit);
parser.setResolveBindings(true);
CompilationUnit astRoot = (CompilationUnit) parser.createAST(null);
AST ast = astRoot.getAST();
TypeDeclaration javaType = null;
Object type = astRoot.types().get(0);
if (type instanceof TypeDeclaration) {
javaType = ((TypeDeclaration) type);
}
List<FieldDeclarationInfo> fieldDeclarations = new ArrayList<FieldDeclarationInfo>();
// Get the field info
for (FieldDeclaration fieldDeclaration : javaType.getFields()) {
// From this object you can recover all the information that you want about the fields.
}
Here cmpUnit is the ICompilationUnit of the Java File.
I simply need to be able to have a text field and validate if input is a decimal number like 100.00, 0.1, 10.6, etc.
I'm using Drupal 7.
Updated question to indicate 'programatic' solution (using Form API).
You could use #element_validate option for your field and write your own validation function. Maybe you could use is_float() or is_number() in your validation function.
So your code
$form['yourField'] = array(
....
'#element_validate'=>'myValidation'
);
....
function myValidation($element, &$form_state, $form){
if (!is_float( $element['#value']) )){
form_error($element, t('This field is not decimal.'));
}
}
I'm looking for a way to filter files in an "Open" window. I'm using NetBeans IDE 6.5.
I did some research, and this is what i came up with, but for some reason it's not working.
//global variable
protected static FileFilter myfilter;
//in declaration of variables
fchoLoad.setFileFilter(myfilter);
//inside main
myfilter = .... (i actually delted this part by accident, i need to filter only .fwd files. can anybody tell me what goes here?)
If I understand it correctly, you want to create your own file chooser and be able to filter just some files (.fwd in your case). I guess this is more general Java question (not only NetBeans) and I suggest reading this tutorial
Anyway, your "myfilter" should look like this:
myfilter = new FileFilter() {
public boolean accept(File f) {
return f.getName().toLowerCase().endsWith(".fwd")
|| f.isDirectory();
}
public String getDescription() {
return "FWD Files"; //type any description you want to display
}
};
Hope that helps