update region with html code

UI Components for JSF
Post Reply
rmemoria
Posts: 6
Joined: 14 Aug 2010, 17:04

14 Aug 2010, 17:19

Hi,

I'm new to PrimeFaces and I got very interested in the capabilities of the framework, so I decided to test it to be replaced by RichFaces in an on-going project using SEAM 2.2 and JSF 1.2 in a JBOSS server. I tried to do something very common, which is updating a region, like that:

Code: Select all

<h:form id="main">
    	Language:
    		<h:selectOneMenu value="#{localeSelector.localeString}">
    			<f:selectItems value="#{localeSelector.supportedLocales}"/>
    		</h:selectOneMenu>
    		<p:commandButton value="Update" action="#{localeSelector.select}" update="@form" />

             <table cellspacing="6" border="0">
             <tr>
                 <td>
                 	#{messages['usuario.conta']}:
                 	<h:inputText value="#{credentials.username}" style="width:120px;" />
                 </td>
             </tr>
             <tr>
                 <td>
                 	#{messages['usuario.password']}:
                 	<h:inputSecret value="#{credentials.password}" style="width:120px;" />
                 </td>
             </tr>
             <tr>
             	<td>
             		<h:selectBooleanCheckbox id="rememberMe" value="#{rememberMe.enabled}"/>
             		#{messages['login.rememberme']}
             	</td>
             </tr> 
             <tr>
                 <td></td>
                 <td><h:commandButton id="btnOk" value="#{messages['form.enter']}" action="#{identity.login}" /></td>
             </tr>
             </table>
        </h:form>
The problem is that, when I click on the Update button, all the html fragments and #{messages} are not rendered back - They are erased from the page, and just the components are rendered back.

Is this the right way to update a region with HTML code? Am I missing something?

Thanks and cheers,
Ricardo

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

14 Aug 2010, 17:41

Hi,

There is a compatibility issue in JSF 1.2 environment.

In JSF 1.2 - PrimeFaces 1.x - RichFaces 3.3, RichFaces viewhandler prevents PrimeFaces to update plain html.

In JSF 2.0 and PrimeFaces 2.x this is not an issue.

rmemoria
Posts: 6
Joined: 14 Aug 2010, 17:04

14 Aug 2010, 19:23

Thanks for the prompt reply,

Now it's working, but I think there is another issue:

The code above is for language selection. If I select a language with accents (like á, for instance) and this message is not enclosed by any tag (div or span) the page is not rendered. In the example bellow, notice that the second line is inside a span tag (<span>#{messages['login.whatsrproj2']}</span>):

Code: Select all

<h:form id="main">
        <span>#{messages['login.whatsrproj2']}</span>
    	Language:
    		<h:selectOneMenu value="#{localeSelector.localeString}">
    			<f:selectItems value="#{localeSelector.supportedLocales}"/>
    			<p:ajax event="change" action="#{localeSelector.select}" update="@form" />
    		</h:selectOneMenu>
			
             <table cellspacing="6" border="0">
             <tr>
                 <td>
                 	#{messages['usuario.conta']}:
                 	<h:inputText value="#{credentials.username}" style="width:120px;" />
                 </td>
             </tr>
             <tr>
                 <td>
                 	#{messages['usuario.password']}:
                 	<h:inputSecret value="#{credentials.password}" style="width:120px;" />
                 </td>
             </tr>
             <tr>
             	<td>
             		<h:selectBooleanCheckbox id="rememberMe" value="#{rememberMe.enabled}"/>
             		#{messages['login.rememberme']}
             	</td>
             </tr> 
             <tr>
                 <td></td>
                 <td><h:commandButton id="btnOk" value="#{messages['form.enter']}" action="#{identity.login}" /></td>
             </tr>
             </table>
        </h:form>
If I remove the span tag, and the #{messages['login.whatsrproj2']} contains chars like á, é, etc, the region is not rendered. It gets blank.

I hope I have helped.

Cheers,
Ricardo

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

15 Aug 2010, 01:37

Hi Ricardo,

Which version of PrimeFaces are you using?

rmemoria
Posts: 6
Joined: 14 Aug 2010, 17:04

15 Aug 2010, 23:32

Hi Optimus,

I downloaded it yesterday. It's

PrimeFaces 1.1

And I'm testing a legacy application using SEAM 2.2 in a JBOSS Server 4.2.3

Thanks,
Ricardo

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 60 guests