Problem with custom widget and dynamic page loading

Hi,
I have a tree used as my app menu, when user clicks a treeItem fires a selectEvent and the java method execute a context.loadView (targetJSP) to load the desired view into my work panel.
This is ok and it works fine but now I've created a new client widget, I've registered the namespace into the bjsf:application node and it works in every page except the ones that are loaded from the tree.
When the page are loaded I get and error:

Reference to undeclared namespace prefix: 'wtw'

As I said, the namespace is declared into the application node.
I've been looking at the response and server returns:
<e:script
     xmlns="http://www.w3.org/1999/xhtml"
     xmlns:xi="http://www.w3.org/2001/XInclude"
     xmlns:b="http://www.backbase.com/2006/btl"
     xmlns:e="http://www.backbase.com/2006/xel" xmlns:c="http://www.backbase.com/2006/command" xmlns:bjsfc="http://www.backbase.com/2007/jsf/client">

<c:create xmlns:b="http://www.backbase.com/2006/btl" xmlns:e="http://www.backbase.com/2006/xel" destination="id('principal')" mode="replaceChildren">


<wtw:wtwImporte id="txtimporte1"></wtw:wtwImporte>

</c:create>
</e:script>

As you can see, the wtw namespace is not declared, how can I declare it?

My page's code is:

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://www.backbase.com/2007/jsf" prefix="bjsf"%>

<f:subview id="importes">
  <bjsf:view>  
    <wtw:wtwImporte id="txtimporte1"></wtw:wtwImporte>
  </bjsf:view>
</f:subview>

Any help will be appreciated.
Thanks in advance.
David

There are two workarounds to

There are two workarounds to this issue that I can think of:
One is to add the namespace of your widget defined on the element itself and the other is to have within the response script a wrapper element around your widget where the namespace would be defined.

Sorry Dimitra, but I don't

Sorry Dimitra, but I don't understand the first one, would you post some code or example to clarify me, please?
In attention to the second one, I've understood that I could wrap the BTL's wtw:wtwImporte component into a JSF component and this component will define the namespace, it isn't?
If don't, could you please give me more info?.

Thank you Dimitra.
David

Well, that is a third solution...

Well, that would be a third solution: to actually have a JSF component wrapping your custom client widget.

You can read how this is done in the example:
http://demo.backbase.com/jsf_tutorials_4_1_2/pages/custom-component/inde...

and you can see the custom component in the page:
http://demo.backbase.com/jsf_tutorials_4_1_2/pages/custom-component/cust...

The example code is delivered in the tutorials.war inside the 4.1.2 JSF Edition package.

But, back to explaining what suggestions 1 and 2 were...

Lets assume you have defined a custom widget in your own client namespace in a element.xml page as follows:

<d:tdl xmlns="http://www.w3.org/1999/xhtml"
xmlns:d="http://www.backbase.com/2006/tdl">

<d:namespace name="http://myCompany.com/">
 <d:element name="myElement">
  <d:template type="application/xhtml+xml">
    <b><d:content /></b>
  </d:template>
  </d:element>
 </d:namespace>
</d:tdl>

In the index.jsp you can write

<bjsf:application skin="system" id="index" nsMap="custom,http://myCompany.com/" >
  <xi:include href="element.xml" />
...
  <custom:myElement>bla</custom:myElement>
</bjsf:application>

and of course you would -as expected- see your custom widget.

So now if you want to dynamically load a subview that would contain this custom widget you can do the following:

Having the widget define its namespace
You could define the namespace on the widget itself (otherwise the xml fragment will not be valid.)

Therefore this was the first suggestion

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://www.backbase.com/2007/jsf" prefix="bjsf" %>  

<f:subview id="myview3">
  <bjsf:view>
        <bjsf:outputText value="hello"/>
       
   <custom:myElement xmlns:custom="http://myCompany.com/">Now it will work</custom:myElement>
       
  </bjsf:view>
</f:subview>

(notice the namespace definition on the widget itself)

Having a wrapper to define its namespace
You can wrap the custom widget with another element in order to define the namespace (less elegant approach though... and quite unecessary)

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://www.backbase.com/2007/jsf" prefix="bjsf" %>  

<f:subview id="myview3">
  <bjsf:view>
        <bjsf:outputText value="hello again"/>
       
   <div xmlns:custom="http://myCompany.com/" >
    <custom:myElement >Also works</custom:myElement>
   </div>
       
  </bjsf:view>
</f:subview>

OK

I really thank you, I didn't knew that I could define the namespace inside a custom component. Maybe it would be a good idea if I could define it inside a JSF component too, because if I use a behavior inside ,for instance, a bjsf:inputText and this page is loaded dynamically the namespace is not found. I can fix this problem with your second solution and wraps it inside a div element but I think that a nsMap attribute would be useful, don't you think?
Thanks again dimitra.
David

I`ve seen the nsMap property

I`ve seen the nsMap property in every jsf component in BB4.2.
Thanks

Kind regards
David