0

I'm trying to code a "Facebook-like" posting view with JSF and PrimeFaces.

For example, what I mean is that when you type something in an InputText, if what you have typed is a link, the view displays something, and if not, the view does not display something.

I want to makes my users able to post some text, and if it's a youtube link, display a <p:media> thing.

For now, I have something like this :

<!-- inuput text -->
<h:form>
    <p:inputText value="#{postBean.newPostBody}">
        <f:ajax render=":link" />
    </p:inputText>
</h:form>

<!-- element to display -->
<ui:fragment rendered="#{postBean.getIsALink()}" id="link">
    <h:form>
        <h1>LINK</h1>               
    </h:form>
</ui:fragment>

but it does not works all the time.

I have tried this too :

<h:form id="link_form">
    <h:form rendered="#{postBean.isALink}">
        <h1>LINK</h1>
    </h:form>
    <p:poll interval="1" update="link_form" />
</h:form>

But it seems heavy to me, and it doesn't works better anyway.

My bean's property is like :

private boolean isALink = true;

public boolean getIsALink() {
    isALink = urlCheckerBean.checkUrl(newPostBody);
    return isALink;
}
BalusC
  • 1,040,783
  • 362
  • 3,548
  • 3,513
Ch4BRN
  • 43
  • 4

0 Answers0