Browser Title

How can you change the browser title.
I am using URL http://pcukrpn1:8080/cisnatural/servlet/StartCISPage?PAGEURL=/cisnatural/NatLogon.html
to start my NJX.
The browser title is as above.
I can pass parameter &POPUPTITLE=This%20is%20a%20new%20title
to the above URL and the title does change but how can this be done ‘in code’ i.e. in StartCISPage or NATLOGON.HTML
or by the adapters generated for NJX.

What about screens that don’t have adapters/pages?

In your question I read 3 cases for which you would like to modify the browser title:

  1. StartCISPage
    Passing the POPUPTITLE as paramter is a good solution for this. You have already done this. What is missing for your use case here?

  2. Natural ADAPTER
    Settin the Browser title from within Natural code can be done in the following way:

2.1) In your layout page add an xcidatadef control. Set dataprop=“mytitleprop”
2.2) Add an adapter listener to the page. This is done via setting the property “adapterlistener” in the natpage control
Example: adapterlisteners=“com.mycompany.MyListener”
2.3) Implement a very small Java Adapter Listener:

class MyListener implements IAdapterListener              
...                                                       
public void init(Adapter adapter){ m_adapter = adapter;}  
...                                                       
public void reactOnInvokePhaseEnd() {    
   if ( m_adapter instanceof IDynamicAccess){                                
     String theTitle = (String)((IDynamicAccess)m_adapter).getPropertyValue("
 mytitleprop");                                                           
     m_adapter.getCISAddons().setBrowserTitle(theTitle);                     
 }         

2.4) At runtime simply apply a corresponding value to your mytitleprop field. The value will be used as Browser title.

  1. No pages/adapters
    Do you mean WEB/IO pages?

Best Regards,
Christine

  1. StartCISPage
    Passing the POPUPTITLE as paramter is a good solution for this. You have already done this. What is missing for your use case here? - The URL could already be hardcoded in places, so wuold need to be changed.

  2. Natural ADAPTER
    Settin the Browser title from within Natural code can be done in the following way:

2.1) In your layout page add an xcidatadef control. Set dataprop=“mytitleprop”
2.2) Add an adapter listener to the page. This is done via setting the property “adapterlistener” in the natpage control
Example: adapterlisteners=“com.mycompany.MyListener”
2.3) Implement a very small Java Adapter Listener:
Code:
class MyListener implements IAdapterListener

public void init(Adapter adapter){ m_adapter = adapter;}

public void reactOnInvokePhaseEnd() {
if ( m_adapter instanceof IDynamicAccess){
String theTitle = (String)((IDynamicAccess)m_adapter).getPropertyValue("
mytitleprop");
m_adapter.getCISAddons().setBrowserTitle(theTitle);
}

2.4) At runtime simply apply a corresponding value to your mytitleprop field. The value will be used as Browser title.

This sounds like a good solution where pages exist. Where and how do you implement the Java Adapter Listener?
Where and how do you give a value to mytitleprop - in Natural adapter?

  1. No pages/adapters
    Do you mean WEB/IO pages? - Yes, I understand that some Natural screens can be NJX’ed but others can remain as they are and still be displayed. How do you influence the browser title for these?

The STARTCISPAGE shows defined Connections. How can I take the chosen connection name and make that the browser title ?

  1. StartCISPage: If the url is hardcoded and should not be changed you could apply a servlet-filter which can add the Parameter. But this is probably only worth the effort if you have many hard-coded urls. It might be simpler to replace them

  2. NATURAL Adapter:
    The value of the “mytitleprop” in the example is set by the NATURALAdapter
    I actually posted nearly the complete adapter listener implementation. Simply create your .java class via copy & paste of the code.
    Then put the corresponding .class file into the \appclasses\classes. For more info please see the Application Designer documentation under cisnatural\cisdocumentation

  3. WEB/ IO Pages: I don’t think it’s currently possible.

Best Regards,
Christine