• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 389
  • Last Modified:

Incompatible Types error

I am using the following piece of code in a JHTML file and getting errors.



<java>
                  Double pInterest = (Double) request.getObjectParameter("element.primaryInterest");

                  switch (pInterest){
                  case 7 :
                  </java>
                        <span class="strong_red"> Test</span>&nbsp;&nbsp;&nbsp;
                  <java>
                        ; break; }
                  


</java>

Error: Error compiling page: /web/gears/whatsnewgear/whatsnewgearshared.jhtml : E:\ATG\ATG2006.3\home\pagebuild\_doc_3\_web\_gears\_whatsnewgear\_whatsnewgearshared.java:149: incompatible types
      found   : java.lang.Double
      required: int


If i change the type to Int as the following

      <java>
                  Int pInterest = (Int) request.getObjectParameter("element.primaryInterest");

                  switch (pInterest){
                  case 7 :
                  </java>
                        <span class="strong_red"> Test</span>&nbsp;&nbsp;&nbsp;
                  <java>
                        ; break; }
                  
                   </java>


Error: Caused by :atg.servlet.pagecompile.AutoCompileException: E:\ATG\ATG2006.3\home\pagebuild\_doc_3\_web\_gears\_whatsnewgear\_whatsnewgearshared.java:147: cannot resolve symbol
      symbol  : class Int
      location: class _doc_3._web._gears._whatsnewgear._whatsnewgearshared._Param_0_output
                        Int pInterest = (Int) request.getObjectParameter("element.primaryInterest");



Would appreciate any help

Thanks
0
qhinds
Asked:
qhinds
1 Solution
 
CEHJCommented:
Should be
 int pInterest = (int) request.getObjectParameter("element.primaryInterest");

Open in new window

0
 
aminabsCommented:
if you are using java 5.x or later you can cast the getObjectParameter result to int just as CEHJ has write,
but to be compatible with older jvms, you can Cast the result to Integer Object and then get its int value:
int pInterest = ((Integer) request.getObjectParameter("element.primaryInterest")).intValue() ;
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now