Gary
Gary

Reputation: 37

jstl c:set to set a bean property results in argument type mismatch

I am trying to use c:set to set a property of my bean. I have a tag at the top of my page like this:

<c:set value="true" target="#{patientChartManager}" property="editingForm" />

The bean field/method is this:

public Boolean getEditingForm() {
    return editingForm;
}


public void setEditingForm(Boolean editingForm) {
    this.editingForm = editingForm;
}

However, when the page attempts to load I get the following exception:

java.lang.IllegalArgumentException: argument type mismatch sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

I have tried changing from a Boolean object to a boolean primative type. Same problem.

But if I change my tag to this, it works:

<c:set value="#{'1' eq '1'}" target="#{patientChartManager}" property="editingForm" />

Really the #{'1' eq '1'} could be any test that results in true.

Ultimately it results in my needs being met, but it feels like a hack and eclipse adds a warning that the test will always result in true.

Thanks!

Upvotes: 0

Views: 5557

Answers (1)

cmbaxter
cmbaxter

Reputation: 35453

Have you tried:

<c:set value="#{true}" target="#{patientChartManager}" property="editingForm" />

Upvotes: 2

Related Questions