1

I have a question. Suppose, i have a menubar the same below:

Menubar

I can use ajax or something else with purpose as : when i click menuitem or submenu on menubar, then name menuitem or menubar will display in p:inputText?

Thank advance.

mr.thien
  • 65
  • 9
  • 1
    Yes you can. But what have you tried? – T3 H40 Oct 15 '15 at 19:25
  • Yes. This is my purpose: when i clicked menuitem or submenu, its name can displayed in field inputText and i can edit it. You can talk with me what should i do? thanks. I really need it. – mr.thien Oct 15 '15 at 19:32
  • 1
    Have a look at my answer, it will point you into the right direction. As you are new to the site (welcome by the way) you should have a read of [how to ask a good question](http://stackoverflow.com/help/how-to-ask). You will find a lot of information on what you need with a simple google search – T3 H40 Oct 15 '15 at 19:35
  • Yes. Thanks for answer. – mr.thien Oct 15 '15 at 19:39
  • No problem. Consider accepting and voting for the question if it was helpful to you – T3 H40 Oct 15 '15 at 19:41
  • @doanvanthien: please unaccept the answer. It is not a correct answer as you can see in the edit. – Kukeltje Oct 16 '15 at 09:54
  • Hi @Kukeltje. Thank you talk to me. – mr.thien Oct 17 '15 at 00:45

1 Answers1

0

DISCLAIMER: This answer is wrong!

This answer overlooked a basic requirement of the asker, he himself did not realize as well. As this answer is marked accepted, it cannot be removed, but its content serves no solution for jsf


This is certainly possible. You can achieve it with jQuery and something like the following example code:

$(document).ready(function() {
    $("menuItem").click(function(event) {
        $("p").text(event.target.text());
    });
});

This is only intendet as pointer to the right direction. Have a look here and here.

Community
  • 1
  • 1
T3 H40
  • 2,326
  • 8
  • 32
  • 43
  • Yes. Thank you. I try making again. – mr.thien Oct 15 '15 at 19:37
  • I have no idea how this solves the problem `p:inputText` renders as an ``, not a `

    `. And there is no `` tag as you use it in the jquery selector. Do you have any JSF knowledge? And what is as remarkable is that the answer is accepted. Since it just can't work. Or is it intended as a 'guideline', then please state so and add what parts of code in the answer should be changed by the OP and why

    – Kukeltje Oct 16 '15 at 08:04
  • You are right. I misunderstood the question of the asker. I would remove my answer, but I can't, as it is marked accepted. I edited it to make my mistake visible, though. I also added a note to the original answer, that notes its original intension as example, not as one to one solution. – T3 H40 Oct 16 '15 at 08:36