Aligning data in JSP while using struts2 - struts2

While using struts2 tags I wrote jsp as
<s:textfield name="NumOfSeats" label="No. of Berths"/>
<sx:datetimepicker name="date" label="Date of journey" displayFormat="dd-MM-yyyy" />
<s:textfield name="trainNo" label="Train no"/>
I got my page like this(Lables and textfilelds at same height)
As I need datetimepicker I added this <sx:head></sx:head>. Then page became like this(label and text field at different heights)
What can I do for making them to align at same height.

Related

how can i separate an iterated struts radio button item?

How can i separate an iterated struts radio button item?
I also tried using some of these
,but probably in the wrong way.
What i wish to do is separate each item from the first iterator (the paths), with a <br> or any separator.
I guess this is happening because the html tags are interpreted first, before the struts tags?
<s:form action="actionConfirmBooking">
<s:iterator var = "pathList" value="results">
<s:iterator var = "flightList" value="pathList">
<s:radio name="flightSelected" list="flightList" listKey = "flightid" id = "flightid" value = "flightid"/>
$$$$$$$$$$$
</s:iterator>*************
</s:iterator>&&&&&&&&
<s:submit label="Submit" />#############
</s:form>
Use theme="simple" to prevent Struts generating additional XHTML code by using the default theme (XHTML):
<s:form action="actionConfirmBooking" theme="simple">
...
</s:form>

How to change a f:field (textField) by a textArea using Grails Fields Plugin

In the documentation changelog of the plugin, at Version 1.1, we can read:
Support `widget:'textarea'` constraint.
Grails has a textArea field. This is the example of the grails documentation:
<g:textArea name="myField" value="myValue" rows="5" cols="40"/>
But, if we are using Grails Fields Plugin, and we have a code like:
<f:field bean="popularExpressionsInstance" property="omg" />
How could we convert it to textArea to allow to type several lines of text?
In your popularExpressions domain class, add the following constraint for omg
static constraints = {
...
omg widget: 'textarea'
}
Note: if you need to control style of textarea, you'll need to include it in the body of the f:field tag, for example
<f:field bean="popularExpressionsInstance" property="omg">
<g:textArea name="omg" cols="40" rows="5" maxlength="40" value="some default text"/>
</f:field>
You can override body of tag directly in GSP, as #user2264997 mentioned, but use ${ property } and ${it.value} variables:
<f:field property="description" widget="textarea">
<g:textArea name="${ property }" cols="40" rows="5"
value="${it.value}" />
</f:field>

zk nested forEach

I have following structure to display in zul file and got List of clinic object from Java controller.
I tried several zk components in zul with no luck. What component should I use with a forEach?
ListBox
ListItem
Grid
Here is structure need to display :
For each clinic
{
For each clinic.location
{
For each (clinic.location.provider)
{
Output (provider display name)
}
Output (clinic name)
Output (clinic.location address)
Output (clinic.locatoin telephone number)
Output (clinic.web address)
}
}
As explained in the answer given by Darius, here is an example of how to use a <Grid> with a <rows> component
<?page title="Result"?>
<zk>
<window apply="org.zkoss.bind.BindComposer"
viewModel="#id('vm') #init('fully.qualified.viewmodel.classname')"
title="Result Window" border="normal" >
<div>
<grid>
<rows>
<row>
<listbox model="#bind(vm.listname)">
<listhead>
<listheader label="Item Name"
style="text-align:center;">
</listheader>
<listheader label="Attribute Value"
style="text-align:center;">
</listheader>
<listheader label="Qualifier Value"
style="text-align:center;">
</listheader>
</listhead>
<template name="model" var="item">
<listitem value="${item }">
<listcell label="#load(item.name)"
style="text-align:center;">
</listcell>
<listcell
style="text-align:center;">
<textbox
value="#bind(item.attributeValue)"
style="text-align:center;" />
</listcell>
<listcell
label="#load(item.qualifierValue)"
style="text-align:center;">
</listcell>
</listitem>
</template>
</listbox>
</row>
</rows>
</grid>
</div>
</window>
</zk>
You can use a Listbox or a Grid.
If you use a Listbox, it will contain Listitem objects
If you use a Grid, it will contain a Rows object, which will contain Row objects
To the Listitem or the Row, you will add other components: the simplest would be Label objects
I notice you have an inner table of providers. For these, you will probably need a nested Grid or Listbox. You could also use ZK's Detail component. it would allow you to expand in order to see the inner table.
There are multiple ways how to achieve this
including separate zul file to template row, whitch will contain a grid with separate view model - this style you can have shown all nested grid at once ,but it should and it will have performance issiues with larger ammout of data(because count of rows == count of viewmodels of nested grids)
include nested grid with own template ,and data model as parameter of view model,and show this grid on demand(button click,row click etc) - this is bether way in case of no performance issues,but you will be able to show only one nested grid at time
Final words - just don´t
Nesting a grid to grid is a very bad design,because it is incredibly hard to render this,and it is only usable for small data. The best way to do this,in my opinion is to create two separate grids,side by side,and show adition data on in second grid,after a click on row in first grid. This way you can achieve very fast gui with no performance issiues,ever with a lot of data. Another way is to create a popup on grid row,whitch will show additional data,a it is also a lot bether for your performance.

Issue with displaying Error message in a page having two forms

I am developing one JSF page, in that i am having two forms. And I am using rich:messages in both the forms.
Suppose, in the first form, if I don't enter any required fields and I click Save, then error messages are displaying twice in the page(as i am using rich:messages in two forms).
Is there any way so that error messages display with respect to the form?
Thanks in advance.
If you are using RichFaces 3.3.3.Final you can do it like so:
<a4j:form id="tmpfrm1">
<rich:messages />
<h:inputText value="#{mybean.intmp1}" required="true"/>
<a4j:commandButton value="save" action="#{mybean.test1}" reRender="tmpfrm1" limitToList="true" />
</a4j:form>
<a4j:form id="tmpfrm2">
<rich:messages />
<h:inputText value="#{mybean.intmp2}" required="true"/>
<a4j:commandButton value="save" action="#{mybean.test2}" reRender="tmpfrm2" limitToList="true" />
</a4j:form>
If you are uisng RichFaces 4 you need to replace the limitToList with limitRender and the reRender with render

How to make items (columns) in <apex:pageBlockTable> hyperlink?

I successfully created tables with style that salesforce provided. (like the one that highlighted on mouseover etc)
But I want the value of column to be a link to display detail info of the object.
When I don't create my own visualforce page, the table looks nice and the column
values (records) are all hyperlinked but can't figure out how to do it from visualforce apex code.
pageBlockTable and column definition does not seem to have attributes or anything that
make it hyperlink.
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_pageBlockTable.htm
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_column.htm
<apex:pageBlock title="test">
<apex:pageBlockTable value="{!workObj}" var="item">
<!-- below needs to be hyperlink -->
<apex:column value="{!item.name}" />
</apex:pageBlockTable>
</apex:pageBlock>
I could achieve my goal by throwing the good design away like below but I would like to keep the code above.
This works but no salesforce style is applied.
<apex:pageBlock title="my test title" >
<apex:dataTable value="{!workObj}" var="wn" cellpadding="2" cellspacing="2">
<apex:column>
<apex:facet name="header">仕事名一覧</apex:facet>
<apex:form >
<apex:commandLink value="{!wn.name}" />
</apex:form>
</apex:column>
</apex:dataTable>
</apex:pageBlock>
Instead of <apex:column value="{!item.name}" />, try doing it like this in the column body:
<apex:pageBlock title="test">
<apex:pageBlockTable value="{!workObj}" var="item">
<apex:column>
<apex:outputLink value="{!item.name}">{!item.name}</apex:outputLink>
</apex:column>
<apex:pageBlock title="test">
<apex:pageBlockTable value="{!workObj}" var="item">

Resources