Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

p:commandLink value does not getting updated. This is frustrating

Posted on 2014-03-31
3
239 Views
Last Modified: 2014-04-02
All,
I am having a series of p:commandLink components. Each one is linked to a bean function. Just for testing purposes, I want to see the link's text getting changed when clicking it as shown in the code below. On the browser the links do not changed when clicked. What is the problem here and what I am not doing right. Please help. This is the design I am expected to implenent in a actual system.



<ui:composition>
 
 
      <table role="region" aria-label="Key Services Portlet"
class="table">
            <tbody>
                  <tr>
                        <td >
                              <p:commandLink
value="#{dataManager.aDataItem1}"
actionListener="#{dataManager.goToClickedLink1()}"/>
                        </td>
                  </tr>
                  <tr>
                        <td >
                              <p:commandLink
value="#{dataManager.aDataItem2}"
actionListener="#{dataManager.goToClickedLink2()}"/>
                        </td>
                  </tr>
                  <tr>
                        <td >
                              <p:commandLink
value="#{dataManager.aDataItem3}"
actionListener="#{dataManager.goToClickedLink3()}"/>
                        </td>
                  </tr>
                  
                  <tr>
                        <td >
                              <p:commandLink value="more"
actionListener="#{dataManager.goToClickedMore()}"/>
                        </td>
                  </tr>
        </tbody>
      </table>
      
</ui:composition>
</html>





 

@ManagedBean(name="DataManager")
@SessionScoped
public class DataManager  {

      private List<String> list;
      private String aDataItem1 = "Employment Opportunity 1";
      private String aDataItem2 = "Employment Opportunity 2";
      private String aDataItem3 = "Employment Opportunity 3";
 
 
      public  DataManager()  {
             
               
      }

      
      
      public String getaDataItem1()
      {
            return aDataItem1;
      }
      
      public void setaDataItem1(String aValue)
      {
             
            aDataItem1 = aValue;
      }
      
      public String getaDataItem2()
      {
            return aDataItem2;
      }
      
      public void setaDataItem2(String aValue)
      {
             
            aDataItem2 = aValue;
      }
      
      public String getaDataItem3()
      {
            return aDataItem3;
      }
      
      public void setaDataItem3(String aValue)
      {
             
            aDataItem3 = aValue;
      }
      
      
      
      public void goToClickedLink1()
      {
            System.out.println("Clicked goToClickedLink1");
            aDataItem3 = "Hello World P";
      }
      
      
      public void goToClickedLink2()
      {
            System.out.println("Clicked goToClickedLink2");
            aDataItem2 = "Hello World Q";
      }
      
      public void goToClickedLink3()
      {
            System.out.println("Clicked goToClickedLink3");
            aDataItem3 = "Hello World R";
      }
      
      public void goToClickedMore()
      {
            System.out.println("Clicked goToClickedMore");
            aDataItem3 = "asjkfdhgsakjhdfkjashfd";
      }
}
0
Comment
Question by:prain
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
mccarl earned 300 total points
ID: 39968498
Looking at the documentation/showcase for Primefaces (I assume that is what you are using, you haven't actually told us), it appears that you may need to tell primefaces what might need to be updated once the actionlistener fires. The example shows the use of the "update" attribute on the p:commandLink element. Try adding this attribute and setting the value to the "id" of a container element. Now I am not sure if you can just add an "id" to your table, of if it specifically needs to be a primefaces component. If adding the id to the table doesn't work, try wrapping the table in a p:panel element with the "id" set to something appropriate and then use that id in the "update" attribute on the p:commandLink's.

ie. something like this...
<ui:composition>
 
  <p:panel id="linkPanel">
      <table role="region" aria-label="Key Services Portlet"
class="table">
            <tbody>
                  <tr>
                        <td >
                              <p:commandLink
value="#{dataManager.aDataItem1}"
actionListener="#{dataManager.goToClickedLink1()}" update="linkPanel"/>
                        </td>
                  </tr>
                  <tr>
                        <td >
                              <p:commandLink
value="#{dataManager.aDataItem2}"
actionListener="#{dataManager.goToClickedLink2()}" update="linkPanel"/>
                        </td>
                  </tr>
                  <tr>
                        <td >
                              <p:commandLink
value="#{dataManager.aDataItem3}"
actionListener="#{dataManager.goToClickedLink3()}" update="linkPanel"/>
                        </td>
                  </tr>
                  
                  <tr>
                        <td >
                              <p:commandLink value="more"
actionListener="#{dataManager.goToClickedMore()}" update="linkPanel"/>
                        </td>
                  </tr>
        </tbody>
      </table>
    </p:panel>
</ui:composition>
</html>

Open in new window

0
 

Author Closing Comment

by:prain
ID: 39969030
PERFECT!!!!
Thank You Very Much. Yes somehow I did not realize that the update property must be set. Phew, coming from ASP.NET background this is different. Thanks again.
0
 
LVL 35

Expert Comment

by:mccarl
ID: 39972071
Your welcome, glad I could help!  :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
bunnyEars challenge 6 137
count8 challlenge 13 168
micro services vs rest web services 16 121
servlet requestdispatcher include and forward differences 1 39
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question