First, let me explain the structure. I have some JSF Facelets pages, which use a template to provide a common header with dynamically generated menus. Within that template, the menus are generated with the following code:
<ui:repeat var="item" value="#{mainMenuBackingBean.subMenuItemsList}">
<td class="#{item.cssClass}">
<h:outputLink id="submenu_#{item.nameText}" value="#{item.linkPath}" disabled="#{item.disabled}">
#{item.nameText}
</h:outputLink>
</td>
</ui:repeat>
Each individual page has a page backing bean which knows how to set up its menus, and so before the page is rendered the menus are set up with the following code:
<f:event listener="#{specificPageBackingBeanHere.setup}" type="preRenderView"></f:event>
Which calls the setup method in the abstract class that all specific page backing beans extend, which then makes some calls to add the right elements to the mainMenueBackingBean's menu lists. So far this has worked out perfectly for us, and we've had no issues, until now.
On a new page, we have a table with a dynamic layout as implemented with the following piece of code:
<table class="gridall">
<tr>
<td colspan="4" style="text-align: center;"><b>Table Title</td>
</tr>
<tr>
...
column headings here
...
</tr>
<ui:repeat var="item" value="#{outgoingFaxBacking.outgoingList}">
<tr bgcolor="#{item.status.color}">
<td style="text-align: center;" class="itemsTopCell">
<h:commandLink value="#{item.itemNo}" action="#{outgoingFaxBacking.testMe}" >
<f:ajax render=":rightColumn"/>
</h:commandLink>
<br/>
<b>Last: #{item.lastString}</b>
</td>
<td class="itemsTopCell">
#{item.description}
</td>
<td style="text-align: center" class="itemsTopCell">
<h:outputText value="#{item.quantity}">
<f:convertNumber maxFractionDigits="2"/>
</h:outputText>
</td>
<td style="text-align: center;" class="itemsTopCell">
<h:inputHidden id="notFilledNote" value="#{outgoingFaxBacking.notFilledNote}"/>
<h:commandButton action="#{outgoingFaxBacking.markNotFilled(item.id)}" onclick="return(notFilled());" value="Not Filled">
<f:ajax execute="notFilledNote" render="#form"/>
</h:commandButton>
</td>
</tr>
<tr bgcolor="#{item.status.color}">
<h:panelGroup rendered="#{empty item.note}">
<td style="border-top: 1px;" colspan="4">
#{item.sig}
</td>
</h:panelGroup>
<h:panelGroup rendered="#{not empty item.note}">
<td style="border-top: 1px; border-bottom:0px;" colspan="4">
#{item.sig}
</td>
</h:panelGroup>
</tr>
<h:panelGroup rendered="#{not empty item.note}">
<tr bgcolor="#{item.status.color}">
<td colspan="4" style="border-top: 1px;">
#{item.note}
</td>
</tr>
</h:panelGroup>
<tr>
<td style="border: 0px;font-size:2%" colspan="3">
</td>
</tr>
</ui:repeat>
</table>
The page renders perfectly the first time through. The problem is that when you click on either the commandLink or the commandButton in the table (and only this table, no other command element on the page causes this), an error is generated which reads as so:
serverError: class javax.faces.view.facelets.TagAttributeException /WEB-INF/templates/secure.xhtml #130,106 id="submenu_#{item.nameText}": Property 'nameText' not found on type org.ppa.db.serializabledb.FaxItemsContainer
The error location (#130,106) is the menu code I quoted above, but the type of object (FaxItemsContainer) being looked at is used in the dynamic table above, not the menus. After fiddling with this for a bit, and making sure it wasn't an ajax problem, or a ui:include problem, or anything else, we finally changed the var name in the table from "item" to "faxItem" and it appears to work.
So ultimately, my question is I thought that the var name for ui:repeat (and other JSF components) was local in scope, and therefore it shouldn't matter that two ui:repeats on the same page use the same var name; is this not the case? Do ui:repeat tags on the same page really require unique var names?
I'm running Mojarra 2.1.3 on Tomcat 7.
Related
I am facing this problem where when I leave everything blank for inputText, click on the Save button, one of the inputText field will be auto set with 0.000000. I have been looking at this for sometime but I still couldn't figure out what is wrong with it. By right, it should remain blank.
<tr>
<td><p:commandButton type="button"
value="#{msg.cr1002_command_save}" onclick="confirmation.show()"
id="cr1002_command_save" styleClass="commandButton">
</p:commandButton> <p:confirmDialog id="confirmDialog"
message="#{msg.cr1002_prompt_confirm_save}" severity="alert"
widgetVar="confirmation">
<p:commandButton id="confirm" value="OK"
oncomplete="confirmation.hide()"
action="#{pc_Cr1002.doCr1002_command_saveAction}" ajax="false"
styleClass="commandButton" />
<p:commandButton id="decline" value="Cancel"
onclick="confirmation.hide()" type="button"
styleClass="commandButton" />
</p:confirmDialog>
</td>
</tr>
<tr>
<td><h:outputText styleClass="outputText"
id="cr1002_output_sample_value"
value="#{msg.cr1002_output_sample_value}"></h:outputText>
</td>
<td></td>
<td><p:inputText styleClass="inputTextRefresh"
id="cr1002_input_sample_value" onchange="this.form.submit()"
valueChangeListener="#{pc_Cr1002.handleCr1002_input_sample_valueValueChange}"
style="text-align: right"
value="#{pc_Cr1002.w_currency.sample_value}">
<f:convertNumber pattern="##0.000000" />
</p:inputText>
</td>
<td></td>
<td><p:message styleClass="message_200px"
id="cr1002_error_sample_value" for="cr1002_input_sample_value"
display="text"></p:message>
</td>
<td></td>
</tr>
#{pc_Cr1002.w_currency.sample_value}
I suppose your field sample_value is a primitive (float may be) and not a wrapper class (Float)
The default value for primitives on instance level is 0 or 0.0 whereas that of wrapper classes is null.
So, if these assumptions are correct, and changing the data type does not harm you, this might solve your issue.
I have a Composit Component that use Ajax on <p:selectOneButton/>, when Ajax call the actionListener on <p:commandButton/> it calls 10 times then run the method. I think the problem cause by <p:dataGrid/> because when i put my <p:commandButtton/> out of <p:dataGrid/> access , it works normally but when i used it in <p:dataGrid/> The Ajax call actionListener more than once.
Here is the .xhtml:
<table style="width: 100%">
<tr>
<td><p:selectOneButton value="#{inviteRequestManagedBean.filterType}">
<f:selectItem itemLabel="#{inviteRequest_msg.request}" itemValue="request" />
<f:selectItem itemLabel="#{inviteRequest_msg.archive}" itemValue="archive" />
<f:ajax event="change" render="requestDataGrid" />
</p:selectOneButton></td>
</tr>
<tr>
<td><p:dataGrid id="requestDataGrid" var="tBusinessPartnerRequestInfo" value="#{inviteRequestManagedBean.filterBusinessRequest()}" columns="1"
rows="2">
<p:column>
<div>
<table border="0" width="100%">
<tr>
<td><p:graphicImage value="#{tBusinessPartnerRequestInfo.partySender_imageUrl}" /></td>
<td>
<div>
<table border="0" width="100%">
<tr>
<td><h:outputLabel value="#{tBusinessPartnerRequestInfo.requestDate}" /></td>
</tr>
<tr>
<td><h:outputLabel value="#{tBusinessPartnerReques`enter code here`tInfo.partySender_fullName}" /></td>
</tr>
</table>
</div>
</td>
<td><p:commandButton id="acceptCommonButton" value="#{inviteRequest_msg.accept}" process="#this"
actionListener="#{inviteRequestManagedBean.acceptRequest(tBusinessPartnerRequestInfo.id)}">
</p:commandButton></td>
<td><p:commandButton id="noNowCommonButton" value="#{inviteRequest_msg.notnow}"
actionListener="#{inviteRequestManagedBean.notNowRequest(tBusinessPartnerRequestInfo.id)}">
</p:commandButton></td>
</tr>
</table>
</div>
<hr />
</p:column>
</p:dataGrid> <p:panel>
</p:panel></td>
</tr>
</table>
How can i fix this problem?
Thanks.
I think you can use the options partialSubmit and process in your ajax request to process only the necessary information, something like this:
<p:selectOneButton value="#{inviteRequestManagedBean.filterType}">
<f:selectItem itemLabel="#{inviteRequest_msg.request}" itemValue="request" />
<f:selectItem itemLabel="#{inviteRequest_msg.archive}" itemValue="archive" />
<f:ajax event="change" render="requestDataGrid" partialSubmit="true" process="#this" />
</p:selectOneButton>
if this solved your problem you can see more in the primefaces showcase:
Partial submit
Partial process
Hi i am working with js2+ primefaces here is my code to block UI
<table>
<h:form id="main">
<tr>
<p:growl --->
---
<p:dashboard id="board" model="#{adminD.userProfl}" disabled="true">
<p:panel id="adminActivity" header="Admin Activities">
<table id="hor-minimalist-b" >
<tbody>
<tr>
<td>
<h:commandLink action="#{photoValidation.ooDirectory()}" name="submit" type="submit" id="convertPhotos">
<h:outputText value="Convert All Photos in Databse "/>
<f:ajax execute=":main:adminActivity" render=":main:growl"/>
</h:commandLink>
</td>
</tr>
</tbody>
</table>
</p:panel>
</p:dashboard>
<p:blockUI block=":main:board" trigger=":main:convertPhotos">
LOADING<br />
<p:graphicImage value="#{facesContext.externalContext.requestContextPath}/resources/images/ajax-loader.gif"/>
</p:blockUI>
here board is dashboard id main is form id
also implemented managed bean with thread.sleep of 5 seconds
Remove all the :main: prefixes , since all this resides inside the same h:form , there no need to add that main prefix
Use
<p:blockUI block="board" trigger="convertPhotos">
Try changing h:commandLink to p:commandLink:
<p:commandLink actionListener="#{photoValidation.ooDirectory()}" update=":main:growl" id="convertPhotos"><h:outputText value="Convert All Photos in Databse "/></p:commandLink>
Can you try this code?
<p:blockUI block="board" trigger="adminActivity:convertPhotos">
It is only tipp but you can find component element by firebug or another web tool in browser.
Whats the advantage is JSF 2 Panel grid vs an HTML table?
e.g.
<h:panelGrid columns="1">
<h:outputText value="Hello"/>
</h:panelGrid>
vs
<table>
<tr>
<td>
<h:outputText value="Hello"/>
</td>
</tr>
</table>
"h:panelGrid" tag in JSF is used to generate HTML table tags. It places JSF components in rows and columns layout. The Advantage of using it is you do not have to type all those html tags.
For example, here you have to type all these html tags in your coding,
<table>
<tbody>
<tr>
<td>
Enter a Phone number :
</td>
<td>
<h:inputText id="input1" value="#{bean.input1}"
size="20" required="true"
label="Number" >
<f:convertNumber />
</h:inputText>
</td>
<td>
<h:message for="input1" style="color:red" />
</td>
</tr>
</tbody>
</table>
but the same thing can be done using "h:panelGrid" by typing the following,
<h:panelGrid columns="3">
Enter a Phone number :
<h:inputText id="input1" value="#{bean.input1}"
size="20" required="true"
label="Number" >
<f:convertNumber />
</h:inputText>
<h:message for="input1" style="color:red" />
</h:panelGrid>
JSF doc gives more details, and panelGrid has got some limitations too.
It would be very easy to align various panels and your can have JSF form control () within the panel, without much help from UI developer.
One of the limitations with PanelGrid is : It would not be easy to apply CSS styles. You need look for alternate solutions. But with standard html tags it would be easy to apply CSS styles. JSF2 Primefaces gives themes but I could not avoid CSS styles in a real time application development.
But with PanelGrid you can use almost any JSF control that fits in the rendered html of PanelGrid.
I have a jsp page in which I have two radio buttons and a select tag. Now, if the first radio button is clicked than I want to make that select tag disable but I am fail to do this , I have tried using "disabled" property. Following is the code.
Jsp Page
<table align="center">
<s:iterator value="FirstObjectList" status="AuthorTypeStatus">
<tr>
<td>
<s:radio name="radio_SelectedValue" list="{ObjectName}" listKey="ObjectKey" listValue="ObjectName" value="DefaultObject"/>
</td>
</tr>
</s:iterator>
<s:if test="%{#radio_SelectedValue == 'ObjectName1'}">
<s:set name="isSelectDisabled" value="false"/>
</s:if>
<s:else>
<s:set name="isSelectDisabled" value="True"/>
</s:else>
<tr >
<td colspan="2">
Select Parent Discover Lab
</td>
</tr>
<tr>
<td>
<s:select name="select_SelectedValue" headerKey="DefaultObject" headerValue="ParentObject" list="ObjectList" listKey="ObjectListKey" listValue="ObjectListValue" disabled="%{isSelectDiabled}">
<s:iterator value="ObjectList">
</s:iterator>
</s:select>
<s:submit value="Continue">
</s:submit>
</td>
</tr>
All the getter and setter methods are fixed..is this possible without javascript?
I'm a little confused by your code block, but I think I understand what you're aiming for. Something like this should work
<tr>
<td>
<s:radio name="radio_SelectedValue" list="%{radioList}" listKey="ObjectKey" listValue="ObjectName" value="DefaultObject"/>
</td>
</tr>
<s:if test="%{radio_SelectedValue.equals('myChosenValueFromTheList')}">
<s:select name="select_SelectedValue" headerKey="-1" headerValue=" " list="ObjectList" listKey="ObjectList.Key" listValue="ObjectList.Value" />
</s:if><s:else>
<s:select name="select_SelectedValue" headerKey="-1" headerValue=" " list="ObjectList" listKey="ObjectList.Key" listValue="ObjectList.Value" disabled="disabled" />
</s:else>
I'm not sure what you're doing with the iterators with these tags, they handle the list propagation themselves. Simply tell the tag what list to use and struts will populate the tags appropriately. You can then do a conditional based on the value of the radio when the page renders and perform magic on the select tag as shown above.