You don't give much information. What is the exact text of the
What are the fully-qualified names (FQNs) of the types 'ActionEvent' and
It looks like either 's.getComponent()' isn't returning an
'HtmlCommandNavigationItem' or 'HtmlCommandNavigationItem#getId()' doesn't
return a 'String'.
When I look at
on the off chance that that's the 'HtmlCommandNavigationItem' to which you
refer, I see the documentation for the 'getId()' method goes all the way back to
. It returns 'String'. So I guess the cast to 'HtmlCommandNavigationItem'
Assuming that's correct, and you should have this answer anyway, on what basis
can the algorithm rely that the call to 's.getComponent()' will always return
If you cannot rely on receiving only that type at that point in the code, you
must put in some sort of run-time check to do something reasonable when that
isn't the type.
There's a principle of programming I call "closure" - that any inputs to a
state change will induce a change to a valid state. A program should have
full closure. That means it must be prepared to handle any inputs. You did
not program for full coverage of possible inputs.
For the 'getId()' call, you really don't need the cast to
'HtmlCommandNavigationItem'. 's.getComponent()' is guaranteed to return a
'UIComponent', which in turn has the 'getId()' method, so you could just skip
that troublesome downcast unless it actually serves a purpose.