You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Vitaly Baranovsky <vi...@gmail.com> on 2007/01/29 16:23:33 UTC

How can I hide portlet programmatically?

Good day!

How can I hide portlet programmatically?

I have portal with "today news" portlet. I need this portlet was hidden if
there is no one news today. So, I need programmatically query database to
check if there are news for today, and hide portlet programmatically if
there no one (with its title and all decoration elements).

How can I do it?

Thanks!
-- 
With best regards,
Vitaly Baranovsky

Re: How can I hide portlet programmatically?

Posted by David Sean Taylor <da...@bluesunrise.com>.
On Feb 6, 2007, at 10:18 AM, Vitaly Baranovsky wrote:

>> this is a change in behavior for Solo mode
> Ups... Ok, I'll reform it.
>
>> why do you want the portlet action bar without the window?
> Because I can't go to Edit mode to edit portlet preferences if portlet
> hasn't an action bar. Usually portlet with no content on my portlal  
> have to
> be hided. And portlet that just was added on the page hasn't content,
> because its preferences are empty.

Well if the action bar is there, to me that constitutes a decorator, no?
Seems like you have two different cases
Try out my slightly modified patch (just checked in) see if it works



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: How can I hide portlet programmatically?

Posted by Vitaly Baranovsky <vi...@gmail.com>.
> this is a change in behavior for Solo mode
Ups... Ok, I'll reform it.

> why do you want the portlet action bar without the window?
Because I can't go to Edit mode to edit portlet preferences if portlet
hasn't an action bar. Usually portlet with no content on my portlal have to
be hided. And portlet that just was added on the page hasn't content,
because its preferences are empty.


2007/2/6, David Sean Taylor <da...@bluesunrise.com>:
>
>
> On Feb 6, 2007, at 9:49 AM, Vitaly Baranovsky wrote:
>
> >
> >  #if (!$solo && !$hidePortlet)
> >    <div class="PTitle" >
> >      <div class="PTitleContent">
> >        #set ($ws=$jetspeed.MappedWindowState)
> >
> >        $!jetspeed.getTitle($jetspeed.getCurrentPortletEntity(), $f)
> >      </div>
> >  #end
> >
> >  #PortletActionBar($decoration)
> >
> this is a change in behavior for Solo mode, and I can't accept it
> why do you want the portlet action bar without the window?
>
> >  #if (!$solo && !$hidePortlet)
> >    </div>
> >  #end
> >
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>


-- 
With best regards,
Vitaly Baranovsky

Re: How can I hide portlet programmatically?

Posted by David Sean Taylor <da...@bluesunrise.com>.
On Feb 6, 2007, at 9:49 AM, Vitaly Baranovsky wrote:

>
>  #if (!$solo && !$hidePortlet)
>    <div class="PTitle" >
>      <div class="PTitleContent">
>        #set ($ws=$jetspeed.MappedWindowState)
>
>        $!jetspeed.getTitle($jetspeed.getCurrentPortletEntity(), $f)
>      </div>
>  #end
>
>  #PortletActionBar($decoration)
>
this is a change in behavior for Solo mode, and I can't accept it
why do you want the portlet action bar without the window?

>  #if (!$solo && !$hidePortlet)
>    </div>
>  #end
>





---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: How can I hide portlet programmatically?

Posted by David Sean Taylor <da...@bluesunrise.com>.
OK, that is dependent on the way we encode and pass through render  
attributes
Since this is a solution for Jetspeed only, I think its acceptable  
although it
does have a maintenance issue of breaking if we change the way we  
name our render parameters

I'll apply a patch by hand to decorator.vm
Watch for a check-in and let me know if it works for you

On Feb 6, 2007, at 9:49 AM, Vitaly Baranovsky wrote:

> I have solved this problem with next solution:
>
> 1) The portlet calls:
>  getPortletRequest().setAttribute("HideDecorator", new Boolean(true))
>
> 2) In webapps/jetspeed/decorations/portlet/decorator.vm I have  
> introduced
> variable $hidePortlet:
>  #set($hidePortlet = $renderRequest.getAttribute("js_${
> jetspeed.CurrentFragment.Id}_HideDecorator"))
>
> 3) After that I use variable $hidePortlet in velocity code of
> decorator.vmthat displays decoration.
>
>
> So, my decorator.vm is:
> #*
> Copyright 2004 The Apache Software Foundation
>
> Licensed under the Apache License, Version 2.0 (the "License");
> you may not use this file except in compliance with the License.
> You may obtain a copy of the License at
>
>    http://www.apache.org/licenses/LICENSE-2.0
>
> Unless required by applicable law or agreed to in writing, software
> distributed under the License is distributed on an "AS IS" BASIS,
> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> See the License for the specific language governing permissions and
> limitations under the License.
> *#
>
> #* ************************* READ ME  
> *************************************
> This is the default template to be used for rendering decorations.   
> If you
> find you cannot accomplish your design requirements by defining a  
> custom
> style sheet for your decoration, you can define your own  
> decorator.vm in
> the root of your decortaion.  This will be used instead of the  
> default.
> ********************************************************************** 
> ** *#
>
> #set($decoration = $f.decoration)
> #set($actions = $decoration.actions)
>
> <!-- Begin: Fragment: ${f.id} Decoration: ${decoratorId} -->
>
> <div id="${f.id}" class="portlet ${decoration.baseCSSClass}">
>  #set($solo = $jetspeed.MappedWindowState.toString()=="solo")
>  #set($hidePortlet = $renderRequest.getAttribute("js_${
> jetspeed.CurrentFragment.Id}_HideDecorator"))
>
>  #if (!$solo && !$hidePortlet)
>    <div class="PTitle" >
>      <div class="PTitleContent">
>        #set ($ws=$jetspeed.MappedWindowState)
>
>        $!jetspeed.getTitle($jetspeed.getCurrentPortletEntity(), $f)
>      </div>
>  #end
>
>  #PortletActionBar($decoration)
>
>  #if (!$solo && !$hidePortlet)
>    </div>
>  #end
>
>  #if (!$jetspeed.isHidden($f) && !$hidePortlet &&
> $jetspeed.WindowState.toString() != "minimized")
>    #if (!$solo)
>      <div class="PContentBorder">
>    #end
>    <div class="PContent">
>
>      $f.renderedContent
>
>   <span style="line-height:0.005px; clear:both;
> display:block">&nbsp;</span>
>    </div>
>    #if (!$solo)
>      </div>
>    #end
>  #end
> </div>
>
> <!-- END: Fragment: ${f.id} Decoration: ${decoratorId} -->
>
>
>
>
> 2007/2/1, David Sean Taylor <da...@bluesunrise.com>:
>>
>>
>> On Jan 30, 2007, at 1:07 PM, Vitaly Baranovsky wrote:
>>
>> >> What I think could be a solution is to set a property on the
>> >> PortletResponse that communicates back to the portal our  
>> instructions
>> >
>> > I have thought about something like this... Can you help me with
>> > name of the
>> > classes and methods that I must to modify in my jetspeed source
>> > code? And
>> > can you give me some suggestions about algorithm of modifications?
>> >
>> > Thank you!
>> >
>>
>> The portlet calls:
>>
>> portletResponse.setAttribute
>> (JetspeedConstants.DISPLAY_PORTLET_DECORATOR, new Boolean(false));
>>
>> Looking at the Jetspeed code, the first thing I noticed is that we do
>> not implement one of the Pluto callback services, the PropertyManager
>> service.
>> So we would need to implement that for starters.
>> From there, you can lookup the properties by portlet window
>> I think the best place to tie this in would be on the LayoutPortlet
>> -- and make a velocity variable for the current decorator being  
>> parsed
>> Seems like a lot of work to go thru just to hide the title bar... but
>> the feature isn't there, so someone needs to do the groundwork
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
>> For additional commands, e-mail: jetspeed-user- 
>> help@portals.apache.org
>>
>>
>
>
> -- 
> With best regards,
> Vitaly Baranovsky

-- 
David Sean Taylor
Bluesunrise Software
david@bluesunrise.com
[office] +01 707 773-4646
[mobile] +01 707 529 9194



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: How can I hide portlet programmatically?

Posted by Vitaly Baranovsky <vi...@gmail.com>.
I have solved this problem with next solution:

1) The portlet calls:
  getPortletRequest().setAttribute("HideDecorator", new Boolean(true))

2) In webapps/jetspeed/decorations/portlet/decorator.vm I have introduced
variable $hidePortlet:
  #set($hidePortlet = $renderRequest.getAttribute("js_${
jetspeed.CurrentFragment.Id}_HideDecorator"))

3) After that I use variable $hidePortlet in velocity code of
decorator.vmthat displays decoration.


So, my decorator.vm is:
 #*
Copyright 2004 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*#

#* ************************* READ ME *************************************
This is the default template to be used for rendering decorations.  If you
find you cannot accomplish your design requirements by defining a custom
style sheet for your decoration, you can define your own decorator.vm in
the root of your decortaion.  This will be used instead of the default.
************************************************************************ *#

#set($decoration = $f.decoration)
#set($actions = $decoration.actions)

<!-- Begin: Fragment: ${f.id} Decoration: ${decoratorId} -->

<div id="${f.id}" class="portlet ${decoration.baseCSSClass}">
  #set($solo = $jetspeed.MappedWindowState.toString()=="solo")
  #set($hidePortlet = $renderRequest.getAttribute("js_${
jetspeed.CurrentFragment.Id}_HideDecorator"))

  #if (!$solo && !$hidePortlet)
    <div class="PTitle" >
      <div class="PTitleContent">
        #set ($ws=$jetspeed.MappedWindowState)

        $!jetspeed.getTitle($jetspeed.getCurrentPortletEntity(), $f)
      </div>
  #end

  #PortletActionBar($decoration)

  #if (!$solo && !$hidePortlet)
    </div>
  #end

  #if (!$jetspeed.isHidden($f) && !$hidePortlet &&
$jetspeed.WindowState.toString() != "minimized")
    #if (!$solo)
      <div class="PContentBorder">
    #end
    <div class="PContent">

      $f.renderedContent

   <span style="line-height:0.005px; clear:both;
display:block">&nbsp;</span>
    </div>
    #if (!$solo)
      </div>
    #end
  #end
</div>

<!-- END: Fragment: ${f.id} Decoration: ${decoratorId} -->




2007/2/1, David Sean Taylor <da...@bluesunrise.com>:
>
>
> On Jan 30, 2007, at 1:07 PM, Vitaly Baranovsky wrote:
>
> >> What I think could be a solution is to set a property on the
> >> PortletResponse that communicates back to the portal our instructions
> >
> > I have thought about something like this... Can you help me with
> > name of the
> > classes and methods that I must to modify in my jetspeed source
> > code? And
> > can you give me some suggestions about algorithm of modifications?
> >
> > Thank you!
> >
>
> The portlet calls:
>
> portletResponse.setAttribute
> (JetspeedConstants.DISPLAY_PORTLET_DECORATOR, new Boolean(false));
>
> Looking at the Jetspeed code, the first thing I noticed is that we do
> not implement one of the Pluto callback services, the PropertyManager
> service.
> So we would need to implement that for starters.
> From there, you can lookup the properties by portlet window
> I think the best place to tie this in would be on the LayoutPortlet
> -- and make a velocity variable for the current decorator being parsed
> Seems like a lot of work to go thru just to hide the title bar... but
> the feature isn't there, so someone needs to do the groundwork
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>


-- 
With best regards,
Vitaly Baranovsky

Re: How can I hide portlet programmatically?

Posted by David Sean Taylor <da...@bluesunrise.com>.
On Jan 30, 2007, at 1:07 PM, Vitaly Baranovsky wrote:

>> What I think could be a solution is to set a property on the
>> PortletResponse that communicates back to the portal our instructions
>
> I have thought about something like this... Can you help me with  
> name of the
> classes and methods that I must to modify in my jetspeed source  
> code? And
> can you give me some suggestions about algorithm of modifications?
>
> Thank you!
>

The portlet calls:

portletResponse.setAttribute 
(JetspeedConstants.DISPLAY_PORTLET_DECORATOR, new Boolean(false));

Looking at the Jetspeed code, the first thing I noticed is that we do  
not implement one of the Pluto callback services, the PropertyManager  
service.
So we would need to implement that for starters.
 From there, you can lookup the properties by portlet window
I think the best place to tie this in would be on the LayoutPortlet  
-- and make a velocity variable for the current decorator being parsed
Seems like a lot of work to go thru just to hide the title bar... but  
the feature isn't there, so someone needs to do the groundwork




---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: How can I hide portlet programmatically?

Posted by Vitaly Baranovsky <vi...@gmail.com>.
> What I think could be a solution is to set a property on the
> PortletResponse that communicates back to the portal our instructions

I have thought about something like this... Can you help me with name of the
classes and methods that I must to modify in my jetspeed source code? And
can you give me some suggestions about algorithm of modifications?

Thank you!

2007/1/30, David Sean Taylor <da...@bluesunrise.com>:
>
>
> On Jan 30, 2007, at 2:40 AM, Vitaly Baranovsky wrote:
>
> >> Will you be making this check in the render or action phase?
> >
> > I will be making this check in render phase. But in RenderResponse
> > interface
> > there is no method SetWindowState. It exists only in ActionResponse
> > interface. So, how can I solve my problem in render phase?
> >
>
> You can't.
> I'm still thinking about this one, but for the 2.1 release I doubt I
> can make time for it
> What I think could be a solution is to set a property on the
> PortletResponse that communicates back to the portal our instructions
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>


-- 
With best regards,
Vitaly Baranovsky

Re: How can I hide portlet programmatically?

Posted by David Sean Taylor <da...@bluesunrise.com>.
On Jan 30, 2007, at 2:40 AM, Vitaly Baranovsky wrote:

>> Will you be making this check in the render or action phase?
>
> I will be making this check in render phase. But in RenderResponse  
> interface
> there is no method SetWindowState. It exists only in ActionResponse
> interface. So, how can I solve my problem in render phase?
>

You can't.
I'm still thinking about this one, but for the 2.1 release I doubt I  
can make time for it
What I think could be a solution is to set a property on the  
PortletResponse that communicates back to the portal our instructions




---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: How can I hide portlet programmatically?

Posted by Vitaly Baranovsky <vi...@gmail.com>.
> Will you be making this check in the render or action phase?

I will be making this check in render phase. But in RenderResponse interface
there is no method SetWindowState. It exists only in ActionResponse
interface. So, how can I solve my problem in render phase?



2007/1/29, David Sean Taylor <da...@bluesunrise.com>:
>
>
> On Jan 29, 2007, at 7:23 AM, Vitaly Baranovsky wrote:
>
> > Good day!
> >
> > How can I hide portlet programmatically?
> >
> > I have portal with "today news" portlet. I need this portlet was
> > hidden if
> > there is no one news today. So, I need programmatically query
> > database to
> > check if there are news for today, and hide portlet
> > programmatically if
> > there no one (with its title and all decoration elements).
> >
> > How can I do it?
> >
> > Thanks!
>
> Making the check for your portlet content is trivial
>
> To hide the portlet decorator, I don't know of any feature off hand
> to do this programmatically
>
> take a look at the default portlet decorator:
>
> #set($solo = $jetspeed.MappedWindowState.toString()=="solo")
> #if (!$solo)
>     ...
>    render title bar
> #end
>
> The portal has the concept of a  "solo" state
> But setting the solo state, say, in a portlet action is not allowed:
>
> response.setWindowState(new WindowState("solo")
>
> Will you be making this check in the render or action phase?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>


-- 
With best regards,
Vitaly Baranovsky

Re: How can I hide portlet programmatically?

Posted by David Sean Taylor <da...@bluesunrise.com>.
On Jan 29, 2007, at 7:23 AM, Vitaly Baranovsky wrote:

> Good day!
>
> How can I hide portlet programmatically?
>
> I have portal with "today news" portlet. I need this portlet was  
> hidden if
> there is no one news today. So, I need programmatically query  
> database to
> check if there are news for today, and hide portlet  
> programmatically if
> there no one (with its title and all decoration elements).
>
> How can I do it?
>
> Thanks!

Making the check for your portlet content is trivial

To hide the portlet decorator, I don't know of any feature off hand  
to do this programmatically

take a look at the default portlet decorator:

#set($solo = $jetspeed.MappedWindowState.toString()=="solo")
#if (!$solo)
     ...
    render title bar
#end

The portal has the concept of a  "solo" state
But setting the solo state, say, in a portlet action is not allowed:

response.setWindowState(new WindowState("solo")

Will you be making this check in the render or action phase?



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org