Popup Question

Friends,

I am trying to get a Pop up window of a view. I have a portlet with 2 views(default.view and target.view).

On default view i have command button. The command button has “custom Script” control as child.

I did as follows on “custom script”

Event = onclick
code = window.open(url)
script params = &Parameter(name=url)
in &Parameter

name =url
value = target.view

I get the pop up with a error messge as follow

"[POP.007.0006] Requested content was not found: “/portlet/t.view”
"

Can anyone tell me whats wrong with my settings?? Thanks in advance

Friends,

I am trying to get a Pop up window of a view. I have a portlet with 2 views(default.view and target.view).

On default view i have command button. The command button has “custom Script” control as child.

I did as follows on “custom script”

Event = onclick
code = window.open(url)
script params = &Parameter(name=url)
in &Parameter

name =url
value = target.view

I get the pop up with a error messge as follow

"[POP.007.0006] Requested content was not found: “/portlet/target.view”
"

Can anyone tell me whats wrong with my settings?? Thanks in advance

Hi Sivaraman,

I believe in window.open(url), You have to provide the entire url i.e., http://.

Regards,
Sunil

Hi Sunil,

I understand, but if that is the case, how can we open a pop window from a portlet?

If you have done so in the past, please provide me some clues…

Thanks in advance

It is probably simpler to use the ‘Portlet URL Script’ control:

See: http://www.ajax-softwareag.com/articles/N7M0TP/DesignerOnlineHelp/caf_portlet_url_script.html

Then just set the ‘formTarget’ property to the name of the frame or window you want the link to open in.

Eric,

Still, something is missing here… I tried with Porlet URL script control as the child of a command button that is on Default.view

Portlet URL script control settings as follows…

Event = onclick
context = href
formatarget = target.view (this is the view on the same portlet )

When i click the button, nothing but page refresh happens…

Shed some lights here…thanks in advance

A couple of points:

  1. you probably don’t want a ‘Command Button’ control unless you are intending to invoke some other action at the same time you are opening the popup window. I’d recommend an ‘Output > Button’ control instead since it has no other side effects.

  2. You probably want context = ‘form’ for the Portlet URL Script.

  3. Make sure you have an ‘Extended Portlet URL’ control in the ‘Portlet URL’ facet of the ‘Portlet URL Script’ control to specify the target view and parameters.

I’m attaching a simple exported CAF project that you could import into your Designer to see a working example.
testapp.zip (14.2 KB)

Eric,

The downloaded file has the name download.php. I could not get the testapp.zip,

Can you please let me know how to get it

Eric,

The downloaded file has the name download.php. I could not get the testapp.zip,

Can you please let me know how to get it , thanks in advance.

Not sure. What browser are you using? When I click the download link in firefox and IE it asks me if I want to open or save the testapp.zip file.

I use IE. It ask me if i want to open or save download.php. Am i missing any permission to download attachments from the post? I don’t know.

In fact, i followed your steps…no luck. So i desparately :smiley: need to see your example…

Can you send the attachment to sivaraman.natarajan@bearingpoint.com please?

Oops! :oops: Sending emails to individuals may be against the forum rules…

Please let me know the other options through which i can get your sample

I see. You must have a different version of IE than me.

You may be able to just use the save option it presents you and change the name of the file to testapp.zip.

Eric,

I followed your sample, and i was able to get the popup with a command button without any issues. But it seems it does not work with a command Link.

My requirement is, i have the custom inbox. When the user clicks the Task id (a command link ) it should open a new window as pop up and display the task details.

I tried to get the pop up from Command Link. I have done the same configurations as i did for the Command Button. However, on clicking the command link, it is not loading the target view , instead it is loading the same window (parent) again as a pop up. I am attaching my CAF project here for your reference

So i am wondering whether or not command link supports popup.

Could you or anyone please weigh in the options here for me please?

Thanks in advance
Pop-upDemo.zip (17.4 KB)

I agree that there does seem to be some bug there that is causing the popup window to load the wrong target view. I will file a new bug report to get it investigated further.

You probably don’t want to use a ‘Command Link’ control anyway unless you are intending to invoke some other action at the same time you are opening the popup window. I’d recommend an ‘Portlet > Portlet Simple Link’ control instead since it has no other side effects.

For example, you could paste something like this into your view:

<control component-type='com.webmethods.caf.faces.component.portleturl.PortletUrlLink' renderer-type='javax.faces.Link'>
  <property name='id' value='portletUrlLink' />
  <property name='onclick' value='window.open("about:blank","popup");' />
  <property name='target' value='popup' />
  <facet name='href'>
    <control component-type='com.webmethods.caf.faces.component.portleturl.ExtendedPortletUrl' renderer-type=''>
      <property name='id' value='extendedPortletUrl1' />
      <property name='targetView' value='/Testportlet/popup.view' />
      <control component-type='com.webmethods.caf.faces.component.portleturl.ExtendedParameter' renderer-type=''>
        <property name='name' value='key' />
        <property name='value' value='10' />
      </control>
    </control>
  </facet>
  <control component-type='javax.faces.HtmlOutputText' renderer-type='javax.faces.Text'>
    <property name='id' value='htmlOutputText1' />
    <property name='value' value='Click here to open a pop up' />
  </control>
</control>

updated_Pop-upDemo.zip (15.7 KB)

Eric,

I tried with Portlet Simple Link, It does NOT work as Pop up, it works as a navigation link.

Actually, i could not use your updated_pop-upDemo because it has some differnt runtime look ups so there are some compilation error occurs.

So created a new portlet application and tried there with simple link and done configuration as you suggested. However, it works as a navigation link …not a pop up.

Is there anything missing here?

Here i am attaching my work with portlet simple link control.

As i said in my previous note, this sample works as a navigation not as a Pop up.

Also, wondering where do we say the target view should be opened as a Pop up?

May be i am missing something, please let me know.
test.zip (15.3 KB)

You are pretty close. It looks to me like you are just missing the ‘target’ property on the ‘Portlet Simple Link’ control to specify the name of the window where the link should be opened.

See: http://ajax-softwareag.com/articles/N7M0TP/DesignerOnlineHelp/caf_portlet_simple_link.html

Eric,

It works, Thanks, but my requirement has not met yet. The Pop up window and the parent (that is the opener of the popup) work as expected when they are invoked with default URL as follows.

http://localhost:8585/portlet/popup_onclick_link___demo?username=Administrator&password=manage&wmp_rt=render&wmp_tc=/portlet/popup_onclick_link___demo&wmp_tv=%2FDemo%2Fdefault.view

When i use this URL, i can open the Popup and when i refresh (by clicking the Browser’s refresh) the parent page(the opener) the parent page refreshes and renders the contents of parent(opener) page without any issues.

But, the situation and output is different when i work with an Alias name for the parent (the opener) page.

I have created an alias for the parent page as follows…

http://bexpus4034932.corp.kpmgconsulting.com:8585/popup?&username=Administrator&password=manage

Here the “popup” is the alias name for the parent page.

When i use this URL, i can open the Popup without any issues. However, After opening the popup window, when i refresh (by clicking the browser’s refresh buton) the parent page, the parent page refreshes and renders the contents of Popup window, which is wiered/strange.

I think, i have explained this case clearly. I must to use an alias for the parent window for my requirement.

Is it a bug with Popup stuff or Alias creation?

I am attaching my sample CAF here, Just create a portlet page and alias for it. Open the Parent with alias name, Click the link to open the Popup and then try to refresh the main/parent page, you will get the contents of popup window on the main page.

Please let me know how to resolve this issue.

Thanks again for feeding inputs…
PopUP_OnClick_Link.zip (17.2 KB)

Interesting. Yes I am able to reproduce that scenario. At this point you should probably open an SR with your findings so the issue can get into the official fix process.

On the other hand, I think I found a way to workaround the issue by using a custom portlet mode. See the attached project. When importing the attached project make sure you are using the ‘Software AG / Existing CAF Project into workspace’ import wizard as that will fix the project to work in your environment. Alternatively, if you have already imported the project you can fix the issues by right-clicking on the project and selecting the ‘CAF Tools > Repair CAF Project’ menu item which should update the project to work in your environment.

These are the steps to use a custom portlet mode:

  1. Open the portlet.xml editor and switch to the ‘Configuration’ tab.
  2. Select the ‘Custom Portlet Modes’ node in the config tree.
  3. Hit the ‘Add…’ button to add a new portlet mode named ‘popup’.
  4. Select the ‘Portlets / Demo / Supports / text/html’ node in the config tree and make sure the new ‘popup’ portlet mode is checked in the ‘Support Declarations’ section.
  5. Select the ‘Portlets / Demo / Init Params’ node in the config tree
  6. Hit the ‘Add…’ button to add a new init param using these settings:
    Name=com.webMethods.caf.faces.portlet.INIT_POPUP
    Value=/Demo/popup.view

When switching portlet modes, the CAF framework uses the ‘com.webMethods.caf.faces.portlet.INIT_[MODE_NAME]’ init param value to determine which page to render.

If you view the portlet.xml source code, it should now look something like this:

	<portlet>
		<portlet-name>Demo</portlet-name>
		<portlet-class>com.webmethods.caf.faces.portlet.FacesPortlet</portlet-class>
		<init-param>
			<name>com.webmethods.caf.faces.portlet.INIT_VIEW</name>
			<value>/Demo/default.view</value>
		</init-param>
		<init-param>
			<name>com.webmethods.caf.faces.portlet.INIT_POPUP</name>
			<value>/Demo/popup.view</value>
		</init-param>
		<supports>
			<mime-type>text/html</mime-type>
			<portlet-mode>view</portlet-mode>
			<portlet-mode>popup</portlet-mode>
		</supports>
...

Now that your portlet supports a custom portlet mode, you can change the link in your UI to use the ‘popup’ portlet mode instead of specifying the ‘Target View’ property. For example, in your ‘Portlet Url’ control, set the ‘Portlet Mode’ property value to ‘popup’ and remove the value of the ‘Target View’ property.

<control component-type='com.webmethods.caf.faces.component.portleturl.PortletUrlLink' renderer-type='javax.faces.Link'>
  <property name='id' value='portletUrlLink' />
  <property name='onclick' value='&#13;&#10;' />
  <property name='target' value='mywindow' />
  <facet name='href'>
    <control component-type='com.webmethods.caf.faces.component.portleturl.ExtendedPortletUrl' renderer-type=''>
      <property name='id' value='extendedPortletUrl' />
      <property name='portletMode' value='popup' />
      <control component-type='com.webmethods.caf.faces.component.portleturl.ExtendedParameter' renderer-type=''>
        <property name='name' value='key' />
        <property name='value' value='10' />
      </control>
    </control>
  </facet>
  <control component-type='javax.faces.HtmlOutputText' renderer-type='javax.faces.Text'>
    <property name='id' value='htmlOutputText' />
    <property name='value' value='Click me to Open the Popup&#13;&#10;' />
  </control>
</control>

If you inspect the link that opens the popup window it should look something like this (notice the wmp_pm=popup param that specifies the portlet mode).

http://localhost:8585/meta/default/popup_onclick_link___demo/0000005373?key=10&wmp_rt=render&wmp_pm=popup&wmp_tc=5373

updated_PopUP_OnClick_Link.zip (15.1 KB)