Hey Norman,

thanks a lot for your help. But IMHO this xml solution isn't really good 
because:

1. it is not possible to have more than one entity per file (please correct me 
if I'm wrong on that), therefore one would end up with a lot of files just 
containing '/foo.xhmtl', '/bar.xhtml', ...

2. one can't use it in attributes (i.e. "view-id="&home;") because:
org.dom4j.DocumentException: Error on line 30 of document  : The external 
entity reference "&home;" is not permitted in an attribute value. Nested 
exception: The external entity reference "&home;" is not permitted in an 
attribute value.

Therefore I discarded this solution and had a look at the seam sources - and 
came up with the following:

The following method expects the path to the web project on the _filesystem_ 
(like it is returned from '((ServletContext) 
facesContext.getExternalContext().getContext()).getRealPath("")') and returns a 
HashMap containing 'from-outcome' as keys and 'to-view-id' as values read from 
configFiles[] (all dependencies are a few dom4j classes):
private static HashMap<String, String> createViewMap(String realPathPrefix) {
  |     String[] configFiles = {
  |                     "WEB-INF" + File.separator + "faces-config.xml",
  |                     "WEB-INF" + File.separator + "navigation.xml" };
  |     HashMap<String, String> map = new HashMap<String, String>();
  |     for (int i = 0; i < configFiles.length; i++) {
  |             Document doc = null;
  |             File file = null;
  |             try {
  |                     file = new File(realPathPrefix + File.separator + 
configFiles[ i ]);
  |                     doc = new SAXReader().read(file);
  |             } catch (DocumentException e) {
  |                     System.out.println("Can't read navigation rules from 
file: " + file.getAbsolutePath());
  |                     continue;
  |             }
  |             Element rootElement = doc.getRootElement();
  |             Iterator rootIterator = rootElement
  |                             .elementIterator("navigation-rule");
  |             while (rootIterator.hasNext()) {
  |                     Element element = (Element) rootIterator.next();
  |                     if (element.element("from-view-id") == null
  |                                     || 
element.element("from-view-id").getText().equals("*")) {
  |                             Element navigationCase = 
element.element("navigation-case");
  |                             
map.put(navigationCase.element("from-outcome").getText(),
  |                                                     
navigationCase.element("to-view-id").getText());
  |                     }
  |             }
  |     }
  |     return map;
  | }
Now all left to do would be to add a check to org.jboss.seam.pageflow.Page.read 
to see if the viewId starts with a / and, if it does not start with a /, 
replace it with the value obtained from the HashMap for said viewId as key.

There's no additional overhead because all necessary stuff can be done on 
initialization.

So could you guys _please_ reconsider your decision and add this to seam?! This 
would be really helpful and I already did almost all necessary work ;)

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3994029#3994029

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3994029
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to