Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Problem Finding Value from List

  1. #1
    Member
    Join Date
    Feb 2011
    Posts
    33
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default Problem Finding Value from List

    Okay, so here's the setup... I have main.xhtml file that displays four links to the user. These links are categories that determine what category is viewed on the next page. The categories are in a database, and are pulled into a List. I use this list to create the links. Note** I decided to do it this way, so when it's time to add more categories, I can update the database, and not have to create more JSF.** The problem I have is that I cannot figure out how to pass the selected category back to my Java class. Here is what I have for the links...

    HTML Code:
                <h:form>
                    <div id="indexRightColumn">
                        <ui:repeat var="category" value="#{vpsForm.category}">
                            <div class="categoryBox">
                                <h:commandLink action="#{vpsForm.findForward}">
                                    <span class="categoryLabelText">#{category}</span>
                                    <img src="#{initParam.categoryImagePath}#{category}.png"
                                         alt="#{category}" class="categoryImage"/>
                                </h:commandLink>
                            </div>
                        </ui:repeat>
                    </div>
                </h:form>

    I can get all the links to display and function, all I need is a way to set my selctedCategory var in my Java class so I can prepare my next page. Please note I am using JSF here and not Struts. However, if I absolutely have to use the actionForward from Struts, I guess I will. But I'd like to avoid that if at all possible...


    All intelligent thoughts have already been thought;
    what is necessary is only to try to think them again.




  2. #2
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Problem Finding Value from List

    Do NOT post the same question within the forums more than once, as it breaks forum policy.

    Additionally, out of both your posts, you haven't placed it questions under the correct sub-forum, as Java Server Faces is a web framework.

    Original question found here: http://www.javaprogrammingforums.com...html#post57675
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  3. #3
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Problem Finding Value from List

    The above said, Lets see where you're at with this.
    As I'm sure you're aware, JFS relies on correctly built beans, from which it will call the getters or setter appropriately.
    To set a value, you would take input from the user using a textfield, from which you would send the value to the backing bean.

    E.g:
    <h:inputText id="catGuide" value="#{catalogue.location}"/>

    In that above example, If I remember correctly, JSF would assign the text from the textfield to a 'location' variable found in your backing bean, using a method called setLocation().
    Does that answer any queries you have?
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  4. #4
    Member
    Join Date
    Feb 2011
    Posts
    33
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default Re: Problem Finding Value from List

    I do have all the variables being set in a backing bean. Problem is, because the links are being set from a List, I don't think the page knows what link is being clicked (or at least I don't know how to relay that back to the bean.


    All intelligent thoughts have already been thought;
    what is necessary is only to try to think them again.



Similar Threads

  1. Help, Building List & finding min and max
    By Margaret_Girl87 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 30th, 2011, 07:15 PM
  2. Array List Help - Can't find where problem is!!
    By destructobob in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 22nd, 2011, 12:04 AM
  3. Finding min in linked list
    By lieles in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 7th, 2011, 02:06 AM
  4. Linked List problem, please help.
    By Axeander in forum What's Wrong With My Code?
    Replies: 10
    Last Post: December 21st, 2010, 05:01 PM
  5. Problem with adding to a list in a loop
    By aminmusa in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 30th, 2010, 10:13 AM