bbNG:textbox is working

Last week I had a big problem getting the bb-tag bbNG:textbox to work. I simply couldn’t extract the request parameter within my servlet that receives the bbNG:form request! There would be nothing in it, even though a similar bbNG:textElement would work perfectly.

The solution to this problem shows quite nicely, how a B2 developer needs to expect that the B2 API break normal web-dev expectations! So normally you’d have something like this,

<bbNG:dataElement isRequired=”true” label=”<%=nLabel%>”>                    <bbNG:textElement name=”content_title” id=”content_title” isRequired=”true” minLength=”3″ maxLength=”255″ size=”40″ value=”<%=parent_id %>”/>                </bbNG:dataElement>

inside a jsp. You’d then access the parameter inside a servlet like this,

String title = request.getParameter(“content_title”);

This corresponds quite nicely with how normal forms in web-dev are treated. This is NOT how bbNG:textbox works. Here youd have to add “text” to the getParameter call. So, with this jsp element,

<bbNG:dataElement isRequired=”false” label=”<%=cTextLabel%>”>

<bbNG:textbox name=”<b>content_text</b>”

you’d normally expect to get the parameter by doing something like this:

FormattedText contentText = new FormattedText(request.getParameter(“content_text”), FormattedText.Type.HTML);

BUT don’t! You have to do this:

FormattedText contentText = new FormattedText(request.getParameter(“content_texttext”), FormattedText.Type.HTML);

Awkward? Yes, I know…

This entry was posted in Plugin development and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *