Results 1 to 7 of 7

Thread: render fragment

Hybrid View

  1. #1
    Join Date
    Feb 2011
    Posts
    19

    Default render fragment

    Hi all

    I need to render the error as a fragment in flow. what do i need to update in the jsp so that only the error div get updated.

    do i need to make any ajax type calls or spring automatically takes care of that, if i use render fragments inside the flow.

    Thanks
    Thomas

  2. #2
    Join Date
    Dec 2010
    Posts
    175

    Default

    Let me know if following code from web flow sample is of help to you? Or if you are looking for something else?

    Code:
    	<ui:fragment id="hotelSearchFragment">
    		<div id="hotelSearch" class="section">
    		    <span class="errors">
    		       <h:messages globalOnly="true" />
    		    </span>
    			<h2>Search Hotels</h2>
    			<h:form id="mainForm">
    				<fieldset>
    					<div class="field">
    						<div class="label">
    							<h:outputLabel for="searchString">Search String:</h:outputLabel>
    						</div>
    						<div class="input">
    							<sf:clientTextValidator promptMessage="Search hotels by name, address, city, or zip.">
    								<h:inputText id="searchString" value="#{searchCriteria.searchString}" />
    							</sf:clientTextValidator>
    						</div>
    					</div>
    					<div class="field">
    						<div class="label">
    						   	<h:outputLabel for="pageSize">Maximum results:</h:outputLabel>
    						</div>
    						<div class="input">
    							<h:selectOneMenu id="pageSize" value="#{searchCriteria.pageSize}">
    								<f:selectItems value="#{referenceData.pageSizeOptions}" />
    							</h:selectOneMenu>
    				   		</div>
    					</div>
    					<div class="buttonGroup">
    						<sf:commandButton id="findHotels" value="Find Hotels" processIds="*" action="search" />
    					</div>
    			    </fieldset>
    			</h:form>			  
    		</div>
    	</ui:fragment>

  3. #3
    Join Date
    Feb 2011
    Posts
    19

    Default

    Hi

    Thanks for that, I am a bit new to the spring framework. Can you also tell me how the JSP gets updated on submit.Is it refreshing the entire page or just the error fragment. If it is just the fragment how to make the submit and how the server returns the fragment back. ie is it using the submit button or javascript /ajax calls .

    I was thinking

    Code:
    <transition on="find" validate="true">
        		<evaluate expression="searchDirectoryAction.searchDirectory(searchDirectoryForm, flowScope.customer, relationshipCustomer, messageContext)" />
        		<render fragments="searchDirectoryResults"></render>
        	</transition>
    will do it but dont know how to update just this fragment from JSP .

    Thanks
    Thomas

  4. #4
    Join Date
    Nov 2008
    Posts
    742

    Default

    I've typically used SWF with JSF, so my experience is a bit different.

    Rather than rely on other validation patterns, I explicitly called validation methods with the evaluate action within transitions. I had to put my render fragments for the error section at the very top though, above my validation calls, otherwise it wouldn't execute (since failing a validation method would cancel the transition and any successive actions.

    Not quite sure how this works using the validate attribute and other validation patterns,though.

  5. #5
    Join Date
    Feb 2011
    Posts
    19

    Default

    thanks for that , can you paste some code to show how u render fragments.

    All i know is that JSF follows component based paradigm , but fragment rendering should behave same in both i suppose.

    also in your rendering does the entire page is send back or just that fragment. If just the fragment how you update it on the client side.

    cheers
    Thomas

  6. #6
    Join Date
    Nov 2008
    Posts
    742

    Default

    If you're using JSF, you'll need to use the Spring Faces (sf) tags. So either an sf: commandButton, an sf: commandLink, or other tags.

    If you're using Spring MVC, you'll need to use Spring Javascript to decorate your controls.

    You have additional options for other libraries, like Trinidad or Richfaces (check the reference guide).

    In either case, using these special tags or decorations handles making the AJAX call and updating the fragments.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •