How to get amx iterator all text box values on Submit Button - oracle-maf

I want to get the all textbox, select box, radio button values on the click of submit button. All the input elements are iterated using amx:iterator. I have shared the amx code below.
The input fields are dynamic based on the response from server.
<?xml version="1.0" encoding="UTF-8" ?>
<amx:view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:amx="http://xmlns.oracle.com/adf/mf/amx"
xmlns:dvtm="http://xmlns.oracle.com/adf/mf/amx/dvt">
<amx:panelPage id="pp1">
<amx:facet name="header">
<amx:outputText value="DynamicPage" id="ot1"/>
</amx:facet>
<amx:commandButton text="commandButton1" id="cb1">
<amx:actionListener id="al1" binding="#{ImageBean.getFormData}"/>
</amx:commandButton>
<amx:outputText value="Question Starts" ></amx:outputText>
<amx:outputText value="Second Question Starts" ></amx:outputText>
<amx:iterator var="row" value="#{bindings.questionCollection3.collectionModel}" id="i1">
<!--<amx:outputText value="#{row.questionList.bindings.qid.inputValue}" id="d85" />-->
<amx:outputText value="#{row.questionList.bindings.qid.inputValue}" />
<amx:outputText value="#{row.questionList.bindings.qtext.inputValue}" rendered="#{row.questionList.bindings.answertype.inputValue == '3' || row.questionList.bindings.answertype.inputValue == '2' || row.questionList.bindings.answertype.inputValue == '1' || row.questionList.bindings.answertype.inputValue == '0'}" id="ot4" />
<amx:inputText inputType="text" disabled="#{row.questionList.bindings.qid.inputValue == '0'}" rendered="#{row.questionList.bindings.answertype.inputValue == '0'}"
value="#{textIterator.txtValue}" valueChangeListener="#{QListBean.getQuestionID}" />
<amx:inputText inputType="text" rendered="#{row.questionList.bindings.answertype.inputValue == '1'}" rows="4" autoCapitalize="auto" />
<amx:selectOneRadio value="#{bindings.optionlist1.inputValue}" rendered="#{row.questionList.bindings.answertype.inputValue == '3'}" id="sor1">
<amx:selectItems value="#{bindings.optionlist1.items}" id="si2"/>
</amx:selectOneRadio>
<amx:selectOneChoice value="#{bindings.optionlist1.inputValue}" rendered="#{row.questionList.bindings.answertype.inputValue == '2'}" id="soc1">
<amx:selectItems value="#{bindings.optionlist1.items}" id="si1"/>
</amx:selectOneChoice>
</amx:iterator>
<amx:commandButton actionListener="#{bindings.getPicture.execute}" text="getPicture"
disabled="#{!bindings.getPicture.enabled}" id="cb2" action="#{ImageBean.getImages}"/>
<amx:panelFormLayout id="pfl1">
<amx:inputText value="#{bindings.quality.inputValue}" label="#{bindings.quality.hints.label}" id="it6"/>
<amx:inputText value="#{bindings.destinationType.inputValue}" label="#{bindings.destinationType.hints.label}"
id="it5"/>
<amx:inputText value="#{bindings.sourceType.inputValue}" label="#{bindings.sourceType.hints.label}" id="it1"/>
<amx:inputText value="#{bindings.allowEdit.inputValue}" label="#{bindings.allowEdit.hints.label}" id="it3"/>
<amx:inputText value="#{bindings.encodingType.inputValue}" label="#{bindings.encodingType.hints.label}" id="it2"/>
<amx:inputText value="#{bindings.targetWidth.inputValue}" label="#{bindings.targetWidth.hints.label}" id="it7"/>
<amx:inputText value="#{bindings.targetHeight.inputValue}" label="#{bindings.targetHeight.hints.label}" id="it4"/>
</amx:panelFormLayout>
<amx:commandButton actionListener="#{bindings.getPicture.execute}" text="getPicture Second"
disabled="#{!bindings.getPicture.enabled}" id="cb3"/>
</amx:panelPage>
</amx:view>
Thanks in Advance.

As per the above given code,
You can use the property <amx:setPropertyListener> in the <amx:commandButton> assign whatever values you want to get to the variable in your corresponding bean class.
eg: <amx:setPropertyListener from="#{row.questionList.bindings.qid.inputValue}" to="#{pageFlowScope.questionId}" type="action">
If you are viewing values from your database,its better to query values from database in your actionListener for better performance.

Related

How to restrict Primefaces inputMask to number and activate the copy and paste

I need to restrict p:inputMask to numbers only and need to activate copy and paste also, this is my code:
<p:inputMask maxlength="18" id="numeroDocumento"
name="numeroDocumento" label="Número de documento"
value="#{dtConsultarInfController.numeroDocumento}"
title="#{pmsg['sif.screen.consultarVerificarInf.label.docNumber']}">
<p:keyFilter regEx="/[\d]/" />
</p:inputMask>
<p:keyFilter for="numeroDocumento" mask="num" preventPaste="false" />
Could somebody help me?
I've added the "onkeypress" to your code, try this now, it will normally restrict typing to numbers only :
<p:inputMask maxlength="18" id="numeroDocumento"
name="numeroDocumento" label="Número de documento"
<p:inputMask maxlength="18" id="numeroDocumento"
name="numeroDocumento" label="Número de documento"
onkeypress="if((event.which < 48 && event.which != 46
&& event.which != 8) || event.which > 57) return false;">
value="#{dtConsultarInfController.numeroDocumento}"
title="#{pmsg['sif.screen.consultarVerificarInf.label.docNumber']}">
<p:keyFilter regEx="/[\d]/" />
</p:inputMask>
<p:keyFilter for="numeroDocumento" mask="num" preventPaste="false" />
value="#{dtConsultarInfController.numeroDocumento}"
title="#{pmsg['sif.screen.consultarVerificarInf.label.docNumber']}">
<p:keyFilter regEx="/[\d]/" />
Thank you very much my friend, your solution admits the dot sign buy I changed the condition on the onkeypress property and it's working successfull!
This is the solution:
<p:inputMask maxlength="18" id="numeroDocumento"
name="numeroDocumento" label="Número de documento"
onkeypress="if((event.which < 48 && event.which != 8) || event.which > 57) return false;" value="# dtConsultarInfController.numeroDocumento}" title="#{pmsg['sif.screen.consultarVerificarInf.label.docNumber']}"></p:inputMask><p:keyFilter for="numeroDocumento" mask="num"preventPaste="false" />

How to convert number using f:convertNumber on JSF form?

I have a input field which takes double can have only one of this pattern:
pattern="#,###,##0.00"
I've done this :
<h:inputText id="value"
required="true"
converterMessage="#{msg.invalidValue}"
requiredMessage="#{msg.required}"
value="#{technicalBean.value}">
<f:convertNumber pattern="#,###,##0.00" />
</h:inputText>
<h:message for="value"/>
But it's not working as I want. It accepts character, if the first input is number like as 8A and converts number only.
If you want to limit user to only type digits and . you can create javascript function and invoke it in onkeypress attribute or do this inline like this
<h:inputText id="value" required="true"
onkeypress="if ((event.which == 8) || (event.which == 46)) return true; if (event.which < 48 || event.which > 57) return false;"
converterMessage="#{msg.invalidValue}"
requiredMessage="#{msg.required}"
value="#{technicalBean.value}">
<f:convertNumber pattern="#,###,##0.00" />
</h:inputText>
<h:message for="value" />
This will allow only digits, . and backspace (numbers are ASCII values for buttons).
If you are open for new framework, PrimeFaces got <p:inputMask> component which you can use for this purpose.

Adding dynamic column using trinidad by clicking on a link in JSF 1.2

<trh:tableLayout width="25%" borderWidth="3" cellSpacing="5"
halign="center" >
<h:commandLink action="#{dataBean.setInitial}" value="ShowView">
</h:commandLink>
<trh:rowLayout shortDesc="head">
<tr:panelHeader size="4" text="Id" />
<tr:forEach var="row" begin="0" end="#{dataBean.size}" items="#{dataBean.dataList}">
<tr:outputText value="#{row.id}" rendered="#{row.editable}"/>
</tr:forEach>
</trh:rowLayout>
<trh:rowLayout>
<tr:panelHeader size="4" text="Name" />
<tr:forEach var="row" begin="0" end="#{dataBean.size}" items="#{dataBean.dataList}">
<tr:outputText value="#{row.text}" rendered="#{row.editable}" />
</tr:forEach>
</trh:rowLayout>
</trh:tableLayout>
I am using trh tags in trinidad to display row wise data ..
and output is like...
Show View
ID 2 1
Name raj Narendra
I want to add a dynamic column in row wise by clicking on link show view..If i click back on show view it should hide that column...Please suggest me how to add rendered attribute and where it should be..
Why don't you use
Something like this:
<tr:commandLink action="#{dataBean.setInitial}" value="ShowView" id="showHideLink"/>
<tr:table value="#{dataBean.dataList}" var="row" id="itemTable" partialTrigger="showHideLink">
<tr:column rendered="#{row.column1Visible}" id="itemCol">
<tr:outputText value="#{row.text1}"/>
</tr:column>
<tr:column rendered="#{row.column2Visible}" id="itemCol">
<tr:outputText value="#{row.text2}"/>
</tr:column>
</tr:table>
In order to get the table to refresh when you click the link, set the partialTrigger property of the table to the id of the button.
To control the visibility of the columns you'll need to use the objects in the dataList.
For example, you could have the fields column1Visible and column2Visible in those objects (with public getters and setters).

Get selected values from MultiCombo in Ext.NEt via JS

I am using Ext.Net I have a form with a ComboBox which I have just changed to a MultiCombo.
Previously I used "SelectEnquiry.getValues()" to retrieve the selected item and pass it into a parameter used with a Button Direct Event.
How do I get the selected values when using the MultiCombo?
Combo Box Bit
<ext:MultiCombo runat="server" ID="SelectEnquiry" FieldLabel="Enquiry" AnchorHorizontal="95%" Editable="false" ValueField="Id" DisplayField="ProviderName" TypeAhead="true" Mode="Local" ForceSelection="true" TriggerAction="All" EmptyText="Select Enquiry" ValueNotFoundText="Select Enquiry" ItemSelector="div.list-item" SelectOnFocus="true" AllowBlank="false">
Button form submit bit
<ext:Button runat="server" ID="ButtonEmailTaskAccept" Text="OK">
<Listeners>
<Click Handler="if (PanelUnlinked.isVisible() && !$form.validate( [SelectProject, SelectEnquiry])) return false;">
</Click>
</Listeners>
<DirectEvents>
<Click Url='<%# Url.Action("CompleteEmailTask") %>' AutoDataBind="true"
Success="window.$messageBus.publish('task-admin', 'inbox-changed');
window.$messageBus.publish('task-admin', 'task-changed');
WindowAssignEmail.close()" Failure="$shell.requestFailedHandler(response, null)"
Json="true">
<EventMask ShowMask="true"></EventMask>
<ExtraParams>
<ext:Parameter Name="emailResponseId" Value="<%# Model.EmailResponse.Id %>" Mode="Value"
AutoDataBind="true" />
<ext:Parameter Name="enquiryId" Value="SelectEnquiry.getValues()" Mode="Raw" />
<ext:Parameter Name="documentList" Value="buildSelectionList()" Mode="Raw" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>
With <ext:MultiCombo> you can just call .getValue() to return an Array of selected values. I'll look into adding .getValues() as well, so it's consistent with the <ext:ComboBox> api.
Edit
It appears the ComboBox does not have a client-side .getValues() function, so we won't be adding to the MultiCombo. Just use .getValue(), which is standardised across all Form Fields.
The problem seemed to be that it could not locate the control I was try to get the value from.
So managed to solve it by doing:
#{SelectEnquiry}.getSelectedValues()

How to display two different types of components based on a boolean variable in jsf?

I have thought about this for a while - not getting a good idea.
This is the problem. I will have to display a text either in a text box or as an output text. How do I do this using a boolean variable in JSF?
I do not want to make an h:inputText and disable/make read only, it based on the boolean , I want to display a clean label or an output text.
suggestions ?
Make use of the rendered attribute. It takes a boolean expression.
<h:inputText value="#{bean.input}" rendered="#{bean.editmode}" />
<h:outputText value="#{bean.input}" rendered="#{!bean.editmode}" />
If the expression evaluates true, the component will be rendered in the component tree and be visible in the generated HTML output. If it evaluates false, it will not be rendered and thus not be emitted to the HTML output.
Here are several other examples how you could express a boolean expression.
<h:someComponent rendered="#{bean.booleanValue}" />
<h:someComponent rendered="#{bean.intValue > 10}" />
<h:someComponent rendered="#{bean.objectValue == null}" />
<h:someComponent rendered="#{bean.stringValue != 'someValue'}" />
<h:someComponent rendered="#{!empty bean.collectionValue}" />
<h:someComponent rendered="#{!bean.booleanValue && bean.intValue != 0}" />
<h:someComponent rendered="#{bean.stringValue == 'oneValue' || bean.stringValue == 'anotherValue'}" />

Resources