Link to home
Start Free TrialLog in
Avatar of Absente
Absente

asked on

JSF pass parameter to another form

Hi.

I have a jsf table and table has a column to delete item.

I have 2 form in my pafe.

first form for table.
the second form for tha dialog.

I want to this.

Ehen i clik button where in the datatable, the confirmation dialog show selected rows value.


My page

<h:form>

table

</h:form>

<h:form>

dialog
</h:form>

How can i  pass parameter first form to second form.
I want to do this without refreshing page.

How can i do this ?
Avatar of chaitu chaitu
chaitu chaitu
Flag of India image

if you show you HTML source then i can show you how to pass parameters from one form to another form.right click on the dispLayed HTML page and click view source and paste it here.
Avatar of Absente
Absente

ASKER

<p:panel id="editCategoryPanel"
				rendered="#{userLogin.isAdmin()== true}" align="center"
				style="text-align:center;">
				<h:form id="form">


					<p:dataTable id="categoriesTable" var="cat"
						value="#{Categories.catList}" rowKey="#{cat.id}"
						paginator="true" rows="10" paginatorPosition="bottom" 
						tableStyle="width:100%" selectionMode="single">
						<f:facet name="header">  
           Categories  
        </f:facet>
						<p:column headerText="ID">
							<h:outputText value="#{cat.id}" />
						</p:column>

						<p:column headerText="Year">
							<h:outputText value="#{cat.name}" />
						</p:column>

						<p:column headerText="Manufacturer">
							<h:outputText value="#{cat.description}" />
						</p:column>

						<p:column headerText="Transaction">

							<p:commandButton icon="ui-icon-search" value="Page"
								action="#{Categories.getRetURL(cat)}">

							</p:commandButton>
							<p:commandButton icon="ui-icon-arrowrefresh-1-w" value="Edit">

							</p:commandButton>
							<p:commandButton icon="ui-icon-close" value="Delete"
								onclick="deleteCdlg.show()" action="#{Categories.setSelectedCate(cat)}" update="@parent" >
				 <f:setPropertyActionListener value="#{cat}" target="#{Categories.selectedCat}" />
							</p:commandButton>

						</p:column>

					</p:dataTable>
					<div style="text-align: right; padding-top: 10px;">
						<p:commandButton value="Add Category" icon="ui-icon-search"
							onclick="addCdlg.show()" />
					</div>
				</h:form>
			</p:panel>






<p:outputPanel id="deleteCatOut">
			<p:dialog id="deleteCatdlg" header="Delete Category" modal="true"
				align="center" widgetVar="deleteCdlg" showEffect="explode"
				hideEffect="puff" dynamic="true"
				rendered="#{userLogin.isAdmin()== true}">
				<p:outputPanel id="deleteCatinOut">
				<h:form>
						<div style="padding-bottom: 10px;">
							<h:outputLabel value="Are you sure to delete this">

							</h:outputLabel>
							<h:outputLabel value="#{Categories.selectedCat.name()}">

							</h:outputLabel>
							<h:outputLabel value=" category ?">

							</h:outputLabel>
						</div>
						<p:commandButton value="Cancel" image="ui-icon-arrowrefresh-1-w"
							type="reset" />
						<p:commandButton actionListener="#{Categories.show()}" value="Delete" image="ui-icon-close" type="reset" />
</h:form>
					
				</p:outputPanel>
			</p:dialog>
		</p:outputPanel>

Open in new window



That is the codes.

I want this.
When I clik
this button


<p:commandButton icon="ui-icon-close" value="Delete"
                                                onclick="deleteCdlg.show()" action="#{Categories.setSelectedCate(cat)}" update="@parent" >
                         <f:setPropertyActionListener value="#{cat}" target="#{Categories.selectedCat}" />
                                          </p:commandButton>
from table.

The dialog show selectes row information.
ASKER CERTIFIED SOLUTION
Avatar of chaitu chaitu
chaitu chaitu
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Absente

ASKER

How can I get id at <p:dialog id="deleteCatdlg"....

for example how can i show id in label.

<h:outputLabel value="#{Categories.selectedCat.name()}">

                                          </h:outputLabel>

?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Absente

ASKER

I can set  Value to bean.

<p:commandButton icon="ui-icon-close" value="Delete"
                                                oncomplete="deleteCdlg.show()" update="deleteCatinOut">
                                                <f:setPropertyActionListener value="#{cat}"
                                                      target="#{Categories.selectedCat}" />
                                          </p:commandButton>

but I can not show selected value in opened dialog.


<p:outputPanel id="deleteCatOut">
                  <p:dialog id="deleteCatdlg" header="Delete Category" modal="true"
                        align="center" widgetVar="deleteCdlg" showEffect="explode"
                        hideEffect="puff" dynamic="true"
                        rendered="#{userLogin.isAdmin()== true}">
                        <p:outputPanel id="deleteCatinOut">
                              <h:form>
                                    <div style="padding-bottom: 10px;">
                                          <h:outputLabel value="Are you sure to delete this">

                                          </h:outputLabel>
                                          <h:outputLabel value="#{Categories.selectedCat.name}">

                                          </h:outputLabel>
                                          <h:outputLabel value=" category ?">

                                          </h:outputLabel>
                                    </div>
                                    <p:commandButton value="Cancel" image="ui-icon-arrowrefresh-1-w"
                                          type="reset" />
                                    <p:commandButton actionListener="#{Categories.show()}"
                                          value="Delete" image="ui-icon-close" type="reset" />
                              </h:form>

                        </p:outputPanel>
                  </p:dialog>
            </p:outputPanel>
----

This actions will be in same page without refreshing page.
Avatar of Absente

ASKER

Thanks