0

Im using a especial protocol (SIP) to open a softphone trough my xhtml page using something like this

<h:outputLink value="sip:123456" />

But is destroying my bean, leaving the page useless, is there a workaround for this? any ideas would be apreciated pd:i also trying with primefaces.

UPDATE

What scope is your bean?

Is a viewscope, and i dont have to pass any parameters, this is a special protocol sip: , what it does is that it opens a program called softphone

How would you do this is normal html?

I corrected the title thanks, in normal html would be something like this <a href="sip:3378984" > call </a>

When will your bean be destroyed? When the page is shown or if you click the link? But, you can't click the link because there is no content to render. How do you check the destroyed bean? Which bean?

when i hit the link it goes to my @Predestroy method, and it opens the softphone program (there is no page to show), after i hit the link the page becomes unusuable, like the links, buttons etc, wont work

i also used primefaces commandlink

 <p:commandLink value="prime link" action="#{testBean.redirect()}"/>

 public void redirect() throws IOException {
    ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
    externalContext.redirect("sip:123456");
}
PaulMB
  • 457
  • 1
  • 4
  • 17
  • 2
    What scope is your bean? If you are in a conversation and it's ConversationScoped, you'd have to pass the `cid`-Parameter to the new page via ``. – Martin Höller Nov 17 '16 at 06:48
  • 2
    How would you do this is normal html? And btw, title is talking about commandLink, content about outputLink – Kukeltje Nov 17 '16 at 07:04
  • 1
    PrimeFaces does not have a `h:outputLink` so if fails with that, it is not PF related – Kukeltje Nov 17 '16 at 07:56
  • 1
    When will your bean be destroyed? When the page is shown or if you click the link? But, you can't click the link because there is no content to render. How do you check the destroyed bean? Which bean? – Holger Nov 17 '16 at 08:20
  • 2
    You can try `linktext` Because you are leaving the page and your bean has viewscope, it'll be destroyed. target='_blank' uses a new tab/page to open the link and your page stays unchanged. – Holger Nov 17 '16 at 13:38
  • 1
    or use a ` call ` with a target="_blank" if you want – Kukeltje Nov 17 '16 at 14:24
  • Great i added linktext and worked great but is there a way for not to open a new tab? – PaulMB Nov 17 '16 at 15:59

1 Answers1

0

So after some reasearch and some comments from previous users i created a script to open the new window and close it after some milliseconds

function clicktocallwindowf(number) {
        var wnd = window.open("sip:" + number);
        setTimeout(function () {
            wnd.close();
        }, 10);
        return false;
    }


 <p:commandLink onclick="clicktocallwindowf(#{phonebean.number})"  styleClass="Fs16 icon-phone-1"/>

Hope this helps somebody, thank you guys for the comments it gave me more direction!

PaulMB
  • 457
  • 1
  • 4
  • 17