Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

STRUTS: Getting values of the checked 'checkboxes' using <html:multibox>

Posted on 2003-11-03
7
Medium Priority
?
2,747 Views
Last Modified: 2010-08-05
Hi,

I seem to be having problems trying to get the values of the selected checkboxes I have. I have a page (in a frame) that iterates over some results taken from a db (using a hashmap).

my configItem.jsp:

    <html:form action="/ConfigItemListAction"
               name="configItemsListForm"
               type="com.hp.adm.workOrder.ConfigItemsListForm" >
               
<logic:iterate id="configItem" name="configItems" scope="session">

<tr>
    <td width=20 height=18 valign=top align="left"  bgcolor="#E7E7E7" class="bold" scope="row"><div style="width:20px;overflow:hidden">
        <html:multibox property="selectedItems">
            <bean:write name="configItem" property="key" />
        </html:multibox>
            <bean:write name="configItem" property="key" />
      </td>
      <td width=80 height=18 valign=top align="left"  bgcolor="#E7E7E7" scope="row">
        <bean:write name="configItem" property="value.searchCode"/>
      </td>
      <td valign=center width="1"  height=18  nowrap bgcolor="#333366"><html:img src="/ADM/images/s.gif" /></td>
      <td width=156 height=18 valign=top align="left"  bgcolor="#E7E7E7" scope="row">
        <bean:write name="configItem" property="value.ciName2"/>
        <input type="textbox" name="databaseCheck" value="<bean:write name="configItem" property="value.inDatabaseAlready"/>">        
      </td>
</tr>

</logic:iterate>

</html:form>

As you could see, I use the hashmap's key as the value for the <html:multibox> that is iterated. Unfortunately, when I click on a submit button (that is located from another frame) I can't seem to get the values to show. I either get a NULL or a NullPointerException when I try to get the length of the array.

Here's my jsp that has the submit button: (take note it doesn't have a <html:form> tag anymore)

<A href="/ADM/RemoveConfigItem.do"><html:img src="/ADM/images/delete_button.gif" border="0"/></A>

Here's my actionform:

public class ConfigItemsListForm extends ActionForm {
   
    protected String[] selectedItems = null;
   
    public String[] getSelectedItems() {
        return this.selectedItems;
    }
       
    public void setSelectedItems(String[] selectedItems) {
       this.selectedItems = selectedItems;
    }
   
    public void reset(ActionMapping mapping, HttpServletRequest request)
    {
        this.selectedItems = null;
    }    

}

Finally, my Action (which is where the /RemoveConfigItem.do points to):

ConfigItemsListForm configItemsListForm = (ConfigItemsListForm)form;
               
 //Get the list of selected checkboxes
 String[] removeConfigList = configItemsListForm.getSelectedItems();

System.out.println(removeConfigList); //gives me NULL
System.out.println(removeConfigList.length); //gives me a NullPointerException

...other codes that manipulate the removeConfigList...

What am I doing wrong? Thanks in advance!
0
Comment
Question by:rusco
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 14

Expert Comment

by:kennethxu
ID: 9682569
>> Here's my jsp that has the submit button: (take note it doesn't have a <html:form> tag anymore)
how can a submit button in one jsp page to submit checkbox in another jsp page? is this what u r trying to do?
0
 

Author Comment

by:rusco
ID: 9683746
Technically yes. The design of the page is to have an iframe that will have two pages in it. One is the page that has values that are iterated on the screen (along with the checkbox) and the submit button (as well as two other buttons) will be placed in another screen. I'm quite not sure how to explain this properly though, jsut that it will end up looking like a little panel that of a screen that has buttons and the values in the center of that 'panel'. The two pages are name configItem.jsp and configItemFrame.jsp.

Anyway, I thought that when in the execute method you can get the 'values' of a given form (whatever form that is) by using the getNameOfMethod of that given form? Kinda new in struts so I'm not quite sure I understand this well.

Thanks :-)
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 400 total points
ID: 9684323
iframe is logically another page. a submit button usually only submit a form it belongs to, unless you use javascript to submit another form.  but no matter how you cannot submit 2 forms, not metion of 2 pages. that's the limitation of browser and has nothing to do with struts. thers is nothing that struts can do while browser didn't supply the informaiton in the first place.

if you intend to submit all the information, then why not put everything in one page instrea  of using iframe?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 14

Expert Comment

by:kennethxu
ID: 9831234
glad to know you probem is resolved.
is there anything wrong in my comments lead to a B grade?
0
 

Author Comment

by:rusco
ID: 9834600
Hi Kennethxu,

Sorry about that, it was suppose to be a grade A. I think I clicked on grade B when I submitted. I'll be asking the moderators if they could possibly get this changed. :-)

Thanks!
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9834642
No prolem, that happends. Thank you too :-)
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question