How to access frontEndContext from within PartEditor

View: New views
3 Messages — Rating Filter:   Alert me  

How to access frontEndContext from within PartEditor

by Valerie Nyre :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hello


I created a part editor and want to add the site name to the URL path for building an editing form. 


And am now looking for a way to access frontEndContext from within a PartEditor but cannot figure out how.


When I do this:


        Map objectModel = ContextHelper.getObjectModel(context);

        infomessage = "Keysfound in objectModel = ";
        Iterator it = objectModel.keySet().iterator();
        while (it.hasNext()) {
            Object keyfound = it.next();
            infomessage = infomessage + " / " + keyfound.toString() ;
            infomessage = infomessage + " (" + keyfound.getClass().toString() + ") ";
        }
       
       
       
I get this:

Keysfound in objectModel =
/ org.apache.cocoon.components.CocoonComponentManager (class java.lang.String)
/ httpservletcontext (class java.lang.String)
/ source-resolver (class java.lang.String)
/ context (class java.lang.String)
/ cocoon.flow.context (class java.lang.String)
/ httprequest (class java.lang.String)
/ request (class java.lang.String)
/ response (class java.lang.String)
/ httpresponse (class java.lang.String)



Is the frontEndContext to be found using any of the objects, which are to found in the objectModel... ?


// request = org.apache.cocoon.environment.http.HttpRequest@8c5488
// context = org.apache.cocoon.environment.http.HttpContext@101acff
// cocoon.flow.context = null
// httpservletcontext = ServletContext@104d976{/,file:/usr/local/daisy-2.2/daisywiki/webapp/}
// request = org.apache.cocoon.environment.http.HttpRequest@8c5488





Thank you for any helpful advice.



Valerie Nyre






_______________________________________________
daisy community mailing list
Professional Daisy support: http://outerthought.org/en/services/daisy/support.html
mail to: daisy@...
list information: http://lists.cocoondev.org/mailman/listinfo/daisy

Re: How to access frontEndContext from within PartEditor

by Lou Parisi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is what I am doing in a field editor I created that uses site name.  I assume this same code would work in the part editor.

   private String getSiteName() {

      String siteName= "null";
      try {
         Map objectModel = ContextHelper.getObjectModel(context);                
         HttpRequest request = ( HttpRequest ) objectModel.get("request");
         SiteConf siteConf = WikiHelper.getSiteConf(request);        
         siteName= siteConf.getName();

      } catch (Exception e) {
         logger.error("Exception getting site name in FunctionalAreaFieldEditor.", e);
      }
      logger.info("site name from FunctionalAreaFieldEditor is " + siteName);
      return siteName;
   }

According to this post http://www.nabble.com/How-to-get-collection-for-field-editor-td25285341.html you can also get the site from the document context but I did not immediately see how to get that so the WikiHelper works for me.

Valerie Nyre wrote:
Hello I created a part editor and want to add the site name to the URL path for building an editing form.

Re: How to access frontEndContext from within PartEditor

by Karel Vervaeke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, you can get the frontEndContext via the request.  Like this:

FrontEndContext.get(request).

Other than that, in the editor you can access the site via javascript,
e.g. alert(daisy.site.name);

HTH,
Karel

On Fri, Sep 11, 2009 at 2:55 PM, Lou Parisi<Lou.Parisi@...> wrote:

>
> This is what I am doing in a field editor I created that uses site name.  I
> assume this same code would work in the part editor.
>
>   private String getSiteName() {
>
>      String siteName= "null";
>      try {
>         Map objectModel = ContextHelper.getObjectModel(context);
>         HttpRequest request = ( HttpRequest ) objectModel.get("request");
>         SiteConf siteConf = WikiHelper.getSiteConf(request);
>         siteName= siteConf.getName();
>
>      } catch (Exception e) {
>         logger.error("Exception getting site name in
> FunctionalAreaFieldEditor.", e);
>      }
>      logger.info("site name from FunctionalAreaFieldEditor is " +
> siteName);
>      return siteName;
>   }
>
> According to this post
> http://www.nabble.com/How-to-get-collection-for-field-editor-td25285341.html
> you can also get the site from the document context but I did not
> immediately see how to get that so the WikiHelper works for me.
>
>
> Valerie Nyre wrote:
>>
>>
>> Hello I created a part editor and want to add the site name to the URL
>> path for building an editing form.
>>
>>
>
> --
> View this message in context: http://www.nabble.com/How-to-access-frontEndContext-from-within-PartEditor-tp25396701p25400494.html
> Sent from the Daisy - General mailing list archive at Nabble.com.
>
> _______________________________________________
> daisy community mailing list
> Professional Daisy support: http://outerthought.org/en/services/daisy/support.html
> mail to: daisy@...
> list information: http://lists.cocoondev.org/mailman/listinfo/daisy
>
_______________________________________________
daisy community mailing list
Professional Daisy support: http://outerthought.org/en/services/daisy/support.html
mail to: daisy@...
list information: http://lists.cocoondev.org/mailman/listinfo/daisy