This is something which can be done in Spring, but not (yet) in Seam. Besides that you're using the Facelets namespace (ui), which supports something like this for the inclusion of page (-parts).
You can have different components.xml in different jars, but I don't think its what you want to do.
Use XML includes/entities. If you don't know how that works, learn XML.
IBM has a nice website about XML and includes, but I repeat its not the same as Spring offers.
P.S. Seam is already complex enough and we hoped we could forget XML a bit. A push in the right direction will keep people interested
It would however be really nice if it was supported in Seam directly since with a growing number of components the components.xml file gets quite messy.
The easiest way I can imagine to achieve this is to allow for XIncludes. This would probably just mean setting a flag for the XML Parser that is used to read in the components.xml file.
I would also like to do this so I tried out include/entity and was not able to get it to work.
My components.xml has:
<!DOCTYPE components [ <!ENTITY components2 SYSTEM "./components2.xml"> ]>
... and I reference the include as
However I get the following error:
Caused by: java.lang.RuntimeException: Can't find schema/DTD reference: C:\jboss-4.2.3.GA\bin\components2.xml at org.jboss.seam.util.XML.getRootElement(XML.java:29) at org.jboss.seam.init.Initialization.initComponentsFromXmlDocument(Initialization.java:227) ... 138 more Caused by: org.dom4j.DocumentException: C:\jboss-4.2.3.GA\bin\components2.xml Nested exception: C:\jboss-4.2.3.GA\bin\components2.xml at org.dom4j.io.SAXReader.read(SAXReader.java:484) at org.dom4j.io.SAXReader.read(SAXReader.java:343) at org.jboss.seam.util.XML.getRootElement(XML.java:24) ... 139 more
It looks as though it is looking from the JBOSS bin directory! Shouldn't it find it at the same location as components.xml since I use
Can anyone recommend the proper way to include?
I tried using <xi:include> and failed.
Spring does it (see below). We need an <import> tag in Seam as well.
An alternate approach is to use one or more occurrences of the <import/> element to load bean definitions from another file (or files). Let's look at a sample:
<beans> <import resource="services.xml"/> <import resource="resources/messageSource.xml"/> <import resource="/resources/themeSource.xml"/> <bean id="bean1" class="..."/> <bean id="bean2" class="..."/> </beans>
In this example, external bean definitions are being loaded from 3 files, services.xml, messageSource.xml, and themeSource.xml. All location paths are considered relative to the definition file doing the importing, so services.xml in this case must be in the same directory or classpath location as the file doing the importing, while messageSource.xml and themeSource.xml must be in a resources location below the location of the importing file. As you can see, a leading slash is actually ignored, but given that these are considered relative paths, it is probably better form not to use the slash at all.
The contents of the files being imported must be fully valid XML bean definition files according to the Schema or DTD, including the top level <beans/> element.
Can the Seam gods weigh in on this? Our project is getting quite large now and component configuration is becoming a headache since components.xml is so large.