0

I’m new in JavaServer Faces. I have a simply form:

<div id="respond" class="comment-respond">
    <h3 id="reply-title" class="comment-reply-title">#{msgs.leavereply}</h3>
    <h1>#{!forumsBean.activeWithProject}</h1>
    <h:form>
        <h:inputTextarea value="#{forumpostsBean.text}" style="resize:none"/>
        <h:commandButton value="#{msgs.add}" action="#{forumpostsBean.addForumpost}"/>
    </h:form>
</div>

By clicking command button all it’s fine, executes method forumpostsBean.addForumpost.

But when I modify code to this:

<div id="respond" class="comment-respond">
    <h3 id="reply-title" class="comment-reply-title">#{msgs.leavereply}</h3>
    <h1>#{!forumsBean.activeWithProject}</h1>
    <h:form>
        <h:inputTextarea value="#{forumpostsBean.text}" style="resize:none" disabled="#{not forumsBean.active}"/>
        <h:commandButton value="#{msgs.add}" action="#{forumpostsBean.addForumpost}" disabled="#{not forumsBean.active}"/>
    </h:form>
</div>

When items not disabled, current page only have refreshed, but method forumpostsBean.addForumpost don’t executes.

In both variants, <h1>#{!forumsBean.activeWithProject}</h1> shows correct value.

user2783755
  • 578
  • 2
  • 10
  • 26

1 Answers1

0

You have 2 beans? one called forumpostsBean and another just forumsBean? I can't see if you've got them both but maybe its the main error? as the comment above says, maybe your logic is out of place.

You may want to use rendered="" on the button rather that just disabling it so its not part of the dom at all upon page load and then use an ajax call when you type data in your input field to do partial ajax render the div again and show it. good for testing.

VeenarM
  • 1,263
  • 1
  • 10
  • 14