Link to home
Create AccountLog in
Avatar of deathstar641
deathstar641

asked on

Getting a jTextfield value in a table using JSF+JSP

Hello, I am having the following table as shown in the picture below. I want to input some values on the textfields of this table, and when I hit the button 'Calculate' I want to get them. But in the action method of the button I use:
String value = firstPageField.getText().toString(); but it returns null. Any thoughts?

I should also add that this table takes values from a session javabean (its public properties basically) using
an ObjectListDataProvider.

Thanks in advance.



table.PNG
Avatar of Kuldeepchaturvedi
Kuldeepchaturvedi
Flag of United States of America image

you sure that your table is inside a form object? In order to get the variable back to the action, it needs to be in the form of the page.
Avatar of deathstar641
deathstar641

ASKER

Yes it's on the main form created automatically with every new JSF page. Keep in mind also, that if I put the 'Calculate' button (remember that its action checks for the value of the textfield) in an additional column of the table then it works fine !!
>>remember that its action checks for the value of the textfield) in an additional column of the table then it works fine !!
Which means that the JSF is treating your table as a different form and the button as a different form...
( It will happen if you have designed it that way in your jsf).. can you post the code of the jsf? that will help.
OK ..this is the code of the table
<webuijsf:table binding="#{licencewizard$BasicResults.resultTable}" id="resultTable" lite="true" paginationControls="true"
                                style="left: 10%; top: 18%; position: relative; width: 600px" title="#{msg.SearchResultsBasic}" width="600">
                                <webuijsf:tableRowGroup aboveColumnFooter="true" binding="#{licencewizard$BasicResults.tableRowGroup1}" id="tableRowGroup1"
                                    rows="10" sourceData="#{licencewizard$BasicResults.osdelbooksDataProvider}" sourceVar="currentRow">
                                    <webuijsf:tableColumn align="center" binding="#{licencewizard$BasicResults.tableColumn1}"
                                        headerText="#{msg.SearchResults_tc1}" id="tableColumn1" style="#{licencewizard$BasicResults.columnStyle}" valign="middle">
                                        <webuijsf:staticText binding="#{licencewizard$BasicResults.staticText1}" id="staticText1" text="#{currentRow.value['Titles1']}"/>
                                    </webuijsf:tableColumn>
                                    <webuijsf:tableColumn align="center" binding="#{licencewizard$BasicResults.tableColumn2}"
                                        headerText="#{msg.SearchResults_tc7}" id="tableColumn2" style="#{licencewizard$BasicResults.columnStyle}" valign="middle">
                                        <webuijsf:staticText binding="#{licencewizard$BasicResults.staticText2}" id="staticText2" text="#{currentRow.value['Name']}"/>
                                    </webuijsf:tableColumn>
                                    <webuijsf:tableColumn align="center" binding="#{licencewizard$BasicResults.tableColumn3}"
                                        headerText="#{msg.SearchResults_tc4}" id="tableColumn3" style="#{licencewizard$BasicResults.columnStyle}" valign="middle">
                                        <webuijsf:staticText binding="#{licencewizard$BasicResults.staticText3}" id="staticText3" text="#{currentRow.value['Ekdotis']}"/>
                                    </webuijsf:tableColumn>
                                    <webuijsf:tableColumn align="center" binding="#{licencewizard$BasicResults.tableColumn7}"
                                        headerText="#{msg.SearchResults_tc6}" id="tableColumn7" style="#{licencewizard$BasicResults.columnStyle}" valign="middle">
                                        <webuijsf:staticText binding="#{licencewizard$BasicResults.staticText7}" id="staticText7" text="#{currentRow.value['Etos1st']}"/>
                                    </webuijsf:tableColumn>
                                    <webuijsf:tableColumn align="center" binding="#{licencewizard$BasicResults.tableColumn8}"
                                        headerText="#{msg.SearchResults_tc2}" id="tableColumn8" style="#{licencewizard$BasicResults.columnStyle}" valign="middle">
                                        <webuijsf:staticText binding="#{licencewizard$BasicResults.staticText8}" id="staticText8" text="#{currentRow.value['OsdelCat']}"/>
                                    </webuijsf:tableColumn>
                                    <webuijsf:tableColumn align="center" binding="#{licencewizard$BasicResults.tableColumn9}" headerText="ISBN"
                                        id="tableColumn9" style="#{licencewizard$BasicResults.columnStyle}" valign="middle" width="53">
                                        <webuijsf:staticText binding="#{licencewizard$BasicResults.staticText9}" id="staticText9" text="#{currentRow.value['ISBN']}"/>
                                    </webuijsf:tableColumn>
                                    <webuijsf:tableColumn align="center" binding="#{licencewizard$BasicResults.tableColumn10}"
                                        headerText="#{msg.SearchResults_tc3}" id="tableColumn10" style="#{licencewizard$BasicResults.columnStyle}"
                                        valign="middle" width="78">
                                        <webuijsf:staticText binding="#{licencewizard$BasicResults.staticText10}" id="staticText10" text="#{currentRow.value['Selides']}"/>
                                    </webuijsf:tableColumn>
                                    <webuijsf:tableColumn align="center" binding="#{licencewizard$BasicResults.tableColumn4}"
                                        headerText="#{msg.SearchResults_tc8}" id="tableColumn4" rowHeader="true"
                                        style="#{licencewizard$BasicResults.columnStyle}" valign="middle" width="200">
                                        <webuijsf:button actionExpression="#{licencewizard$BasicResults.addToLicence_action}"
                                            binding="#{licencewizard$BasicResults.addToAcademicLicence}" id="addToAcademicLicence"
                                            imageURL="/resources/cart.png" mini="true" onMouseOut="document.getElementById('form1:academicBubble').close();"
                                            onMouseOver="document.getElementById('form1:academicBubble').open(event);" text="Button"/>
                                    </webuijsf:tableColumn>
                                </webuijsf:tableRowGroup>
                            </webuijsf:table>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of deathstar641
deathstar641

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
that would have worked...
you can ask the mods to close this question and refund your points.