Displaytag - How to pass hidden value in url? - jsp-tags

<display:table name="sessionScope.userInbox" pagesize="5" sort="list" cellspacing="10" cellpadding="5">
<display:column property="aid" title="" class="hidden" />
<display:column property="from" title="From" sortable="true" />
<display:column property="to" title="To" sortable="true" />
<display:column property="msg" title="Message" sortable="true" />
<display:column property="status" title="Status" sortable="true" paramId="aid" paramProperty="aid" href="/MsgSystem/adminread" />
</display:table>
when i click on "status" link then pass "aid" value in url but it is by get method i want to pass hidden in url.

you have added "userInbox"object list to the session scop and try to iterate it using displaytag. This object would be a java bean having getters /setters for properties - (aid,from,to,msg,status)
you need to change
<display:column property="status" title="Status" sortable="true" paramId="aid" paramName="aid" href="/MsgSystem/adminread" />
the returned url for that display column will be like this..
/MsgSystem/adminread?aid=1
more information on this..
http://displaytag.sourceforge.net/11/tut_links.html

Related

one requiredMessage for 2 "h:selectOneMenu"s

I want one requiredmessage for two h:selectOneMenu components, that is when a user submits the form if one of those selects values is not null, the bean method should be called, otherwise(both of them null) : I should tell him to select at least one, is it possible? or do I have to use JS.
Thanks in advance,
I'd use the OmniFaces validateOne validator for this or the validateOneOrMore if filling both is allowed too.
Code example from their site:
<h:form>
<h3>Please fill out only one of two fields</h3>
<o:validateOne id="one" components="foo bar" />
<h:panelGrid columns="3">
<o:outputLabel for="foo" value="Foo" />
<h:inputText id="foo" />
<h:message for="foo" />
<o:outputLabel for="bar" value="Bar" />
<h:inputText id="bar" />
<h:message for="bar" />
<h:panelGroup />
<h:commandButton value="submit">
<f:ajax execute="#form" render="#form" />
</h:commandButton>
<h:panelGroup>
<h:message for="one" />
<h:outputText value="OK!" rendered="#{facesContext.postback and not facesContext.validationFailed}" />
</h:panelGroup>
</h:panelGrid>
</h:form>

GridView inside p:dataScroller

I tried with the following code to create a "Facebook" like GridView. I am sure I am doing something completely wrong here (since I am novice programmer) You people have any idea how I could achieve that? I know DataGrid exists but I wanted to try something that was scrollable:
<p:dataScroller id="profilePhotos"
var="photo"
value="#{searchController.photoModel}"
chunkSize="3"
lazy="true">
<p:panelGrid columns="3">
<f:facet name="loader">
<p:commandLink type="button"
value="load more"
icon="ui-icon-circle-triangle-s" />
</f:facet>
<p:media rendered="#{photo.id ne 0}"
value="imageservlet?id=#{photo.id}" width="400" height="400"
player="quicktime" />
<br />
<p:commandLink value="respond" style="color:blue"
actionListener="#{searchController.buildPhotoComments(photo)}"
update=":viewPhotoFrmId"
oncomplete="PF('viewPhotoDlgWidget').show();" />
<p:commandLink value="delete" style="color:blue"
actionListener="#{imageController.deletePhoto(photo)}"
update="profilePhotos"
rendered="#{photo.account.id eq user.account.id}" />
</p:panelGrid>
</p:dataScroller>
This is the result that contains both images and videos:

<o:massAttribute> affects another components in same <h:panelGrid>

I'm using the new version of OmniFaces 1.8.1, and particullary I start to use the new tag: <o:massAttribute>. Basically, I have the following form with conditionally rendered and disabled fields:
<h:form id="formABMProducto">
<h:panelGrid id="datosProducto" columns="4">
<o:massAttribute name="rendered" value="#{cc.attrs.page != 'baja'}">
<h:outputLabel for="codigo" ... />
<h:inputText id="codigo" ... />
<rich:message for="codigo" />
<h:panelGroup />
</o:massAttribute>
<o:massAttribute name="rendered" value="#{cc.attrs.page eq 'baja'}">
<h:outputLabel for="codigo" .../>
<rich:autocomplete id="codigoProducto" ... />
<rich:message for="codigo" />
<h:panelGroup />
</o:massAttribute>
<o:massAttribute name="disabled" value="#{cc.attrs.disableComponents}">
<h:outputLabel for="nombre" ... />
<h:inputTextarea id="nombre" ... />
<rich:message for="nombre" />
<span />
<h:outputLabel for="descripcion" ... />
<h:inputTextarea id="descripcion" ... />
<rich:message for="descripcion" />
<span />
</o:massAttribute>
<h:outputLabel value="#{msgs['producto.abm.panel.proveedor.tipo']}" for="CmbTipoProveedor"/>
<rich:select id="CmbTipoProveedor" ... />
<rich:message for="CmbTipoProveedor" />
<a4j:commandButton ... />
</h:panelGrid>
</h:form>
However, when I open the page, the third <o:massAttribute> is also disabling another input fields codigo and codigoProducto. I think this isn't the expected behaviour.
Indeed, this was a bug. The <o:massAttribute> got applied on all children of the parent UIComponent instead of only those contained in the tag. It would theoretically have worked when you've wrapped each <o:massAttribute> in its own UIComponent like <h:panelGroup> or so. However, this is clearly not an option in case of a <h:panelGrid> wherein you'd like to put the children each in its own column.
I reproduced your problem, filled issue 51 about this bug and fixed it in the current 2.0 snapshot. Please give it a try and sorry for any inconvenience.

how to put a string value from <h:inputHidden> to a bean property?

I have a simple "register" page built with primefaces tags where user inputs his login, clicks OK and that info is stored in DB via POST request to a bean. Login is saved properly, but there is another one...
I want to store implicit String field which represents user's "role" and is always equal to "Guest". I've tried two different approaches but all of them failed for me:
1)
<h:outputLabel for="login" value="Login" />
<p:inputText required="true" id="login" value="#{userBean.login}"
label="Login" />
<h:inputHidden value="#{userBean.roleName}" id="rolename"
name="Guest" />
<p:commandButton value="OK" update="dataForm" action="#{userBean.create}"
ajax="false">
2)
<h:outputLabel for="login" value="Login" />
<p:inputText required="true" id="login" value="#{userBean.login}"
label="Login" />
<p:commandButton value="OK" update="dataForm" action="#{userBean.create}"
ajax="false">
<f:param id="rolename" value="User" binding="#{userBean.roleName}"/>
</p:commandButton>
could anybody provide an idea for me?
thx.
environment: jdk7, tomcat7, eclipse, primefaces
Use either plain HTML <input type="hidden"> or JSF <f:param> along with a #ManagedProperty.
So, either
<input type="hidden" name="rolename" value="Guest" />
or
<p:commandButton ...>
<f:param name="rolename" value="Guest" />
</p:commandButton>
Either way, they're available as a HTTP request parameter by
#ManagedProperty("#{param.rolename}")
private String rolename; // +getter+setter

How to get parameter values of rich:hashParam

I am trying to pass values to rich:popupPanel with rich:hashParam tag, here is my code
<h:commandLink value="Edit">
<rich:componentControl target="editPanel" operation="show">
<a4j:param noEscape="true" value="event" />
<rich:hashParam>
<a4j:param name="categoryId" value="#{ c.categoryId }" />
<a4j:param name="categoryName" value="#{ c.name }" />
<a4j:param name="categoryParent" value="#{ c.parent }" />
</rich:hashParam>
</rich:componentControl>
And here is my popup panel which user can do something
<rich:popupPanel id="editPanel" autosized="true">
<!-- how to get value of the rich:hashParam? -->
</rich:popupPanel>
I have referred the richfaces document and examples about rich:hashParam to find out how to get values within the rich:popupPanel. But it seems that the document contains few about rich:hashParam and the example is hard coded, not passed by rich:hashParam.
Document : Here
Example : Here
Does anyone have idea about this? Thanks in advance.
Well, I have solved this problem myself. Instead of passing parameters with rich:hashParam, I passed parameters to the popup panel with a4j:param and assign the value to a backing bean property. Then re-render an a4j:outputPanel which displays the parameter values.
<h:form id="editDataForm">
<!-- server do something with the 'categoryId' parameter it gets -->
<a4j:commandLink action="#{ testBackingBean.editData }" value="Edit" render="dataContent" oncomplete="#{rich:component('editPanel')}.show()">
<a4j:param name="data" value="#{ c.categoryId }" assignTo="#{ testBackingBean.categoryId }"/>
</a4j:commandLink>
</h:form>
<!--...-->
<rich:popupPanel id="editPanel">
<a4j:outputPanel id="dataContent" layout="inline">
<h:outputText value="ID:"/>
<h:outputText value="#{ testBackingBean.dataToEdit.categoryId }"/>
</a4j:outputPanel>
</rich:popupPanel>

Resources