Multiline textbox in Formview with DynamicDataTemplatesCS - binding

Using model binding with the above like so:
<asp:FormView runat="server" ID="ConversationForm" DefaultMode="Edit"
OnCallingDataMethods="ConversationForm_CallingDataMethods"
ItemType="MyApp.Model.Conversation"
DataKeyNames="ConversationID"
SelectMethod="GetConversation"
UpdateMethod="UpdateConversation"
OnItemUpdated="Conversation_ItemUpdated">
<EditItemTemplate>
<fieldset>
<legend>Conversation Notes:</legend>
<ol>
<asp:DynamicEntity runat="server" Mode="Edit" />
</ol>
</fieldset>
<asp:Button ID="btnUpdate" runat="server" Text="Save" CommandName="Update" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" OnClick="btnCancel_Click" />
</EditItemTemplate>
</asp:FormView>
The Conversation entity basically has one property, "Text", which should contain freeform text captured by the user.
The DynamicEntity control generates a simple textbox for this property as it has a datatype of string.
How do I tell it to create a multiline textbox instead?
Can I add some sort of data annotation to the Conversation class that will tell the Dynamic Templates to create a multiline textbox?

It does not seem to be possible so I had to revert to using a static asp:Textbox control with the TextMode="MultiLine" property set.

Related

displaying bean class items on view - beginner

The bean class looks like this:
String houseNo
String address
Person person
The view looks like this
<g:form action="save">
<fieldset class="form">
<g:render template="form" />
</fieldset>
<fieldset class="buttons">
<g:submitButton name="create" class="save"
value="${message(code: 'default.button.create.label', default: 'Create')}" />
</fieldset>
</g:form>
According to my knowledge in Grails, i think is <g:render template="form" /> will pull all form attributes and display it.
But what i want to do is Instead of displaying a drop-down for Person, i want to display all Person related fields like personName, personAge. How can i display these fields in a label underneath ?
Help
You're correct about the way g:render works, the template part refers to a GSP which will look through the bean values and print them according to the html + groovy markup in "_form.gsp" (located in your views folder under the controller name).
To change the way the Person domain object is displayed, simply edit this "_form.gsp" and take out the 'select' html code - replacing it with groovy markup using the property values of the bean, eg.
${beanName.person.personName} //(use the existing code to help workout the bean name etc)
Hopefully that helps you on your way.

Render selectManyCheckbox without HTML table

is there a way to remove the table out of rendered html that is created by the h:selectManyCheckbox tag in server faces?
I am using twitter bootstrap and i placed the checkboxes inside a dropdown menu:
<ul class="dropdown-menu dropdown-menu-form">
<li><label class="checkbox"> <input type="checkbox" />
Activated
</label></li>
<li><label class="checkbox"> <input type="checkbox" />
Deactivated
</label></li>
</ul>
So the generated html table destroys the layout ...
You could just render a bunch of <h:outputLabel><h:selectBooleanCheckbox> inside <ui:repeat>. This way you've markup freedom. You'll only need to alter the model from e.g. List<T> to Map<T, Boolean> to represent the checked values and then loop over the map afterwards to collect checked ones.
A ready-to-use component is Tomahawk's <t:selectManyCheckbox> which has an additional layout attribute value of spread.

How to automatically populate value from action class to the JSP TextBox

I am able to print value from Java Action Class to JSP Page without textbox, But when I want to put that value in a TextBox in JSP, its not coming.
My Code is :
<S:form>
<s:textfield name="toDate" key="td" > <s:property value="fromDate"/> </s:textfield>
<s:textfield name="fromDate" key="fd"> <s:property value="toDate" /> </s:textfield>
<s:submit value="Confirm"></s:submit>
</s:form>
toDate and fromDate is variables in Java Class.
Just dive in the Struts2 UI Tag documentation:
key : Set the key (name, value, label) for this particular component
If you want them different (eg. toDate the value to set, td the value to read, and so on), specify all of them:
<s:form>
<s:textfield name="toDate" value="td" label="To date" />
<s:textfield name="fromDate" value="fd" label="From date" />
<s:submit value="Confirm" />
</s:form>
(Obviously according to your getters and setters).
You can set value in TextBox using value attribute of <s:textfield> tag to value come from action class.
For this you have your getter and setter method for that variable in action class and read that value by below code:
For Example :
<s:textfield name="some_name" value="%{variable}"/>
your code look like this:
<s:form>
<s:textfield name="toDate" value="%{fromDate}" />
<s:textfield name="fromDate" value="%{toDate}" />
<s:submit value="Confirm" />
</s:form>

Display table tag in struts 2

<display:table export="true" id="data" name="${sessionScope.forbesList}"requestURI="">
<a href="#" rel="tooltip" content="<span>
Name:<s:property value="#data.rank" /><br/>
Email: <a><s:property value="#data.name" /></a><br/>
Phone:<s:property value="#data.age" /> </span>"> <display:column property="rank" title="Rank" sortable="true" /></a>
<display:column property="name" title="Name" sortable="true" />
<display:column property="age" title="Age" sortable="true" />
</display:table>
In Struts 2 I'm trying to use <s:property> tag inside <display :column> tag but I can only see the <display:column> values and not the values that I access with <s:property>. How to do it?
#1: Anchor (<A>) Tag does not have any content attribute.
Please refer to the documentation to see which attributes it supports and how to use them.
#2: in HTML, when putting the character " into an attribute of a Tag, you can:
substitute " with ', like in
myAttribute="this is 'right'" or
myAttribute='this is "right" too', or
encode the " with the html entity ", like in
myAttribute="this is "right""
You must encode the < and > too, with < (Less Than) or > (Greater Than).
#3: that said, you could put your HTML inside the Anchor Tag, in the place where it is supposed to be inserted, like :
<a href="#" rel="tooltip">
Name:<s:property value="#data.rank" />
</a>
but, in your case, you are injecting a lot of HTML, including another Anchor, that is not possible. I think you should simply use a div or something similar as a container, like:
<div rel="tooltip" >
<span>
Name:<s:property value="#data.rank" /><br/>
Email: <a><s:property value="#data.name" /></a><br/>
Phone:<s:property value="#data.age" />
</span>
</div>
Resolve this before worrying about DisplayTag
EDIT
#4
Change
<s:property value="#data.rank" />
(and all the other tags) to
<s:property value="#attr.data.rank" />
#attr is the OGNL used to access the pageContext,
if it is available, otherwise it searches request, session and application scopes.

Grails filterPane plugin to fit page layout

I would like to have the filterPane to be inserted in my own div in order to fit my page layout. Basically I want to get rid of the default pop-up behavior and harmonize filterPane with the other elements of the application.
this is my gsp
<div class="filter">
<p>
<filterpane:isFiltered>
<filterpane:currentCriteria domainBean="demoracer.Pilot" />
</filterpane:isFiltered>
</p>
<g:formRemote method="post" name="form_search" url="${[action:'list']}" update="listContainer" >
<filterpane:filterPane customForm="true" formName="form_search" domainBean="demoracer.Pilot"
filterProperties="name," id="filterpaneContainer" />
<g:actionSubmit value="Apply Filter From Outside Filter Pane" action="list" />
</g:formRemote>
</div>
but the pane do not show up.
Thanks
Since the filterpane generates its own div, can't you just use the div it generates and restyle it to fit your layout? You can specify the id, class, and style attributes of the container div it generates. That should be more than enough to restyle it any way you'd like.
it doesn't seems possible since the html is statically created by the taglib
def output = """\
<div id="${containerId}"
class="filterPane ${containerClass ?: ''}"
style="display:none;${containerStyle}">
<h2>${title}</h2>
${openFormTag}
<input type="hidden" name="filterProperties" value="${propsStr}" />
<table cellspacing="0" cellpadding="0" class="filterTable">
"""

Resources