Re: Struts setting a String object instead of Integer in the form

Lukasz Lenart <[email protected]>
Newsgroups gmane.comp.jakarta.struts.user
Message-ID <CAMopvkPo7Ccv-+eoKg-qh4AaYZwaPea7xKk8LqiXV+puChdsXQ@mail.gmail.com>
pt., 14 sie 2026 o 22:36 Prasanth <[email protected]> napisał(a):
> Getting the below exception after a form is submitted. The form has a check box, when this check box is not selected we get the exception. If the check box is selected it works normally. Is there
> anything I should be doing to force struts to put a Integer value in the hash map when the check box is not selected?
>
>   Exception: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer (java.lang.String and java.lang.Integer are in module java.base of loader 'bootstrap')
>
>
> The code line where it happens is below
>
>                  else if(getEnrollmentForm().getCapDeferral().get(compID) != null && getEnrollmentForm().getCapDeferral().get(compID)==1) {
>
> Variable Declaration:
>      @Element(value=java.lang.Integer.class)
>      private HashMap<Long, Integer> capDeferral = new HashMap<Long,Integer>();

Can you post the UI, how do you compose the form from tags?


Cheers
Łukasz
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.