[Logo] OLD FORUM - Use new one: https://www.CaptainCasa.online/forum
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Info: when (NOT!) to call the "ComponentTag.setId()" method  XML
Forum Index -> Development
Author Message
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5555
Offline

Hi,

we just had a problem at customer/user-site: a stack trace on server side was coming up, telling:


Code:
 java.lang.IllegalStateException: Duplicate component ID...
 


The problem was "caused" by the dynamic creation of JSF components and by explicitly assigning the id via setId(). When opening one and the same page first as normal page and afterwards as popup then the error showed up.

Do not call "BaseComponent.setId(...)" if not explicitly required. (The only component which currently requires this is the popup-menu component.)

Just leave out the setId("") - a unique id is created automatically when calling BaseComponentTag.createBaseComponent().

Code:
 CORRECT:
 
 LABELComponentTag lct = new LABELComponentTag();
 lct.setText("...");
 lct.setWidth("...");
 BaseComponent lc = lct.createBaseComponent();
 
 NOT CORRECT:
 
 LABELComponentTag lct = new LABELComponentTag();
 lct.setId("id_hello");
 lct.setText("...");
 lct.setWidth("...");
 BaseComponent lc = lct.createBaseComponent();
 


Björn

Björn Müller, CaptainCasa GmbH
 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team