Closed tmulle closed 2 years ago
I managed a workaround by creating a Template extension which simply reverses the boolean value.
This works:
{#text name="name" value=orgForm.name label=i18n:['label.orgName'] placeholder="Org Name"
label_class="control-label form-label f-required"
input_class="form-control input-sm"
disabled=canEdit.not()
/}
Template Extension:
import io.quarkus.qute.TemplateExtension;
@TemplateExtension
public class JavaExtensions {
public static boolean not(boolean value) {
return !value;
}
}
Yeah, this is another case of https://github.com/quarkusio/quarkus/issues/13106 I'm afraid. Please comment there to let @mkouba know that we want operators in expressions ;)
@tmulle Stef is right that this is not possible at the moment. Your workaround is fine, but maybe negate
would be a better name of the extension method... and you can skip the parentheses, i.e. use it like disabled=canEdit.negate
.
Hi,
I have a custom tag which build a label and a textfield with a variety of parameters. One of those being the ability to disable the field with the 'disabled' parameter.
I'm getting an error when trying to pass in a boolean and take the opposite of it using the (!) operation. You can see in the error message below that the
canEdit
parameter is included in the list of params available to the template.In my Templates instance I have the method defined as:
public static native TemplateInstance orgEdit(OrgFormData orgForm, Long orgId, boolean canEdit);
If I take out the (!) and just make it
disabled=canEdit
the build succeeds but then my form element is always disabled.So, I'm not sure why it's not working.. any ideas? is the boolean operation (!) supported inside custom tags?
Thanks again!
Template Use:
text.html (Custom Tag)
Error: