1 2 Previous Next 17 Replies Latest reply on Jul 13, 2011 2:31 AM by antibrumm.mfrey0.bluewin.ch Go to original post
      • 15. Re: s:convertEntity in h:selectOneMenu produces indexes for option tags only
        antibrumm.mfrey0.bluewin.ch

        I'm sorry but you lost me with the last post. I thought you want to use one select box to create a url with ONE parameter. But on the last post you mention that you want two? Round AND group ? If thats the case you either have to create one value as a concatenated string that the setter method will split correctly into round and group. Like


        param=roundId_groupId



        . Or you use the select box together with jquery not to submit the form but just to create the GET request yourself and you submit the request with js.


        If we are still speaking of ONE single parameter i would go for the entity id as the value of the option and map the select id on the page parameter name.
        Probably you should not even use the jsf lib for that but just render an html select together with a ui:repeat for the options? There you define the id yourself and you have no mapping issue.


        If Im missing something just let me know. I like odd requests because my customer is quite crazy too sometimes :)

        • 16. Re: s:convertEntity in h:selectOneMenu produces indexes for option tags only
          kwutzke

          Martin Frey wrote on Jul 12, 2011 15:45:


          I'm sorry but you lost me with the last post. I thought you want to use one select box to create a url with ONE parameter. But on the last post you mention that you want two? Round AND group ? If thats the case you either have to create one value as a concatenated string that the setter method will split correctly into round and group. Like

          param=roundId_groupId



          ...

          If Im missing something just let me know. I like odd requests because my customer is quite crazy too sometimes :)


          There's nothing odd about what I'm doing. Let me restate:


          I'm on a page that represents a league which has a composite PK:


          http://localhost:8081/bbstats/group-standings.seam?round=54&group=1


          This is the league standings and schedule for that league in season 2001. Now I have a select box to look at previous or future seasons of that same league, so the league's round and group would have to change to


          http://localhost:8081/bbstats/group-standings.seam?round=154&group=1


          for season 2002 or


          http://localhost:8081/bbstats/group-standings.seam?round=254&group=1


          for season 2003. (Due to my laziness I only added 100 to the round IDs for each season.)


          However, because I use a dropdown box for navigation (new HTTP GET), which only supports a single value, I can only get


          http://localhost:8081/bbstats/group-standings.seam?round=1


          or similar, which pages.xml can't handle as we're just going to the same view. You might consider using a dropdown box for navigation unusual or odd, okay :-), but in effect I believe it's something that shouldn't be. After all, other views that use entities with single-column PKs do work with <s:convertEntity /> and that dropdown box, so multi-column PK entities should, too. I'm turning in circles. :-/


          Of course I COULD use links or maybe some other means of navigation, but this time machine dropdown is the most intuitive AAAND it can also be placed into my BREADCRUMB. Okay, now it's really getting odd. ;-) I might post a link here soon for you to look at the result.


          Today I've found a workaround solution to my problem which is based upon a coincidence: the fact that for whatever group I have, previous and future season will keep the group ordinal number constant, which means I only have to submit a new round ID. So I put the constant group ordinal number into a hidden input of the HTML form instead:


          <form method="get" enctype="application/x-www-form-urlencoded">
            <h:selectOneMenu value="#{groupHome.roundId}" id="round" onchange="this.form.submit();">
              <s:selectItems value="#{parallelGroupListQuery.resultList}"
                             var="round"
                             itemValue="#{round.id}"
                             label="Season #{round.season.startYear}/#{(round.season.startYear + 1).toString().substring(2)}"
                             noSelectionLabel="Select Season"
                             hideNoSelectionLabel="true" />
              <!--s:convertEntity /-->
              <!--f:converter converterId="org.jboss.seam.ui.EntityConverter" /-->
              <!--f:converter converterId="groupEntityConverter" /-->
            </h:selectOneMenu>
            <input type="hidden" id="group" name="group" value="#{groupHome.ordinalNbr}" /> <!-- always the same as the current! -->
            ...
          </form>



          However, this won't work as a general-purpose solution for multi-column entities where more than one PK value will change. I'd like to find out, as this will definitely return someday, but I'm really out of gas and I'd probably have to be a Seam expert to solve this.


          Karsten

          • 17. Re: s:convertEntity in h:selectOneMenu produces indexes for option tags only
            antibrumm.mfrey0.bluewin.ch

            Ah I see.


            So you have two problems that are not really related to each other.


            - Html Select box to create multiple page parameters


            - EntityConverter not supporting Composite PK


            For the EntityConverter there is just nothing you can do with the default implementation. I'm currently running always in JPA 1 mode so i never got the issue because it's not supported (as far as i know) and for entities i would never use composite pks anyway. But you can always superseed the default seam components with your own implementation. Just give it the same @Name and use a higher precedence like APPLICATION (in the @Install i think). Then you need a clear algorithm to convert muliple PK values into one string and back to the object.


            This is what my other implementation is doing, just for a single pk: ClassName_PkValue. But i think you can go in the same direction, as long as the order of the pks can be well defined (alphabeticaly sorted attributes resolution probably?)
            Then you map directly the entity in your class with the converter on top and seam will inject the entity found by the converter.


            But then I have never used converters with page parameters. No clue if this is possible.



            And for the select box you need also exactly one value, because it's just not supported :)
            So you will not come around the fact that you need to join up your PKs into one value, as long as you want to use a single html input field. Then i would use jquery on the onchange event to split it correctly and call a get request. Thats a simple an fast implementation if you need this for exactly one case and probably some more work to get a general solution. So you create not a selectbox that is mapping some entities, but just render a select tag with some javascript.


            Marty

            1 2 Previous Next